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

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Committer:
spinal
Date:
Wed Oct 18 14:47:54 2017 +0000
Revision:
15:0bbe8f6fae32
Parent:
0:e8b8f36b4505
direct lcd stuff used by sensitive

Who changed what in which revision?

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