Trouble With Sound Stuttering ON XIAO ESP32S3 from Streaming MP3 #1099
-
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
I don't know where you are located: Did you try with a local url. So my gut feeling is that you have an infrastructure problem. You can double check e.g. if you just serve an mp3 file from a local webserver where the local network traffic is under your control. ps. I assume that you were not so crasy to replace the demo url with one that uses some extreme or insane bitrates |
Beta Was this translation helpful? Give feedback.
-
Thanks. I will try doing the measurements but I was already serving an mp3
file from a local webserver. On my laptop I ran :
sudo python3 -m http.server 80 (which was connected by Ethernet to my
router)
And on the esp32 I ran the following code. (Alicia.mp3 was in the directory
where the http.server was running)
/**
* @file streams-url_mp3-i2s.ino
* @author Phil Schatzmann
* @brief decode MP3 stream from url and output it on I2S
* @Version 0.1
* @Date 2021-96-25
*
* @copyright Copyright (c) 2021
*/
// install https://github.com/pschatzmann/arduino-libhelix.git
#include "AudioTools.h"
#include "AudioCodecs/CodecMP3Helix.h"
URLStream url("SSID","password");
I2SStream i2s; // final output of decoded stream
EncodedAudioStream dec(&i2s, new MP3DecoderHelix()); // Decoding stream
StreamCopy copier(dec, url); // copy url to decoder
void setup(){
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// setup i2s
auto config = i2s.defaultConfig(TX_MODE);
// you could define e.g your pins and change other settings
//config.pin_ws = 10;
//config.pin_bck = 11;
//config.pin_data = 12;
//config.mode = I2S_STD_FORMAT;
i2s.begin(config);
// setup I2S based on sampling rate provided by decoder
dec.setNotifyAudioChange(i2s);
dec.begin();
// mp3 radio
url.begin("http://192.168.1.5/Alicia.mp3","audio/mp3");
}
void loop(){
copier.copy();
}
…On Tue, Dec 12, 2023 at 1:09 PM Phil Schatzmann ***@***.***> wrote:
I don't know where you are located: Did you try with a local url.
Your test with the mobile phone does not mean anything: on the mobile
phone megabytes are buffered before the audio starts to play.
On microconrollers it is vital that the data is provided at a constant
(fast enough speed) and any short drop will be audible.
You should also measure the network speed from the audiotools
<https://www.pschatzmann.ch/home/2023/02/28/arduino-audiotools-esp32-vs-rp2040-pico-w/>
.
So my gut feeling is that you have an infrastructure problem. You can
double check e.g. if you just serve an mp3 file from a local webserver
where the local network traffic is under your control.
—
Reply to this email directly, view it on GitHub
<#1099 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHBBBCVBR6FSZB3Y5I7DASDYJCMV3AVCNFSM6AAAAABAR2WOQSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQMZTHEYDC>
.
You are receiving this because you authored the thread.Message ID:
<pschatzmann/arduino-audio-tools/repo-discussions/1099/comments/7833901@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Just a quick note to say I also tried running the AudioLogger with "warning"
…On Tue, Dec 12, 2023 at 4:54 PM Jim Ruxton ***@***.***> wrote:
Thanks. I will try doing the measurements but I was already serving an mp3
file from a local webserver. On my laptop I ran :
> sudo python3 -m http.server 80 (which was connected by Ethernet to my
> router)
>
And on the esp32 I ran the following code. (Alicia.mp3 was in the
directory where the http.server was running)
/**
* @file streams-url_mp3-i2s.ino
* @author Phil Schatzmann
* @brief decode MP3 stream from url and output it on I2S
* @Version 0.1
* @Date 2021-96-25
*
* @copyright Copyright (c) 2021
*/
// install https://github.com/pschatzmann/arduino-libhelix.git
#include "AudioTools.h"
#include "AudioCodecs/CodecMP3Helix.h"
URLStream url("NETGEAR41","exoticunit847");
I2SStream i2s; // final output of decoded stream
EncodedAudioStream dec(&i2s, new MP3DecoderHelix()); // Decoding stream
StreamCopy copier(dec, url); // copy url to decoder
void setup(){
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// setup i2s
auto config = i2s.defaultConfig(TX_MODE);
// you could define e.g your pins and change other settings
//config.pin_ws = 10;
//config.pin_bck = 11;
//config.pin_data = 12;
//config.mode = I2S_STD_FORMAT;
i2s.begin(config);
// setup I2S based on sampling rate provided by decoder
dec.setNotifyAudioChange(i2s);
dec.begin();
// mp3 radio
url.begin("http://192.168.1.5/Alicia.mp3","audio/mp3");
}
void loop(){
copier.copy();
}
On Tue, Dec 12, 2023 at 1:09 PM Phil Schatzmann ***@***.***>
wrote:
> I don't know where you are located: Did you try with a local url.
> Your test with the mobile phone does not mean anything: on the mobile
> phone megabytes are buffered before the audio starts to play.
> On microconrollers it is vital that the data is provided at a constant
> (fast enough speed) and any short drop will be audible.
> You should also measure the network speed from the audiotools
> <https://www.pschatzmann.ch/home/2023/02/28/arduino-audiotools-esp32-vs-rp2040-pico-w/>
> .
>
> So my gut feeling is that you have an infrastructure problem. You can
> double check e.g. if you just serve an mp3 file from a local webserver
> where the local network traffic is under your control.
>
> —
> Reply to this email directly, view it on GitHub
> <#1099 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AHBBBCVBR6FSZB3Y5I7DASDYJCMV3AVCNFSM6AAAAABAR2WOQSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQMZTHEYDC>
> .
> You are receiving this because you authored the thread.Message ID:
> <pschatzmann/arduino-audio-tools/repo-discussions/1099/comments/7833901@
> github.com>
>
|
Beta Was this translation helpful? Give feedback.
-
I ran the program to measure the bitrate streams-url_mp3-measuring.ino . I got the following bitrates. It looks plenty fast to me. The test was done using the same mp3 file and network infrastructure as described above.
|
Beta Was this translation helpful? Give feedback.
-
I am not quite sure: In order to never stutter all values might need to be above 44200* 2 channels * 2 bytes (=16 bits)) = 176400 bytes / sec What is the bitrate of your mp3 ? Did you try to convert it to standard e.g. with Audacity ? |
Beta Was this translation helpful? Give feedback.
-
Thanks again Phil for your suggestions. This is what ffprobe gives me on the mp3 file
So a couple things , it is a high bitrate but I thought if it was less than the transmission rates I am getting , lowest was 150kbytes/sec or 1200kb/s . Meanwhile I will try converting the file to a lower bit rate. Also I see the format is fltp , although in between stutters when the sound plays it sounds ok so I guess the decoder can handle this format ok. When I tried to raise the i2s buffer size to 200 I got a message in the monitor saying it had to be between 128 and 2 . However anything above 50 and I get nothing in fact the espe32 keeps rebooting with buffer sizes above 64 . Below is the monitor output with a buffer size of 70. It is continuously rebooting. I realize this probably isn't audio tools related but I thought it may provide other clues.
|
Beta Was this translation helpful? Give feedback.
-
Using Audacity terms: a standard bitrate (170-210 kbps) should work w/o any changes. |
Beta Was this translation helpful? Give feedback.
-
Thanks Phil. I just tested with a 64 kbps mp3 file and it worked fine. Would you have any thoughts as to why when increasing the i2s buffer_count above 64 the program no longer works. Would it help to implement PSRAM in some way at that point? |
Beta Was this translation helpful? Give feedback.
-
My guess would be that you just run out of RAM, so PSRAM might help, but I never checked if this is working. |
Beta Was this translation helpful? Give feedback.
I don't know where you are located: Did you try with a local url.
Your test with the mobile phone does not mean anything: on the mobile phone megabytes are buffered before the audio starts to play.
On microconrollers it is vital that the data is provided at a constant (fast enough speed) and any short drop will be audible.
You should also measure the network speed with the audiotools.
So my gut feeling is that you have an infrastructure problem. You can double check e.g. if you just serve an mp3 file from a local webserver where the local network traffic is under your control.
ps. I assume that you were not so crasy to replace the demo url with one that uses some extreme or insane bitrates