arduino-audio-tools icon indicating copy to clipboard operation
arduino-audio-tools copied to clipboard

stutter on ESP Now example with audio kit

Open IsiTapier opened this issue 2 years ago • 12 comments

IsiTapier avatar Jul 24 '22 18:07 IsiTapier

I tried both esp now examples (normal and with SBC codec, but i receive a lot of stutter (probably some buffsize issues? What could possibly had gone wrong? I just edited the examples to use audio kit streams instead of i2s

IsiTapier avatar Jul 24 '22 18:07 IsiTapier

its caused by the esp now sender, but I stillt dont know why

IsiTapier avatar Jul 24 '22 20:07 IsiTapier

Is the log level in all sketches set to Warning? Maybe you can try to decrease the sample rate...

pschatzmann avatar Jul 25 '22 18:07 pschatzmann

With the sine wave example it works fine, but when I switch it to the AudioKitStream it outputs a lot of garbage

IsiTapier avatar Jul 27 '22 05:07 IsiTapier

Is this with the example with or w/o decoder ?

pschatzmann avatar Jul 27 '22 06:07 pschatzmann

I am having the same issue , needing to send audio from audio kit input via esp now but sound stuttering using the codec encoder/ decoder think the problem is on the sender side , have tried lowering the sample rate but still an issue , works fine with the example

nipper01792 avatar Sep 12 '22 23:09 nipper01792

Streaming Audio is hard: If you use a process where you sample at the sender with constant speed, it might be that the receiver is running a bit faster than the sender: The clocks between the different microcontrollers are not synchonized: That could lead to stuttering! The sine example sends as fast as possible and gets stalled by playing the audio in the receiver. If you look what the web browsers do: they buffer a lot of audio before they start to play....

pschatzmann avatar Sep 14 '22 18:09 pschatzmann

Thanks for the reply, I'm fairly new to audio tools. You have done great work with this library. It's made life a lot easier . I got it working with Bluetooth so I'll keep trying to fix the espnow issue, if anything it'll be a good learning experience. Thanks for you time .

nipper01792 avatar Sep 14 '22 22:09 nipper01792

Makes total sense what you said I'm streaming from a esp32 A1s (kit) to an esp32 with pmod I2s

nipper01792 avatar Sep 14 '22 23:09 nipper01792

Ok this is weird . So the buffer size is limited to 256 on the espnow . I thought what the hell and raised it to 1000. No more stuttering . EncodedAudioStream decoder(&kit, new SBCDecoder(1000)); did I miss something or has it changed . Or did I misunderstand the code

nipper01792 avatar Sep 16 '22 02:09 nipper01792

Check out the class documentation: you actually reduced the internal buffer from 8192 bytes to 1000. I guess you could even go further and decrease it down to the actual framesize length.

I am not sure why the proposed buffer size is so big. I guess this might be the maximum expected value. It should however not have any impact on the decoding performance since a frame is decoded whenever the framesize is reached.

I just added the actual framesize info to the info log...

pschatzmann avatar Sep 16 '22 06:09 pschatzmann

Ah I understand now . Thanks for the info. This is awesome . Your a star . Thanks so much

nipper01792 avatar Sep 16 '22 13:09 nipper01792