Hi all,
Some of this is already a bit old but is getting a new kick now so I guess it is time to have a word about it!
Since PR#87, it is possible for most platforms (not ESP, yet, see after) to define an "external audio output function". This allows a great simplicity to output the sound using a non-standard (for Mozzi) way, for instance DACs, but also any way that you can think of (resistance ladder etc…).
Basically, if you configure mozzi correctly (there is an option in mozzi_config.h), you can declare a void audioOutput(int r, int l) function which will contains the sound sample(s) for you to take care of them. It will be called by Mozzi at the correct sample rate.
PR#90 and #103 provide examples of audioOutput functions for the following DACs:
- MCP48/9XX, which are 8/10/12 bits mono/stereo DAC, connected via SPI, one example shows a way to output 24bits audio by combining two 12bits DAC. As standard AVR platforms have 16bits integers, this is not compatible. However users with more powerful platforms (like STM32) could be interested. From my personal tests, not all the 24bits get out of the noise, but it still gives a very nice 16/18 bits actual resolution on one channel).
- PT8211 which is a stereo 16 bits DAC that is intended to be connected via I2S but can be made working using SPI interfaces.
They are available in the Examples of Mozzi.
This should ease by a lot the support of new output hardware, and if you happen to get it working on something else do not hesitate to pull request!
Additionally, a great work is being done now by tfry-git under PR#98 to simplify the internal way Mozzi is working. This is still work in progress and will be the subject of another post when it is ready but in short:
- automatic scaling of the output will be provided, this means examples won't have to be modified for platform outputting a different number of bits that the default AVR,
- external audio output will be supported for all platforms (including ESP32 which is missing now).
If you are not using the External audio output capability, these changes should not break any sketch, it will just allow to make them more portable across platforms.
Best and happy new year to all!