Audio “PUP” noises in mp3 silent sections and long loading times for large MP3 files on the ESP32 Audio Kit 2.2 #2155
-
Problem Description1. Audio glitches during speech pauses
2.Long delay when playing large MP3 files Libraries used: Sample Code: Device DescriptionESP32 Audio Kit v2.2 Sketch**1. Audio glitches during speech pauses**
The tested MP3 file contains **only spoken voice**, with **no background music**. During silent gaps between spoken segments, a noticeable "PUP" sound occurs, as if the audio chip is briefly deactivated and reactivated. I tried the following settings to mitigate this behavior, but without success:
cfg.auto_clear = false;
kit.setTimeout(0);
player.setSilenceOnInactive(true); // also tested with false
**2.Long delay when playing large MP3 files**
When **player.begin();** is enabled, it takes several seconds (sometimes up to a minute) before a large MP3 file (~100 MB) starts playing. If I comment out **player.begin()**;, playback starts immediately.
**Libraries used:**
arduino-audio-tools v1.1.3
arduino-audio-driver v0.1.4
arduino-libhelix v0.9.1
SdFat v2.3.1
**Sample Code:**
I used the official **player-sdfat-audiokit** example with minimal changes to reproduce the issue reliably.
/**
* @file player-sd-audiokit.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/player-sdfat-audiokit/README.md
* Make sure that the pins are set to off, on, on, off, off
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include <AudioTools.h>
#include <AudioTools/AudioLibs/AudioBoardStream.h>
#include <AudioTools/AudioCodecs/CodecMP3Helix.h>
#include <AudioTools/Disk/AudioSourceSD.h>
const char *startFilePath="/";
const char* ext="mp3";
//SdSpiConfig sdcfg(PIN_AUDIO_KIT_SD_CARD_CS, DEDICATED_SPI, SD_SCK_MHZ(10) , &SPI);
AudioSourceSD source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
AudioBoardStream kit(AudioKitEs8388V1);
MP3DecoderHelix decoder; // or change to MP3DecoderMAD
AudioPlayer player(source, kit, decoder);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// SD-Card
SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS); // SCK, MISO, MOSI, CS
SD.begin(PIN_AUDIO_KIT_SD_CARD_CS, SPI, 25000000); // 25 MHz instead of standard
if (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS, SPI)) {
return;
}
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.auto_clear = false;
kit.begin(cfg);
kit.setTimeout(0);
// setup player
player.setVolume(0.01);
player.setSilenceOnInactive(false);
//player.begin(); //Causes large MP3 files (approx. 100 MB) to take several seconds to start playing.
player.setPath("/play/01/11/4SchwesternUMagie.mp3");
}
void loop() {
player.copy();
} Other Steps to ReproduceNo response What is your development environment (incl. core version info)VisualStudio Core + PlatformIO I have checked existing issues, discussions and online documentation
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 3 replies
-
I think this is normal to take quite some time if you have the system search the whole file system recursively for mp3 files! Please open issues only for bugs and not for questions... ps. If you really need to search the whole file system, use the indexed implementations instead. |
Beta Was this translation helpful? Give feedback.
-
@pschatzmann Thank you for your response, but the main issue I described in the first point wasn't addressed at all. Could you also provide an answer to that, or did I perhaps explain the problem poorly? |
Beta Was this translation helpful? Give feedback.
-
@pschatzmann For testing purposes, I created a spoken text using Google Sound of Text: https://soundoftext.com/ Using mp3DirectCut, I extended the pauses in the file slightly. Now, when this file is played, the "PUP" noises appear at the start and end of each pause in the MP3. I’ve attached the MP3 file — maybe you can test it that way. The ESP32 Audio Kit is connected via USB to a PC. I also tested it with a lithium battery, and the same issue occurred. Both power sources should be clean and stable, especially the battery. At the audio output, I connected a VISATON FRS 7W (Art. No. 2017) 8-ohm speaker. I haven’t tested it with the MedianFilter yet, because the setup seems a bit tricky to me and I need to take a closer look. However, I can imagine that in general, MP3 files containing such silent gaps might lead to these kinds of issues. |
Beta Was this translation helpful? Give feedback.
-
@pschatzmann The problem only happens with spoken MP3 files that don’t have any background music and contain truly silent pauses between speech. When I play an audio drama that includes background music, these noises don’t occur. By the way, the ESP32 Audio Kit supports 4–8 ohm speakers. I have the impression that the hardware decoder might be shutting down during silent passages and reactivating once the silence ends. This switching on and off could be causing the noise. It’s actually the same sound I hear whenever any MP3 file starts playing — I get that noise then too. At the beginning of playback, I can work around it by activating the speaker amplifier slightly later. But during playback, that’s not possible. Is there a way to fill the silent passages with a very low, inaudible signal so that the hardware decoder doesn’t shut down in the first place? It would also be interesting to know whether this issue has been observed with the ESP32 Audio Kit board, or if I’m the only one experiencing it. Because if this is a general issue with this board series, I might need to consider switching to a different one. |
Beta Was this translation helpful? Give feedback.
-
@pschatzmann I rewrote the code to use the WAVDecoder and converted my MP3 file to WAV format. – The issue also occurs when playing the WAV file, even with headphones. For completeness, here is the code I used to play the WAV file.
|
Beta Was this translation helpful? Give feedback.
-
I assumed that you already tested with a proper log level because this is described all over the place when having quality issues. |
Beta Was this translation helpful? Give feedback.
-
@pschatzmann |
Beta Was this translation helpful? Give feedback.
-
Could this phenomenon be a bug? I previously developed an MP3 player based on the VS1053 chip. Since the VS1053 is a hardware decoder, I used the same MP3 files that worked well on that setup as a reference for this project. That’s how I noticed these issues — which did not occur with the VS1053. What’s your take on it? Personally, I would consider this a bug and would like to officially report it so it can be reviewed and not overlooked. I’ve already attached the MP3 and WAV files that reproduce the issue. |
Beta Was this translation helpful? Give feedback.
-
I am usually avoiding the SD library because of the poor performance. I was testing with your WAV file with SDMMC and a headphone and could not hear what you described during the repeated playback: #include <AudioTools.h>
#include <AudioTools/AudioLibs/AudioBoardStream.h>
#include <AudioTools/AudioCodecs/CodecWAV.h>
#include <AudioTools/Disk/AudioSourceSDMMC.h>
const char *startFilePath="/test4";
const char* ext="wav";
AudioSourceSDMMC source(startFilePath, ext);
AudioBoardStream kit(AudioKitEs8388V1);
//MP3DecoderHelix decoder; // or change to MP3DecoderMAD
WAVDecoder decoder;
AudioPlayer player(source, kit, decoder);
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// setup output
auto cfg = kit.defaultConfig(TX_MODE);
cfg.sd_active = false; // no need for SPI
kit.begin(cfg);
// setup player
player.begin();
}
void loop() {
if (!player.copy()){
// replay on end
player.begin();
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for testing it. I also continued reducing the code in parallel, and after that, I was no longer able to reproduce the issue. I honestly don’t understand what caused it earlier. I removed the AudioPlayer class from the code, which was using AudioSourceSD as its source. That might have been the reason — as you also suggested. Instead, I switched to using the standard SD.h, and it seems that was indeed the key. It’s a bit of a pitfall, since older code examples still rely on AudioSourceSD. Thanks again for your quick response to my issue. Attached is my current code, which no longer shows the problem. I hope it helps someone else down the line.
|
Beta Was this translation helpful? Give feedback.
I am usually avoiding the SD library because of the poor performance.
I was testing with your WAV file with SDMMC and a headphone and could not hear what you described during the repeated playback: