How to properly use ICYStreamBufferedESP32? #2113
-
Hi all, I am building an internet radio with an ESP32-S3, and have run into an issue where the audio drops out for a fraction of a second. In the serial log, the dropouts manifest as:
I believe using a buffered audio stream would help resolve this issue, as I read in the following discussion post: #432 When I attempt to use this kind of stream object however, I am provided with a large number of compiler errors. I think I'm misunderstanding how to properly use this object, and could really use some guidance! Thank you for your help! Here's my current code: #include <AudioLogger.h>
#include <AudioTools.h>
#include <AudioToolsConfig.h>
#include "AudioTools/AudioCodecs/CodecMP3Helix.h" // install https://github.com/pschatzmann/arduino-libhelix
#include <AudioTools/CoreAudio/AudioHttp/URLStreamESP32.h>
#include <AudioTools/CoreAudio/AudioHttp/URLStreamBufferedT.h>
#define URL_STREAM_BUFFER_COUNT 64 //use this to combat dropouts in the stream.
const char* ssid = "myssidgoeshere";
const char* pwd = "mypasswordgoeshere";
const char* streamURL = "http://stream.live.vc.bbcmedia.co.uk/bbc_world_service";
ICYStreamBufferedESP32 url(ssid, pwd);
I2SStream i2s; // final output of decoded stream
MP3DecoderHelix codec;
EncodedAudioStream dec(&i2s, &codec); // Decoding stream
StreamCopy copier(dec, url); // copy url to decoder
// callback for meta data --Extract the metadata from the Icecast internet radio stream and print it to the serial console.
void printMetaData(MetaDataType type, const char* str, int len) {
Serial.print("==> ");
Serial.print(MetaDataTypeStr[type]);
Serial.print(": ");
Serial.println(str);
}
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
Serial.println("ESP32 has restarted!");
// setup i2s
auto config = i2s.defaultConfig(TX_MODE);
// Manually define the pins for the off-brand ESP32-S3.
config.pin_bck = 5;
config.pin_data = 14;
config.pin_ws = 6;
//config.mode = I2S_STD_FORMAT;
i2s.begin(config);
// setup I2S based on sampling rate provided by decoder
dec.begin();
// mp3 radio
url.setMetadataCallback(printMetaData);
url.begin(streamURL, "audio/mp3");
}
void loop() {
copier.copy();
} Here are the errors I'm getting:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I committed some corrections. |
Beta Was this translation helpful? Give feedback.
I committed some corrections.
If you have performance problems, try URLStream which should have a bit less overhead.
I am not sure how the ESP32 specific classes compare to the regular Arduino implementations...