38 #ifndef POKITTOSOUND_H 39 #define POKITTOSOUND_H 42 #include "Pokitto_settings.h" 43 #include "GBcompatibility.h" 47 extern void pokPauseStream();
48 extern void pokPlayStream();
49 extern uint8_t pokStreamPaused();
52 #define GLOBVOL_SHIFT 5 //shift global volume to allow for finer increments 54 #define VOLUME_SPEAKER_MAX 255 //((8<<GLOBVOL_SHIFT)-1) 55 #define VOLUME_HEADPHONE_MAX (1<<GLOBVOL_SHIFT) 56 #define VOLUME_STARTUP ((1<<GLOBVOL_SHIFT)/2) 58 #define VOLUME_SPEAKER_MAX ((8<<GLOBVOL_SHIFT)-1) 59 #define VOLUME_HEADPHONE_MAX VOLUME_SPEAKER_MAX 60 #define VOLUME_STARTUP VOLUME_SPEAKER_MAX 72 #define CMD_INSTRUMENT 1 74 #define CMD_ARPEGGIO 3 77 #define STR_PLAYING 0x1 78 #define STR_VISUALIZER 0x2 80 #define STR_PAUSED 0x8 92 extern void audio_IRQ();
96 static uint16_t volumeMax;
101 static void setMaxVol(int16_t);
102 static uint16_t getMaxVol();
103 static void volumeUp();
104 static void volumeDown();
107 static void updateStream();
108 static void playTone(uint8_t os,
int frq, uint8_t amp, uint8_t wav,uint8_t arpmode);
109 static void playTone(uint8_t os, uint16_t freq, uint8_t volume, uint32_t duration);
110 static uint8_t ampIsOn();
111 static void ampEnable(uint8_t);
112 static int playMusicStream(
char* filename, uint8_t options);
113 static int playMusicStream(
char* filename);
114 static int playMusicStream();
115 static void pauseMusicStream();
118 static void playTrack(
const uint16_t* track, uint8_t channel);
119 static void updateTrack(uint8_t channel);
120 static void updateTrack();
121 static void stopTrack(uint8_t channel);
122 static void stopTrack();
123 static void changePatternSet(
const uint16_t*
const* patterns, uint8_t channel);
124 static bool trackIsPlaying[NUM_CHANNELS];
126 static void playPattern(
const uint16_t* pattern, uint8_t channel);
127 static void changeInstrumentSet(
const uint16_t*
const* instruments, uint8_t channel);
128 static void updatePattern(uint8_t i);
129 static void updatePattern();
130 static void setPatternLooping(
bool loop, uint8_t channel);
131 static void stopPattern(uint8_t channel);
132 static void stopPattern();
133 static bool patternIsPlaying[NUM_CHANNELS];
135 static void command(uint8_t cmd, uint8_t X, int8_t Y, uint8_t i);
136 static void playNote(uint8_t pitch, uint8_t duration, uint8_t channel);
137 static void updateNote();
138 static void updateNote(uint8_t i);
139 static void stopNote(uint8_t channel);
140 static void stopNote();
142 static uint8_t outputPitch[NUM_CHANNELS];
143 static int8_t outputVolume[NUM_CHANNELS];
145 static void setMasterVolume(uint8_t);
146 static uint8_t GetMasterVolume();
147 static void setVolume(int16_t volume);
148 static uint16_t getVolume();
149 static void setVolume(int8_t volume, uint8_t channel);
150 static uint8_t getVolume(uint8_t channel);
152 static void playOK();
153 static void playCancel();
154 static void playTick();
156 static uint8_t prescaler;
158 static void setChannelHalfPeriod(uint8_t channel, uint8_t halfPeriod);
160 static void generateOutput();
164 #if (NUM_CHANNELS > 0) 166 static uint16_t *trackData[NUM_CHANNELS];
167 static uint8_t trackCursor[NUM_CHANNELS];
168 static uint16_t **patternSet[NUM_CHANNELS];
169 static int8_t patternPitch[NUM_CHANNELS];
172 static uint16_t *patternData[NUM_CHANNELS];
173 static uint16_t **instrumentSet[NUM_CHANNELS];
174 static bool patternLooping[NUM_CHANNELS];
175 static uint16_t patternCursor[NUM_CHANNELS];
178 static uint8_t notePitch[NUM_CHANNELS];
179 static uint8_t noteDuration[NUM_CHANNELS];
180 static int8_t noteVolume[NUM_CHANNELS];
181 static bool notePlaying[NUM_CHANNELS];
184 static int8_t commandsCounter[NUM_CHANNELS];
185 static int8_t volumeSlideStepDuration[NUM_CHANNELS];
186 static int8_t volumeSlideStepSize[NUM_CHANNELS];
187 static uint8_t arpeggioStepDuration[NUM_CHANNELS];
188 static int8_t arpeggioStepSize[NUM_CHANNELS];
189 static uint8_t tremoloStepDuration[NUM_CHANNELS];
190 static int8_t tremoloStepSize[NUM_CHANNELS];
194 static uint16_t *instrumentData[NUM_CHANNELS];
195 static uint8_t instrumentLength[NUM_CHANNELS];
196 static uint8_t instrumentLooping[NUM_CHANNELS];
197 static uint16_t instrumentCursor[NUM_CHANNELS];
198 static uint8_t instrumentNextChange[NUM_CHANNELS];
201 static int8_t stepVolume[NUM_CHANNELS];
202 static uint8_t stepPitch[NUM_CHANNELS];
204 static uint8_t chanVolumes[NUM_CHANNELS];
206 static void updateOutput();
211 #endif // POKITTOSOUND_H
Definition: PokittoBacklight.h:42
Definition: PokittoSound.h:94
static uint16_t globalVolume
\ DO NOT USE
Definition: PokittoSound.h:161