-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
nrf: Add i2s audio output #2127
Conversation
Testing performed: I used a Particle Xenon with a HDA1334 I2S DAC. I played a variety of mono 16-bit samples at 11025 and 22050Hz nominal bit rates. With this setup, all the 11025Hz samples sound good. I tested play, pause, and loop functionality. During some runs with 22050Hz samples, there were glitches. However, these may have only occurred during runs where I had set breakpoints and watchpoints in gdb. I also tested with a MAX98357A I2S amplifier. On this device, everything sounded "scratchy". I was powering it from 5V and the 5V rail seemed steady, so I don't have an explanation for this. However, I haven't tried it with a SAMD board.
I had used those MAX98357A amplifiers at work and had problems with them at the beginning, by any chance did you captured the I2S traffic with a logic analyzer? My problem was because I didn't removed the bit clock before removing the LRClock (WSCLK). |
@C47D the "scratchy" audio with MAX is while a sample is playing, so I don't think this is the cause. However, I'll attempt to capture a scope trace of the end of playing and look for problems. |
@jepler Noted, I did work with an STM32 microcontroller on that project and had to use double buffers to play the audio, didn't took a look at your implementation, maybe it's different for the Nordic device, which I'm not (yet) very familiar with the I2S and DMA peripherals. |
@jepler what's it look like with a sine wave playing? you can put an RC filter on the speaker outputs to scope it - also maybe post a pic of your setup? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall nice work! I tested it using the UDA1443 and the nrF52840 FeatherWing with the sine sample: https://learn.adafruit.com/adafruit-i2s-stereo-decoder-uda1334a/circuitpython-wiring-test
I did the same test to compare with the Feather M4 and it did way worse. I could hear the tone but it wasn't as loud or as clear as the nRF. So hopefully you don't mind working on I2S. :-)
Just a couple code comments and then it should be good to merge. Thanks!
.. based on some tasks I found that caused stuttering: # Test SD and printing while True: os.listdir('.') # Test bulk I/O while True: len(open('somefile.wav', 'rb').read()) Each of these tasks *WAS* worse and I am improving them in a separate PR by adding RUN_BACKGROUND_TASKS to them.
@tannewt I have attempted to address your review comments. Thank you! |
There was a problem hiding this 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 refactor and added comments. Please mark comments as resolved as you address them next time. Thanks!
I've been having problems with I2S on the Feather nRF52840 Express running CircuitPython 5.0.0-alpha.4-260-g2b02750f1 (2019-10-26.)
|
Testing performed: I used a Particle Xenon with a HDA1334 I2S DAC. I played a variety of mono 16-bit samples at 11025 and 22050Hz nominal bit rates. With this setup, all the 11025Hz samples sound good. I tested play, pause, and loop functionality.
During some runs with 22050Hz samples, there were glitches. However, these may have only occurred during runs where I had set breakpoints and watchpoints in gdb.
I also tested with a MAX98357A I2S amplifier. On this device, everything sounded "scratchy". I was powering it from 5V and the 5V rail seemed steady, so I don't have an explanation for this. However, I haven't tried it with a SAMD board.