Rp2040 port: using I2s(0) and I2S(1) in parallel #10426
-
with two seperate HW set-ups (gpio pins, max98357 DAC, speaker), would it technically possble to use the 1st available i2s for playing wav-files (read from an sdcard) whilst using the 2nd available i2s to create an occasional "sound_over" ? These would be typical say 5 sec bursts (which I would store in flash memory possibly triggering me to use a Rp2040's with 16M flash). Mike Teachman has created some very nice examples (thx a lot !), inclusive an asyncio version that might support what I am looking for. Not having any experience with asyncio, it might not enable feeding both streams without running into buffer underflows. I expect - but might miss other crucial matters - that will be the crictical part. The use case behind this is: I develop hw/sw to operate a miniature railway track and plan to dedicate a RP2040 for producing diesel / steam loc sounds, There is plenty of material on youtube so I can create a "library" of authentic sounds for the various loc's that I have and model them to the loc's operation (start/stop...). The sound_over's are the literally the "whistles and bells" that I can schedule or have called at random. Using Mike's examples I got the first stream to work; now the next step. Thx for sharing any thoughts / advice. Rob |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi Rob, To get started, here is an approach to consider, adapting the asyncio example in the repo.
This is just one approach. I would see if @peterhinch can review your use case and comment. He's the preeminent MicroPython asyncio application expert. As an aside, I've considered creating an I2S PR, to add a static Hope this helps. Please report on your progress. |
Beta Was this translation helpful? Give feedback.
-
I think this should be feasible with suitable buffering. You might like to look at this demo which is a player for audio files, notably this section which aims to reduce allocation. In this application buffering is necessary because reading from SD cards is slow. The DMA from the buffer proceeds in the backgound and enables continuous audio output. |
Beta Was this translation helpful? Give feedback.
I think this should be feasible with suitable buffering. You might like to look at this demo which is a player for audio files, notably this section which aims to reduce allocation. In this application buffering is necessary because reading from SD cards is slow. The DMA from the buffer proceeds in the backgound and enables continuous audio output.