Play endless stream of bytes on ESP32 via I2S DMA #660
Replies: 2 comments
-
Without more details, here is how I would approach it. The PlayWaveFromFunction example might have some useful insights, but I've not used it before. Then maybe apply an AudioFileSourceBuffer if it's applicable. Alternatively, maybe an AudioOutputBuffer that you write your bytes to. |
Beta Was this translation helpful? Give feedback.
-
Thanks ChuckMash, I had seen that example and agree it seems to be the closest to what I'm trying to do. However, I believe that since it calls the given function for each and every value, it won't benefit from the speedup of using DMA (i.e. dumping a buffer of bytes into a memory location all at once). More specifically, I have my audio bytes in this array: uint8_t audioBuffer[AUDIO_BUFFER_SIZE]; And I have some code that fills that buffer asynchronously. That code detects when the buffer is full, at which point I'd like to dump those bytes into a buffer in ESP8266Audio which would play it back as a WAV via DAC (with DMA optimization). The bytes come in fast enough that the playback buffer should never run out of bytes, so it's continuous. Does that suggest any more specific routes? Thanks again. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I'm pretty sure ESP8266Audio can be used for this situation, but I can't quite find an example that ties it together, and my own experimenting didn't work out.
I have my own streaming source of bytes which I'm storing in a simple buffer (array), which represents an 8-bit WAV. How can I play back this continuous stream using the DMA approach to the ESP32's DAC? I already have it working with dacWrite() but there's a bit of stuttering, and I suspect using DMA (via I2S) will solve this.
The closest example I found was for playing an HTTP stream of MP3 bytes, which is neither the input nor file type I have.
In terms of figuring out the API, I'm not sure what input object to use such that I can periodically add bytes from my own array into the input for the playback to use.
Thanks,
Vance
Beta Was this translation helpful? Give feedback.
All reactions