nRF52: Add support for sound output over I2S #2623
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for sound output over I2S.
Tested to work on a Jolt.js and a XiaoBLE, with a MAX98357 I2S amplifier (Adafruit Audio BFF, but anything that can cope with having no master clock should probably work as well).
Still very much WIP and currently hardcoded to only do 32 kHz audio, but it actually sounds quite nice :)
I'm not quite sure yet how to handle different sample rates - looks like that isn't very straightforward and will always be a little off: https://docs.nordicsemi.com/bundle/ps_nrf52840/page/i2s.html#ariaid-title6 (section "Master clock (MCK)")
Weirdly enough, the charge LED on Jolt.js blinks in sync with the beat when powering the amplifier from
Q0
.I2S on nRF52840 wants audio as S16 instead of the U16 that the
Waveform
class wants, so beware of horrible noises and potential speaker and ear damage when testing this.Slightly modified QOA module with I2S output support: https://gist.github.com/ssievert42/b71276ebb327ab4888012521a922bd63
Suggestions and feedback very much welcome :)