port by Dieter Vandoren, Thomas Friedrichsmeier and Thomas Combriat
mozziAnalogRead()
relays to analogRead()
. MOZZI_AUDIO_INPUT is not implementedThe following audio modes (see MOZZI_AUDIO_MODE) are currently supported on this hardware:
The default mode is MOZZI_OUTPUT_INTERNAL_DAC for the ESP32 (that has a built-in DAC) and MOZZI_OUTPUT_PWM for all other ESP32 flavours.
The internal DAC has 8 bit resolution, and outputs to GPIO pins 25 and 26 (non-configurable). For simplicity of code, both pins are always used. In a mono configuration, both pins output the same sample.
TODO: We could really use this to hack in a 2 PIN mode!
Internally, the inbuilt DAC is connected via an I2S interface. Which interface number to use can be configured using:
This mode outputs to a PT8211 (or compatible) I2S DAC, which allows for very high quality (mono or stereo) output. By default this mode outputs a plain I2S signal, with BCK, WS and DATA lines defined (but configurable, see after), which is equivalent to defining:
The mode can be changed to LSBJ format (the PT8211 DAC for instance uses this format) by using:
In addition to the three pins referred above, MCLK pin, which is of use in some DAC can be defined. Presumably, any pins qualify, and you can configure this using:
For further customization, the signals outputted on some of these pins can be inverted, to accomodate DAC that would not fall into the standard, by using:
This mode uses the same setup as MOZZI_OUTPUT_I2S_DAC, but rather than using an external DAC, the communication signal itself is modulated in PDM (pulse density modulation) encoded form. Thus not extra hardware is needed, and the signal is output on the DATA pin (see above). The BCK and WS pins are also claimed, but should be left non-connected, and do not produce anything meaningful. This can only be used in mono mode.
Output resolution may be adjusted by defining MOZZI_PDM_RESOLUTION , where the default value of 4 means that each audio sample is encoded into four 32 bit blocks of ones and zeros. Obviously, more is potentially better, but at the cost of considerable computation power.
This mode outputs a standard PWM signal (10 bits) cadenced at MOZZI_AUDIO_RATE. Allegedly, any pin should qualify but by default it is set to GPIO 15 (left/mono) and GPIO 16 (right). They can be customized by using: