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

Committer:
Pokitto
Date:
Tue Jan 30 10:41:47 2018 +0000
Revision:
31:f4b9b85c7b62
Sound output improvements added:  louder, clearer, faster!

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 31:f4b9b85c7b62 39 #ifndef boolean
Pokitto 31:f4b9b85c7b62 40 typedef bool boolean;
Pokitto 31:f4b9b85c7b62 41 #endif
Pokitto 31:f4b9b85c7b62 42
Pokitto 31:f4b9b85c7b62 43 //extern void fakeISR(); // was defined in Rboy_soundsim.h
Pokitto 31:f4b9b85c7b62 44
Pokitto 31:f4b9b85c7b62 45 typedef void (*waveFunction)(OSC*);
Pokitto 31:f4b9b85c7b62 46 typedef void (*envFunction)(OSC*);
Pokitto 31:f4b9b85c7b62 47 typedef void (*mixFunction)();
Pokitto 31:f4b9b85c7b62 48
Pokitto 31:f4b9b85c7b62 49 extern waveFunction Farr [];
Pokitto 31:f4b9b85c7b62 50 extern envFunction Earr [];
Pokitto 31:f4b9b85c7b62 51 extern mixFunction Marr []; // counts down
Pokitto 31:f4b9b85c7b62 52 extern mixFunction HWMarr []; // counts down
Pokitto 31:f4b9b85c7b62 53 /** COMMON TO BOTH HW AND SIM SOUND OUTPUT **/
Pokitto 31:f4b9b85c7b62 54
Pokitto 31:f4b9b85c7b62 55 #define RBTRACKER_VERSION 0.03f
Pokitto 31:f4b9b85c7b62 56
Pokitto 31:f4b9b85c7b62 57 #define WOFF 0
Pokitto 31:f4b9b85c7b62 58 #define WSQUARE 1
Pokitto 31:f4b9b85c7b62 59 #define WSAW 2
Pokitto 31:f4b9b85c7b62 60 #define WTRI 3
Pokitto 31:f4b9b85c7b62 61 #define WNOISE 4
Pokitto 31:f4b9b85c7b62 62 #define WSAMPLE 5
Pokitto 31:f4b9b85c7b62 63 #define WPNOISE 5
Pokitto 31:f4b9b85c7b62 64
Pokitto 31:f4b9b85c7b62 65 #define OVERDRIVE 4
Pokitto 31:f4b9b85c7b62 66
Pokitto 31:f4b9b85c7b62 67 #define ARPSTEPMAX 4 // was 5
Pokitto 31:f4b9b85c7b62 68 #define PATTERNLENGTH 64
Pokitto 31:f4b9b85c7b62 69 #define MAXPATTERNS 10
Pokitto 31:f4b9b85c7b62 70 #define MAXBLOCKS 30 // 10 *3
Pokitto 31:f4b9b85c7b62 71
Pokitto 31:f4b9b85c7b62 72 #define VOLTICK 5
Pokitto 31:f4b9b85c7b62 73 #define ARPTICK 50 // 150 // was 200
Pokitto 31:f4b9b85c7b62 74
Pokitto 31:f4b9b85c7b62 75 #define NUMWAVES 5
Pokitto 31:f4b9b85c7b62 76 #define NUMENVELOPES 3
Pokitto 31:f4b9b85c7b62 77 #define NUMMIXES 4
Pokitto 31:f4b9b85c7b62 78
Pokitto 31:f4b9b85c7b62 79 extern void getNoteString(char *, uint8_t);
Pokitto 31:f4b9b85c7b62 80
Pokitto 31:f4b9b85c7b62 81 extern void playNote(uint8_t,uint8_t,uint8_t);
Pokitto 31:f4b9b85c7b62 82 extern void makeSampleInstruments();
Pokitto 31:f4b9b85c7b62 83
Pokitto 31:f4b9b85c7b62 84 extern void setPitch(int);
Pokitto 31:f4b9b85c7b62 85 extern void setWave(int);
Pokitto 31:f4b9b85c7b62 86 extern void setVolume(int);
Pokitto 31:f4b9b85c7b62 87 extern void initAudio();
Pokitto 31:f4b9b85c7b62 88 extern void testOsc();
Pokitto 31:f4b9b85c7b62 89 extern void terminateSound();
Pokitto 31:f4b9b85c7b62 90 extern void killSound();
Pokitto 31:f4b9b85c7b62 91 extern void startSound();
Pokitto 31:f4b9b85c7b62 92 extern void stopSound();
Pokitto 31:f4b9b85c7b62 93 extern void updatePlayback(); // from flash
Pokitto 31:f4b9b85c7b62 94 extern void updatePlaybackSD(uint8_t); // from SD
Pokitto 31:f4b9b85c7b62 95 extern void initStreams(uint8_t);
Pokitto 31:f4b9b85c7b62 96 extern void emptyOscillators();
Pokitto 31:f4b9b85c7b62 97 extern void emptyPatches();
Pokitto 31:f4b9b85c7b62 98 extern void emptyBlocks();
Pokitto 31:f4b9b85c7b62 99 extern void emptySong();
Pokitto 31:f4b9b85c7b62 100 extern int openSongFromSD(char *);
Pokitto 31:f4b9b85c7b62 101 extern void writeChunkToSD(uint8_t *);
Pokitto 31:f4b9b85c7b62 102 extern void readChunkFromSD(uint8_t *);
Pokitto 31:f4b9b85c7b62 103
Pokitto 31:f4b9b85c7b62 104
Pokitto 31:f4b9b85c7b62 105 extern boolean playing, track1on, track2on, track3on, tableRefresh;
Pokitto 31:f4b9b85c7b62 106 extern uint16_t playerpos;
Pokitto 31:f4b9b85c7b62 107 extern uint16_t samplespertick, notetick;
Pokitto 31:f4b9b85c7b62 108 extern long samplesperpattern;
Pokitto 31:f4b9b85c7b62 109
Pokitto 31:f4b9b85c7b62 110 extern long readindex, writeindex;
Pokitto 31:f4b9b85c7b62 111 extern uint8_t tick, sequencepos;
Pokitto 31:f4b9b85c7b62 112
Pokitto 31:f4b9b85c7b62 113 extern SONG song;
Pokitto 31:f4b9b85c7b62 114 extern OSC osc1,osc2,osc3;
Pokitto 31:f4b9b85c7b62 115 extern OSC patch[];
Pokitto 31:f4b9b85c7b62 116 extern BLOCK block[]; // array of blocks
Pokitto 31:f4b9b85c7b62 117
Pokitto 31:f4b9b85c7b62 118 #define MAX_ARPMODE 16
Pokitto 31:f4b9b85c7b62 119
Pokitto 31:f4b9b85c7b62 120 extern int8_t arptable[][5];
Pokitto 31:f4b9b85c7b62 121
Pokitto 31:f4b9b85c7b62 122 extern uint16_t freqs[];
Pokitto 31:f4b9b85c7b62 123 //extern uint16_t cincs[];
Pokitto 31:f4b9b85c7b62 124 extern uint32_t cincs[];
Pokitto 31:f4b9b85c7b62 125
Pokitto 31:f4b9b85c7b62 126 extern uint8_t xorshift8();
Pokitto 31:f4b9b85c7b62 127 extern uint16_t xorshift16();
Pokitto 31:f4b9b85c7b62 128
Pokitto 31:f4b9b85c7b62 129 extern uint16_t noiseval;
Pokitto 31:f4b9b85c7b62 130
Pokitto 31:f4b9b85c7b62 131 extern void setOSC(OSC*,byte, byte, byte, byte, byte,
Pokitto 31:f4b9b85c7b62 132 uint8_t, uint8_t,
Pokitto 31:f4b9b85c7b62 133 uint16_t, uint16_t, uint16_t, uint16_t,
Pokitto 31:f4b9b85c7b62 134 int16_t, int16_t, uint8_t, uint8_t, uint8_t);
Pokitto 31:f4b9b85c7b62 135
Pokitto 31:f4b9b85c7b62 136 extern void setOSC(OSC*,byte,byte,uint16_t, uint8_t, uint32_t);
Pokitto 31:f4b9b85c7b62 137
Pokitto 31:f4b9b85c7b62 138 extern void waveoff(OSC*);
Pokitto 31:f4b9b85c7b62 139 #endif // SYNTH_H
Pokitto 31:f4b9b85c7b62 140
Pokitto 31:f4b9b85c7b62 141