-
-
Notifications
You must be signed in to change notification settings - Fork 309
Audio "PUP" noises in mp3 silent sections and long loading times for large MP3 files on the ESP32 Audio Kit 2.2 #2155
-
Problem Description
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.
Device Description
ESP32 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 Reproduce
No response
What is your development environment (incl. core version info)
VisualStudio Core + PlatformIO
I have checked existing issues, discussions and online documentation
- I confirm I have checked existing issues, discussions and online documentation
Beta Was this translation helpful? Give feedback.
All reactions
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(Ser...
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!
In the start path, use a subdirectory that contains the relevant 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.
All reactions
-
@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.
All reactions
-
You would need to find the root cause of this: maybe it's artifacts from MP3 or even in the recording ?
Did you test with headphones ?
Try to visualize this in the Serial Monitor by sending the silence output to a CsvOutput...
I am pretty sure that if you just call kit.writeSilence(1024) in a loop, you won't hear anything.
If you do, maybe it is just a noisey power supply...
If it is in the PCM output, you can try to apply a MedianFilter...
Beta Was this translation helpful? Give feedback.
All reactions
-
@pschatzmann
I used an MP3 file that plays flawlessly on a "Lilypad MP3 Board". During the silent pauses, no "PUP" noises can be heard. This sound typically occurs at the beginning and end of a pause or moment of silence within the MP3.
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.
image
Using mp3DirectCut, I don’t see any unusual peaks.
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.
All reactions
-
You would really need to look at the output of the decoder to figure out if it is coming from there.
Alternatively you could try to test with a simple WAV file and if that is providing a clean result, you could look into alternative mp3 decoders...
The issue might be also your speaker: I guess the AudiKit expects 4ohm speakers. Therefore I asked if you were testing with some headphones (or earphones)...
Beta Was this translation helpful? Give feedback.
All reactions
-
@pschatzmann
I’ve now tested it with headphones as well, and the same issue occurs — I can hear these noises.
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.
All reactions
-
Could you reproduce the issue with a wav file (to exclude that the issue is with the mp3 decoder) ?
Could you reproduce the issue with the headphones (to exclude that the issue is with the amplifier) ?
I think we should try to identify the source of the issue first before jumping to conclusions. If it is really the hardware codec chip: there are plenty of settings.
ps. did you also confirm that this is not just from your log level ?
Beta Was this translation helpful? Give feedback.
All reactions
-
@pschatzmann
I listened to the MP3 file using headphones, and the issue also occurs when using headphones.
I rewrote the code to use the WAVDecoder and converted my MP3 file to WAV format.
This is the file I used: Hello_world2.wav
– 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.
/**
* @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/AudioCodecs/CodecWAV.h>
#include <AudioTools/Disk/AudioSourceSD.h>
const char *startFilePath="/test";
const char* ext="wav";
//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
WAVDecoder decoder;
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.play();
player.setPath("/test/Hello_world2.wav");
}
void loop() {
player.copy();
}
Beta Was this translation helpful? Give feedback.
All reactions
-
I assumed that you already tested with a proper log level because this is described all over the place when having quality issues.
Please confirm that AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); does not make a difference...
Beta Was this translation helpful? Give feedback.
All reactions
-
@pschatzmann
Yes, I’ve now also tested it with the following code. It actually makes NO difference at all.
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
All reactions
-
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.
All reactions
-
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.
/**
* @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 <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
#include <AudioTools/AudioCodecs/CodecWAV.h>
const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream kit(AudioKitEs8388V1); // final output of decoded stream
EncodedAudioStream decoder(&kit, new WAVDecoder()); // Decoding stream
StreamCopy copier;
File audioFile;
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Error);
// setup audiokit before SD!
auto config = kit.defaultConfig(TX_MODE);
config.sd_active = true;
kit.begin(config);
kit.setVolume(0.01);
// setup file
SD.begin(chipSelect);
audioFile = SD.open("/test/Hello_world2.wav");
// setup I2S based on sampling rate provided by decoder
decoder.begin();
// begin copy
copier.begin(decoder, audioFile);
}
void loop() {
if (!copier.copy()) {
stop();
}
}
Beta Was this translation helpful? Give feedback.