23 #include "mozzi_analog.h"
36 #define CONTROL_RATE 64
140 #define STANDARD_PLUS 1
144 #include "mozzi_config.h"
148 #if AUDIO_MODE == STANDARD
149 #warning "AUDIO_MODE is set to STANDARD in mozzi_config.h. If things sound wrong, check if STANDARD is the correct AUDIO_MODE for your sketch."
150 #elif AUDIO_MODE == STANDARD_PLUS
151 #warning "AUDIO_MODE is set to STANDARD_PLUS in mozzi_config.h. If things sound wrong, check if STANDARD_PLUS is the correct AUDIO_MODE for your sketch."
152 #elif AUDIO_MODE == HIFI
153 #warning "AUDIO_MODE is set to HIFI in mozzi_config.h. If things sound wrong, check if HIFI is the correct AUDIO_MODE for your sketch."
156 #if (AUDIO_MODE == STANDARD) && (AUDIO_RATE == 32768)
157 #error AUDIO_RATE 32768 does not work when AUDIO_MODE is STANDARD, try setting the AUDIO_MODE to STANDARD_PLUS in Mozzi/mozzi_config.h
161 #define CLOCK_TICKS_PER_AUDIO_TICK (F_CPU / AUDIO_RATE)
164 #if AUDIO_RATE == 16384
165 #define AUDIO_RATE_AS_LSHIFT 14
166 #define MICROS_PER_AUDIO_TICK 61 // 1000000 / 16384 = 61.035, ...* 256 = 15625
167 #elif AUDIO_RATE == 32768
168 #define AUDIO_RATE_AS_LSHIFT 15
169 #define MICROS_PER_AUDIO_TICK 31 // = 1000000 / 32768 = 30.518, ...* 256 = 7812.6
173 #if defined(__MK20DX128__) || defined(__MK20DX256__) // Teensy 3
174 #include "AudioConfigTeensy3_12bit.h"
176 #if (AUDIO_MODE == STANDARD)
177 #include "AudioConfigStandard9bitPwm.h"
178 #elif (AUDIO_MODE == STANDARD_PLUS)
179 #include "AudioConfigStandardPlus.h"
180 #elif (AUDIO_MODE == HIFI)
181 #include "AudioConfigHiSpeed14bitPwm.h"
187 typedef unsigned char uchar;
188 typedef unsigned int uint;
189 typedef unsigned long ulong;
191 #if defined(__MK20DX128__) || defined(__MK20DX256__) // teensy 3, 3.1
199 typedef unsigned char uint8_t;
200 typedef signed char int8_t;
201 typedef unsigned int uint16_t;
202 typedef signed int int16_t;
203 typedef unsigned long uint32_t;
204 typedef signed long int32_t;
316 #if (USE_AUDIO_INPUT == true)
346 #if (AUDIO_MODE == HIFI)
347 static void setupTimer2();
#define CONTROL_RATE
Control rate setting.
unsigned long mozziMicros()
A replacement for Arduino micros() which is disabled by Mozzi which takes over Timer 0 for control in...
void updateControl()
This is where you put your control code.
void audioHook()
This is required in Arduino's loop().
void unPauseMozzi()
Restores Mozzi audio and control interrupts, if they have been temporarily disabled with pauseMozzi()...
unsigned long audioTicks()
An alternative for Arduino time funcitions like micros() which are disabled by Mozzi when it takes ov...
void pauseMozzi()
Stops audio and control interrupts and restores the timers to the values they had before Mozzi was st...
int getAudioInput()
This returns audio input from the input buffer, if #define USE_AUDIO_INPUT true is in the Mozzi/mozzi...
int updateAudio()
This is where you put your audio code.
void startMozzi(int control_rate_hz=CONTROL_RATE)
Sets up the timers for audio and control rate processes, storing the timer registers so they can be r...