13 #if !(IS_TEENSY3() || IS_TEENSY4()) 14 # error "Wrong implementation included for this platform" 18 #include "IntervalTimer.h" 24 "Mozzi has been tested with a cpu clock speed of 16MHz on Arduino and 48MHz on Teensy 3! Results may vary with other speeds." 28 #define MOZZI_FAST_ANALOG_IMPLEMENTED 32 #define getADCReading() adc->readSingle(teensy_adc) 33 #define channelNumToIndex(channel) teensyPinMap(channel) 34 uint8_t adcPinToChannelNum(uint8_t pin) {
39 adc->adc0->setAveraging(0);
40 adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
42 adc->adc1->setAveraging(0);
43 adc->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
52 void setupMozziADC(int8_t speed) {
54 adc->adc0->enableInterrupts(adc0_isr);
56 adc->adc1->enableInterrupts(adc0_isr);
60 void adcStartConversion(uint8_t channel) {
63 if (adc->adc0->checkPin(teensy_pin)) teensy_adc = 0;
66 adc->startSingleRead(teensy_pin,teensy_adc);
69 static void startSecondADCReadOnCurrentChannel() {
70 adc->startSingleRead(teensy_pin,teensy_adc);
82 #include "AudioConfigTeensy3_12bit.h" 84 #include "AudioConfigTeensy4.h" 86 inline void audioOutput(
const AudioOutput f) {
87 analogWrite(AUDIO_CHANNEL_1_PIN, f.l()+AUDIO_BIAS);
89 analogWrite(AUDIO_CHANNEL_2_PIN, f.r()+AUDIO_BIAS);
94 static void startAudio() {
96 analogWriteResolution(12);
98 analogWriteResolution(10);
99 # if (!EXTERNAL_AUDIO_OUTPUT) 100 analogWriteFrequency(AUDIO_CHANNEL_1_PIN, 146484.38f);
101 # if (AUDIO_CHANNELS > 1
) 102 analogWriteFrequency(AUDIO_CHANNEL_2_PIN, 146484.38f);
106 timer1.begin(defaultAudioOutput, 1000000. /
AUDIO_RATE);
void stopMozzi()
Stops audio and control interrupts and restores the timers to the values they had before Mozzi was st...
#define AUDIO_CHANNELS
This sets allows to change from a single/mono audio output channel to stereo output.
#define AUDIO_RATE
Holds the audio rate setting.
void setupFastAnalogRead(int8_t speed)
NOTE: Code needed to set up faster than usual analog reads, e.g.
#define EXTERNAL_AUDIO_OUTPUT
Defining this option as true in mozzi_config.h allows to completely customize the audio output...