esp32c3-lyra board: No DAC, no problem! Audio over PDM #10643
Closed
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 PR is a proof of concept, but need some discussion on how to handle this "properly".
The esp32-c3-lyra board has no DAC, but the i2s data pin is connected directly to an audio amplifier.
Using the
audiobusiolibrary, I was able to play music on this board, but it sounded terrible.Comparing the i2s implementation in CircuitPython vs the working sample in the
esp-adfdev kit, it turns out that the dev kit isn't using true i2s, but the i2s hardware has a PDM output mode. This prototype forces the i2s output pin into this PDM mode.The reason it's implemented in
audiobusio/I2SOut.cright now is because I started looking at the I2S peripheral, and this file is where the I2S peripheral code is. However, it seems to not belong here for a few reasons: a) it's not really running in I2S mode, b) it's using a single pin, so theaudiobusioAPI that uses multiple pins doesn't make sense.Against argument a) above though, there is an
audiobusio.PDMInAPI that takes one pin. It seems like the logical followup would be to have anaudiobusio.PDMOutAPI.Another alternative that comes to mind is the
audiopwmioAPI, which is a "natural" place for beginners to go, since it's used in a bunch of examples. The API would look the same, except that the name is wrong by one letter. Perhaps adding a flag or PWM vs PDM, or anaudiopwmio.PDMAudioOutAPI.