Reputation: 1
I have built an internet radio based on ESP32 & VS1053B MP3 decoder. The radio works OK with a number of my favorite stations but for some there is a "gap" (or stutter) during reception. The ESP32 app was coded to forward 32 bytes (recommended value) to VS1053B. I wonder if there is a way to "buffer", by using either hardware or software, more bytes to the ESP32 and/or VS1053B so it could better handle the "gap". Searches on the subject resulted in the use of circular (ring) buffer but I didn't find a reliable article on how to implement it. Any suggestions will be greatly appreciated. Thank you.
There is a Youtube video that describes exactly what I am trying to accomplish:
#206 ESP32 Circular Buffer for Internet Radio - and ESP32 WiFi Woes
https://www.youtube.com/watch?v=6BK4fzRaFGY
Youtuber Mr. Ralph S. Bacon
Upvotes: 0
Views: 878
Reputation: 4762
The term to google for is "jitter buffer". In short, you create a fixed time delay between receiving a packet with audio data, and sending that data to the decoder chip. When receiving the first audio data packet from your radio station, store it in a FIFO buffer. Keep doing so until you have e.g. 100 ms (exact amount depends on how much jitter you're expecting) worth of audio buffered. Then start feeding the earlier packets to the decoder. If there are problems getting new audio from the source, you have 100 ms of buffer to play back before running out of audio.
Upvotes: 2