PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
66:6281a40d73e6
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 31:f4b9b85c7b62 1 /**************************************************************************/
Pokitto 31:f4b9b85c7b62 2 /*!
Pokitto 31:f4b9b85c7b62 3 @file Synth.h
Pokitto 31:f4b9b85c7b62 4 @author Jonne Valola
Pokitto 31:f4b9b85c7b62 5
Pokitto 31:f4b9b85c7b62 6 @section LICENSE
Pokitto 31:f4b9b85c7b62 7
Pokitto 31:f4b9b85c7b62 8 Pokitto development stage library
Pokitto 31:f4b9b85c7b62 9 Software License Agreement
Pokitto 31:f4b9b85c7b62 10
Pokitto 31:f4b9b85c7b62 11 Copyright (c) 2015, Jonne Valola ("Author")
Pokitto 31:f4b9b85c7b62 12 All rights reserved.
Pokitto 31:f4b9b85c7b62 13
Pokitto 31:f4b9b85c7b62 14 This library is intended solely for the purpose of Pokitto development.
Pokitto 31:f4b9b85c7b62 15
Pokitto 31:f4b9b85c7b62 16 Redistribution and use in source and binary forms, with or without
Pokitto 31:f4b9b85c7b62 17 modification requires written permission from Author.
Pokitto 31:f4b9b85c7b62 18 */
Pokitto 31:f4b9b85c7b62 19 /**************************************************************************/
Pokitto 31:f4b9b85c7b62 20
Pokitto 31:f4b9b85c7b62 21 #ifndef SYNTH_H
Pokitto 31:f4b9b85c7b62 22 #define SYNTH_H
Pokitto 31:f4b9b85c7b62 23
Pokitto 31:f4b9b85c7b62 24 #include "Synth_osc.h"
Pokitto 31:f4b9b85c7b62 25 #include "Synth_song.h"
Pokitto 31:f4b9b85c7b62 26
Pokitto 31:f4b9b85c7b62 27
Pokitto 31:f4b9b85c7b62 28 /* PROPER WAY
Pokitto 31:f4b9b85c7b62 29 void f() {}
Pokitto 31:f4b9b85c7b62 30
Pokitto 31:f4b9b85c7b62 31 int main()
Pokitto 31:f4b9b85c7b62 32 {
Pokitto 31:f4b9b85c7b62 33 using FunctionPtr = void (*)();
Pokitto 31:f4b9b85c7b62 34
Pokitto 31:f4b9b85c7b62 35 FunctionPtr ptr = f;
Pokitto 31:f4b9b85c7b62 36 }
Pokitto 31:f4b9b85c7b62 37 */
Pokitto 31:f4b9b85c7b62 38
Pokitto 66:6281a40d73e6 39 #define OPT_ADSR 1
Pokitto 66:6281a40d73e6 40 #define OPT_LOOP 2
Pokitto 66:6281a40d73e6 41 #define OPT_ECHO 4
Pokitto 66:6281a40d73e6 42 #define OPT_OVERDRIVE 8
Pokitto 66:6281a40d73e6 43 #define OPT_NORMALIZE 0x10
Pokitto 66:6281a40d73e6 44
Pokitto 66:6281a40d73e6 45 #define OVERDRIVE 4
Pokitto 31:f4b9b85c7b62 46
Pokitto 31:f4b9b85c7b62 47 //extern void fakeISR(); // was defined in Rboy_soundsim.h
Pokitto 31:f4b9b85c7b62 48
Pokitto 31:f4b9b85c7b62 49 typedef void (*waveFunction)(OSC*);
Pokitto 31:f4b9b85c7b62 50 typedef void (*envFunction)(OSC*);
Pokitto 31:f4b9b85c7b62 51 typedef void (*mixFunction)();
Pokitto 66:6281a40d73e6 52 typedef void (*streamsFunction)();
Pokitto 31:f4b9b85c7b62 53
Pokitto 31:f4b9b85c7b62 54 extern waveFunction Farr [];
Pokitto 31:f4b9b85c7b62 55 extern envFunction Earr [];
Pokitto 31:f4b9b85c7b62 56 extern mixFunction Marr []; // counts down
Pokitto 31:f4b9b85c7b62 57 extern mixFunction HWMarr []; // counts down
Pokitto 31:f4b9b85c7b62 58 /** COMMON TO BOTH HW AND SIM SOUND OUTPUT **/
Pokitto 31:f4b9b85c7b62 59
Pokitto 31:f4b9b85c7b62 60 #define RBTRACKER_VERSION 0.03f
Pokitto 31:f4b9b85c7b62 61
Pokitto 31:f4b9b85c7b62 62 #define WOFF 0
Pokitto 31:f4b9b85c7b62 63 #define WSQUARE 1
Pokitto 31:f4b9b85c7b62 64 #define WSAW 2
Pokitto 31:f4b9b85c7b62 65 #define WTRI 3
Pokitto 31:f4b9b85c7b62 66 #define WNOISE 4
Pokitto 31:f4b9b85c7b62 67 #define WSAMPLE 5
Pokitto 31:f4b9b85c7b62 68 #define WPNOISE 5
Pokitto 31:f4b9b85c7b62 69
Pokitto 31:f4b9b85c7b62 70 #define OVERDRIVE 4
Pokitto 31:f4b9b85c7b62 71
Pokitto 31:f4b9b85c7b62 72 #define ARPSTEPMAX 4 // was 5
Pokitto 31:f4b9b85c7b62 73 #define PATTERNLENGTH 64
Pokitto 31:f4b9b85c7b62 74 #define MAXPATTERNS 10
Pokitto 66:6281a40d73e6 75
Pokitto 66:6281a40d73e6 76 #ifdef PROJ_SYNTH_MAXBLOCKS
Pokitto 66:6281a40d73e6 77 #define MAXBLOCKS PROJ_SYNTH_MAXBLOCKS
Pokitto 66:6281a40d73e6 78 #else
Pokitto 31:f4b9b85c7b62 79 #define MAXBLOCKS 30 // 10 *3
Pokitto 66:6281a40d73e6 80 #endif
Pokitto 31:f4b9b85c7b62 81
Pokitto 66:6281a40d73e6 82 #ifdef PROJ_SYNTH_MAXPATCHES
Pokitto 66:6281a40d73e6 83 #define MAXPATCHES PROJ_SYNTH_MAXPATCHES
Pokitto 66:6281a40d73e6 84 #else
Pokitto 66:6281a40d73e6 85 #define MAXPATCHES 15
Pokitto 66:6281a40d73e6 86 #endif
Pokitto 66:6281a40d73e6 87
Pokitto 66:6281a40d73e6 88 #define VOLTICK POK_AUD_FREQ/8820 //was 5
Pokitto 66:6281a40d73e6 89 #define ARPTICK POK_AUD_FREQ/441 // 150 // was 200
Pokitto 31:f4b9b85c7b62 90
Pokitto 31:f4b9b85c7b62 91 #define NUMWAVES 5
Pokitto 31:f4b9b85c7b62 92 #define NUMENVELOPES 3
Pokitto 31:f4b9b85c7b62 93 #define NUMMIXES 4
Pokitto 31:f4b9b85c7b62 94
Pokitto 31:f4b9b85c7b62 95 extern void getNoteString(char *, uint8_t);
Pokitto 31:f4b9b85c7b62 96
Pokitto 31:f4b9b85c7b62 97 extern void playNote(uint8_t,uint8_t,uint8_t);
Pokitto 31:f4b9b85c7b62 98 extern void makeSampleInstruments();
Pokitto 31:f4b9b85c7b62 99
Pokitto 31:f4b9b85c7b62 100 extern void setPitch(int);
Pokitto 31:f4b9b85c7b62 101 extern void setWave(int);
Pokitto 31:f4b9b85c7b62 102 extern void setVolume(int);
Pokitto 31:f4b9b85c7b62 103 extern void initAudio();
Pokitto 31:f4b9b85c7b62 104 extern void testOsc();
Pokitto 31:f4b9b85c7b62 105 extern void terminateSound();
Pokitto 31:f4b9b85c7b62 106 extern void killSound();
Pokitto 31:f4b9b85c7b62 107 extern void startSound();
Pokitto 31:f4b9b85c7b62 108 extern void stopSound();
Pokitto 31:f4b9b85c7b62 109 extern void updatePlayback(); // from flash
Pokitto 31:f4b9b85c7b62 110 extern void updatePlaybackSD(uint8_t); // from SD
Pokitto 31:f4b9b85c7b62 111 extern void initStreams(uint8_t);
Pokitto 31:f4b9b85c7b62 112 extern void emptyOscillators();
Pokitto 31:f4b9b85c7b62 113 extern void emptyPatches();
Pokitto 31:f4b9b85c7b62 114 extern void emptyBlocks();
Pokitto 31:f4b9b85c7b62 115 extern void emptySong();
Pokitto 31:f4b9b85c7b62 116 extern int openSongFromSD(char *);
Pokitto 31:f4b9b85c7b62 117 extern void writeChunkToSD(uint8_t *);
Pokitto 31:f4b9b85c7b62 118 extern void readChunkFromSD(uint8_t *);
Pokitto 66:6281a40d73e6 119 extern void registerStreamsCallback(streamsFunction);
Pokitto 66:6281a40d73e6 120 extern streamsFunction streamCallbackPtr;
Pokitto 31:f4b9b85c7b62 121
Pokitto 66:6281a40d73e6 122 extern bool playing, track1on, track2on, track3on, tableRefresh;
Pokitto 31:f4b9b85c7b62 123 extern uint16_t playerpos;
Pokitto 31:f4b9b85c7b62 124 extern uint16_t samplespertick, notetick;
Pokitto 31:f4b9b85c7b62 125 extern long samplesperpattern;
Pokitto 31:f4b9b85c7b62 126
Pokitto 31:f4b9b85c7b62 127 extern long readindex, writeindex;
Pokitto 31:f4b9b85c7b62 128 extern uint8_t tick, sequencepos;
Pokitto 31:f4b9b85c7b62 129
Pokitto 31:f4b9b85c7b62 130 extern SONG song;
Pokitto 31:f4b9b85c7b62 131 extern OSC osc1,osc2,osc3;
Pokitto 31:f4b9b85c7b62 132 extern OSC patch[];
Pokitto 31:f4b9b85c7b62 133 extern BLOCK block[]; // array of blocks
Pokitto 31:f4b9b85c7b62 134
Pokitto 31:f4b9b85c7b62 135 #define MAX_ARPMODE 16
Pokitto 66:6281a40d73e6 136 #define MAX_WAVETYPES 6
Pokitto 31:f4b9b85c7b62 137
Pokitto 31:f4b9b85c7b62 138 extern int8_t arptable[][5];
Pokitto 31:f4b9b85c7b62 139
Pokitto 31:f4b9b85c7b62 140 extern uint16_t freqs[];
Pokitto 31:f4b9b85c7b62 141 //extern uint16_t cincs[];
Pokitto 31:f4b9b85c7b62 142 extern uint32_t cincs[];
Pokitto 31:f4b9b85c7b62 143
Pokitto 31:f4b9b85c7b62 144 extern uint8_t xorshift8();
Pokitto 31:f4b9b85c7b62 145 extern uint16_t xorshift16();
Pokitto 31:f4b9b85c7b62 146
Pokitto 31:f4b9b85c7b62 147 extern uint16_t noiseval;
Pokitto 31:f4b9b85c7b62 148
Pokitto 31:f4b9b85c7b62 149 extern void setOSC(OSC*,byte, byte, byte, byte, byte,
Pokitto 66:6281a40d73e6 150 uint8_t, uint16_t,
Pokitto 31:f4b9b85c7b62 151 uint16_t, uint16_t, uint16_t, uint16_t,
Pokitto 31:f4b9b85c7b62 152 int16_t, int16_t, uint8_t, uint8_t, uint8_t);
Pokitto 31:f4b9b85c7b62 153
Pokitto 31:f4b9b85c7b62 154 extern void setOSC(OSC*,byte,byte,uint16_t, uint8_t, uint32_t);
Pokitto 31:f4b9b85c7b62 155
Pokitto 31:f4b9b85c7b62 156 extern void waveoff(OSC*);
Pokitto 31:f4b9b85c7b62 157 #endif // SYNTH_H
Pokitto 31:f4b9b85c7b62 158
Pokitto 31:f4b9b85c7b62 159