I have tested the current development status of the AudioTools with the example player-sdfat-i2s. I noticed that the playback speed is too high (about a factor of 1.088 (like 48000/44100) faster.
Investigations have shown that this always happens after certain MP3 files. For these, a sample rate of 48000 is displayed in the log at the beginning, which is then changed to 44100.
At the beginning of these MP3 files, a crackling sound can also be heard. (see excerpt from the Serial Monitor). The error described occurs from the first file played with the sample rate 48000 displayed for all subsequent files.
On the PC, the test files are played back normally and a sample rate of 44100 is displayed for all of them.
Repeating the test with an older software version (here the commit 7ba38f039 - MemoryStream do not limit available() in loop mode) does not cause the problem.
Device Description
Espressif ESP32 Dev Module (ESP32 WROVER B)
Sketch
based on example "player-sdfat-i2s" with MAD decoder
....
player.setAutoFade(false);
player.setSilenceOnInactive(false);
player.setMetadataCallback(printMetaData);
player.begin();
player.setAutoNext(true);
player.setIndex(0);
}
void loop() {
static unsigned long start = 0, end = 0;
if (!player.copy() ) {
if ( !end ) {
end = millis();
log_w("Dauer %s = %d s", source.toStr(), (end-start)/1000);
start = 0;
}
}
if ( !start && player.copy() ) {
start = millis();
end = 0;
}
if (Serial.available()) {
String r = Serial.readString();
r.trim();
player.next(r.toInt());
start = 0; end = 0;
}
}
Other Steps to Reproduce
SD contain 4 mp3 Files:
normal durations:
/08 - Hey, Wir Woll´n Die Eisbärn Sehn.mp3 4:17 (257s)
/02 - Because You Loved Me.mp3 4:35 (275s)
/08 - Hey, Wir Woll´n Die Eisbärn Sehn - Kopie.mp3 4:17 (257s)
/04 - So nah wie du.mp3 3:51 (231s)
--------------------------------------------------------------------------
current main branch --> faulty processing
[256662][W][main.cpp:90] loop(): Dauer /08 - Hey, Wir Woll´n Die Eisbärn Sehn.mp3 = 256 s
[509395][W][main.cpp:90] loop(): Dauer /02 - Because You Loved Me.mp3 = 252 s
[745288][W][main.cpp:90] loop(): Dauer /08 - Hey, Wir Woll´n Die Eisbärn Sehn - Kopie.mp3 = 235 s <<<
[958356][W][main.cpp:90] loop(): Dauer /04 - So nah wie du.mp3 = 212 s
---------------------------------------------------------------------------
commit 7ba38f039 MemoryStream do not limit available() in loop mode --> correct processing
[256419][W][main.cpp:90] loop(): Dauer /08 - Hey, Wir Woll´n Die Eisbärn Sehn.mp3 = 256 s
[531806][W][main.cpp:90] loop(): Dauer /02 - Because You Loved Me.mp3 = 274 s
[788501][W][main.cpp:90] loop(): Dauer /08 - Hey, Wir Woll´n Die Eisbärn Sehn - Kopie.mp3 = 256 s
[1020697][W][main.cpp:90] loop(): Dauer /04 - So nah wie du.mp3 = 231 s
I could reproduce your issue in my latest release.
I committed some corrections. You might also need to take the latest version of libhelix, if you get any compile errors
Problem Description
I have tested the current development status of the AudioTools with the example player-sdfat-i2s. I noticed that the playback speed is too high (about a factor of 1.088 (like 48000/44100) faster. Investigations have shown that this always happens after certain MP3 files. For these, a sample rate of 48000 is displayed in the log at the beginning, which is then changed to 44100. At the beginning of these MP3 files, a crackling sound can also be heard. (see excerpt from the Serial Monitor). The error described occurs from the first file played with the sample rate 48000 displayed for all subsequent files. On the PC, the test files are played back normally and a sample rate of 44100 is displayed for all of them.
Repeating the test with an older software version (here the commit 7ba38f039 - MemoryStream do not limit available() in loop mode) does not cause the problem.
Device Description
Espressif ESP32 Dev Module (ESP32 WROVER B)
Sketch
Other Steps to Reproduce
log_current_mainbranch.txt log_commit_7ba38f039.txt
What is your development environment
PlatformIO
[platformio] description = Audio Example default_envs = esp32dev
[env:esp32dev] platform = https://github.com/platformio/platform-espressif32.git board = esp32dev framework = arduino
lib_deps = ; https://github.com/pschatzmann/arduino-audio-tools.git # problem occures https://github.com/pschatzmann/arduino-audio-tools.git#7ba38f039aef0554967138a8c8c590ace8061af1 # no problem https://github.com/pschatzmann/arduino-libhelix.git https://github.com/pschatzmann/arduino-libmad.git https://github.com/greiman/SdFat.git
lib_ldf_mode = chain+
build_flags = -DCORE_DEBUG_LEVEL=5 -D CONFIG_ARDUHAL_LOG_COLORS -Wunused-variable -Wunused-but-set-variable -Wunused-function -Wno-format-extra-args -Wno-attributes '-D USE_UTF8_LONG_NAMES = 1' '-D SDFAT_FILE_TYPE = 1' '-D DESTRUCTOR_CLOSES_FILE = 1' '-D USE_MAD_DECODER = 1' '-D MAD_MAX_BUFFER_SIZE = 4048' '-D MAD_MAX_RESULT_BUFFER_SIZE = 4048' '-D MP3_MAX_OUTPUT_SIZE = (1024 20)' '-D MP3_MAX_FRAME_SIZE = (1600 4)' '-D DEFAULT_BUFFER_SIZE = 2048' -D COPY_LOG_OFF
###########################################################
PLATFORM: Espressif 32 (6.6.0+sha.c9c9bbe) > Espressif ESP32 Dev Module HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:
|-- libMAD @ 0.7.1+sha.f777bd9
|-- SdFat @ 2.2.2+sha.57900b2 |-- WiFiClientSecure @ 2.0.0 |-- WiFi @ 2.0.0 |-- SPI @ 2.0.0
I have checked existing issues, discussions and online documentation