Pauses during streaming #1727
-
Hello, It's a long shot but i'm looking into debugging my issues. My main goal is to find how to debug (rather than plain answers). I started out with this: minimal sketch using MP3DecoderHelix#include <SPI.h>
#include "AudioTools.h"
#include "AudioLibs/A2DPStream.h"
#include "AudioLibs/AudioSourceSD.h"
#include "AudioCodecs/CodecMP3Helix.h"
#include "AudioCodecs/CodecWAV.h"
#define HSPI_SCLK 26
#define HSPI_MISO 33
#define HSPI_MOSI 25
#define HSPI_SS 27
const char *startFilePath = "/";
const char *ext = "mp3";
SPIClass hspi(HSPI);
AudioSourceSD source(startFilePath, ext, HSPI_SS, hspi);
A2DPStream out;
MP3DecoderHelix decoder;
AudioPlayer player(source, out, decoder);
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
hspi.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS);
// setup output
auto cfg = out.defaultConfig(TX_MODE);
cfg.name = "Bose Color II SoundLink";
cfg.auto_reconnect = false;
out.begin(cfg);
// setup player
player.begin();
out.setVolume(100);
}
void loop() {
player.copy();
} This compiles well, connects to BLE and plays the file with approx 200ms gaps of silence between each chunk of sound. I thought that maybe the issue would be with my board not powerful enough to decode the mp3 on the fly (no PSRAM) so I thought to swap to wav (the SD card being big enough, it doesn't seem like a problem to me). From the sketch below i literally only swapped minimal sketch using WAVDecoder#include <SPI.h>
#include "AudioTools.h"
#include "AudioLibs/A2DPStream.h"
#include "AudioLibs/AudioSourceSD.h"
#include "AudioCodecs/CodecMP3Helix.h"
#include "AudioCodecs/CodecWAV.h"
#define HSPI_SCLK 26
#define HSPI_MISO 33
#define HSPI_MOSI 25
#define HSPI_SS 27
const char *startFilePath = "/";
const char *ext = "wav";
SPIClass hspi(HSPI);
AudioSourceSD source(startFilePath, ext, HSPI_SS, hspi);
A2DPStream out;
WAVDecoder decoder;
AudioPlayer player(source, out, decoder);
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
hspi.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS);
// setup output
auto cfg = out.defaultConfig(TX_MODE);
cfg.name = "Bose Color II SoundLink";
cfg.auto_reconnect = false;
out.begin(cfg);
// setup player
player.begin();
out.setVolume(100);
}
void loop() {
player.copy();
} This also compiles well, connects to BLE and the logs show good amount of data being dump through the player, although no sound is being played. As mentioned in another issue, I've even tried to swap to different mp3 codecs, and also different bitrates leading to interesting results (mostly panic - 64kbps file with Helix did it too) I don't know if:
I'm sorry to ask of your time for this, but would you have any pointers to help resolve this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Usually no PSRAM should be necessary. For MP3 the sd speed is usually not any problem, but it is more likely when using uncompressed data with WAV: The output goes to the DAC pins GPIO25 (Channel 1) and GPIO26 (Channel 2). Just connect GND on one of the channels with the earphones to check if it is breaking up there as well. If this is working then the issue is most likely on the A2DP side, which is sometimes quite challaging for this scenario:
I committed today some small change to the A2DPStream that gives you access to the buffer information: e.g with out.buffer().levelPercent() you can monitor the level of the buffer e.g. in the loop. |
Beta Was this translation helpful? Give feedback.
-
I was just running a test with ESP32 3.0.5.
I did not notice any breakups. Then I realized that I was using SDFAT instead of SD! After using AudioSourceSD the sketch started to crash outside of my code... |
Beta Was this translation helpful? Give feedback.
Usually no PSRAM should be necessary.
For MP3 the sd speed is usually not any problem, but it is more likely when using uncompressed data with WAV:
Did you test if the audio is ok with anouther output: If you don't have an external I2S DAC, you can use the internal DAC of the ESP32 with the AnalogAudioStream and test it with some earphones:
The output goes to the DAC pins GPIO25 (Channel 1) and GPIO26 (Channel 2). Just connect GND on one of the channels with the earphones to check if it is breaking up there as well.
If this is working then the issue is most likely on the A2DP side, which is sometimes quite challaging for this scenario:
You can test the A2DP side with some sine tests: