Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RP2040 I2S: always copy to output buffer #5310

Merged
merged 1 commit into from
Sep 7, 2021

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Sep 7, 2021

Make RP2040 I2S work again.

  • Don't attempt to use the sample buffer as the DMA buffer if no conversion is needed. Instead, always copy the sample buffer into the output buffer.
  • Move the I2S PIO restart slightly to avoid starting before an error check.
  • Add explanatory comment about getting mono->stereo conversion for free.

The quality of the I2S audio is not great: there are buzzes and noise, which happen erratically. A power cycle or reset can improve things temporarily. However, the quality seems to be the same as in CircuitPython 6.3.0. I'll open another issue about fixing the quality in the long term.

Tested with an MP3 file, a looping RawSample sine wave, and WAV files on an Adafruit Feather RP2040. Also did partial testing on a Pi Pico: no differences were found. Also smoke-tested PWMAudioOut to make sure it still works. PWM audio works better than I2S: there are fewer noisy artifacts.

Various audio testing programs I used:
audio-test-programs.zip

@dhalbert dhalbert requested review from tannewt and kattni September 7, 2021 20:44
Copy link

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix! WAV playback and tone playback are now functional on Pico. The tone playback took some tweaking but it's consistent now. WAV playback worked immediately.

Tested on Raspberry Pi Pico RP2040 with UDA1334A.

@kattni kattni merged commit 2ea3305 into adafruit:main Sep 7, 2021
@dhalbert dhalbert deleted the rsp2040-i2s-fix branch September 7, 2021 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sinewave tone playback on RP2040 no longer working as of CP7
2 participants