Advice needed for wireless I2C streaming #786
-
Hi Phil (and everybody), I'm completely blown away by this library, both in terms on quantity an quality. Amazing job!! I'd like to use this for a project where I take analog audio, convert to I2S via a codec and then stream it via UDP on either WiFi or Ethernet but I wanted to have a quick chat with you guys on the way to do this the most efficient way so I don't waste time on something that has no chance of working properly. Obviously the people on this forum know a lot about audio, hence this message. I'm reading I2S on ESP32-S2 (i.e. the audio source) using this line:
which puts the data into the sBuffer, which is initialised as: ..and write back the I2S into the DAC (i.e. the receiver) with this: If I leave it at this, I could in principle send sBuffer to UDP and handle all data that way but it would use too much bandwidth (~1.4Mbps for 44.1kHz/16bit/stereo) so I was thinking of using an LC3 encoder/decoder and I came across this example (https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/tests/codecs/test-codec-lc3/test-codec-lc3.ino) using your library. What's the most efficient way to use the LC3 encoder and decoder with my data structure of simple int16_t arrays? Most of your examples are a lot fancier than this so I wanted to make sure I wasn't overcomplicating things. Any other pointers? I'm aiming at keeping latency around 100ms, so I would need encoders and decoders that can be fast and efficient on ESP32-S2+ Let me know what you think. Any suggestions are very welcome :) thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
I suggest to keep with the philosophy and just and just use a StreamCopy to copy an I2SStream to a standard WiFiUDP object (which is also Stream). You can also use by UDPStream class which simplifies the processing a bit. You will find examples how to use encoders and decoders and they should work with this scenario as well. However be careful, using UDP you might loose data, which leads to some hickups when you use PCM data, but which is a major disaster when you use encoded data. |
Beta Was this translation helpful? Give feedback.
-
But all the data used via streams is usually int16_t unless you you define a bits_per_sample other then 16! In the API it's just defined as byte array so that we can process any type of data! |
Beta Was this translation helpful? Give feedback.
-
In the EncodedAudioStream you need to specify the output stream! As explained above this can be a WiFiUDP or a UDPStream object. That's the reason why I told you you should use a StreamCopy which will automatically take care of this... |
Beta Was this translation helpful? Give feedback.
I suggest to keep with the philosophy and just and just use a StreamCopy to copy an I2SStream to a standard WiFiUDP object (which is also Stream). You can also use by UDPStream class which simplifies the processing a bit.
You will find examples how to use encoders and decoders and they should work with this scenario as well.
However be careful, using UDP you might loose data, which leads to some hickups when you use PCM data, but which is a major disaster when you use encoded data.