13 # error "Wrong implementation included for this platform"
19 #if MOZZI_IS(MOZZI_ANALOG_READ, MOZZI_ANALOG_READ_STANDARD)
20 #error not yet implemented
22 #define getADCReading() 0
23 #define channelNumToIndex(channel) channel
24 uint8_t adcPinToChannelNum(uint8_t pin) {
27 void adcStartConversion(uint8_t channel) {
29 void startSecondADCReadOnCurrentChannel() {
31 void setupMozziADC(int8_t speed) {
33 void setupFastAnalogRead(int8_t speed) {
39 #define LOOP_YIELD yield();
45 uint16_t output_buffer_size = 0;
47 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_PDM_VIA_SERIAL, MOZZI_OUTPUT_I2S_DAC)
49 # if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
53 inline bool canBufferAudioOutput() {
54 return (i2s_available() >= MOZZI_PDM_RESOLUTION);
57 for (uint8_t words = 0; words < MOZZI_PDM_RESOLUTION; ++words) {
58 i2s_write_sample(pdmCode32(f.l()+MOZZI_AUDIO_BIAS));
61 # elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_I2S_DAC)
65 inline bool canBufferAudioOutput() {
66 return (i2s_available() >= MOZZI_PDM_RESOLUTION);
69 i2s_write_lr(f.l(), f.r());
75 void CACHED_FUNCTION_ATTR esp8266_serial_audio_output() {
77 while ((UART_TX_FIFO_SIZE - ((U1S >> USTXC) & 0xff)) > (MOZZI_PDM_RESOLUTION * 4)) {
84 for (uint8_t i = 0; i < MOZZI_PDM_RESOLUTION*4; ++i) {
85 U1F = pdmCode8(f.l()+MOZZI_AUDIO_BIAS);
91 static void startAudio() {
92 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_EXTERNAL_TIMED)
94 timer1_attachInterrupt(defaultAudioOutput);
95 timer1_enable(TIM_DIV1, TIM_EDGE, TIM_LOOP);
97 #elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_SERIAL)
107 timer1_attachInterrupt(esp8266_serial_audio_output);
111 timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP);
115 # if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S)
121 if (output_buffer_size == 0)
129 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S, MOZZI_OUTPUT_I2S_DAC)
131 #elif MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_SERIAL, MOZZI_OUTPUT_EXTERNAL_TIMED)
137 #if MOZZI_IS(MOZZI_AUDIO_MODE, MOZZI_OUTPUT_PDM_VIA_I2S) && (MOZZI_PDM_RESOLUTION != 1)
138 # define AUDIOTICK_ADJUSTMENT ((output_buffer_size - i2s_available()) / MOZZI_PDM_RESOLUTION)
140 # define AUDIOTICK_ADJUSTMENT (output_buffer_size - i2s_available())
147 #include <esp8266_peri.h>
149 void MozziRandPrivate::autoSeed() {
153 y = y ^ RANDOM_REG32;
154 z = z ^ RANDOM_REG32;
#define MOZZI_AUDIO_MODE
Configure how Mozzi outputs generated sounds.
#define MOZZI_AUDIO_RATE
Defines the audio rate, i.e.
void stopMozzi()
Stops audio and control interrupts and restores the timers to the values they had before Mozzi was st...
This struct encapsulates one frame of mono audio output.