port by Dieter Vandoren and Thomas Friedrichsmeier
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 .
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. Communication needs the BCK, WS, and DATA(out) pins of one I2S interface. Presumably, any pins qualify, and you can configure this using:
See the note above (esp_internal_dac) regarding pin numbering. Also, please always test the default pinout, should a custom setting fail!
As a technical note, I2S support in the ESP32 SDK has been reworked since this was implemented in Mozzi, and Mozzi uses the "legacy" implementation "i2s.h". This should not be an issue, unless you want to connect additional I2S components, yourself. In which case contributions are certainly welcome!
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.