-
|
I'm trying to play two MP3 at the same time using an OutputMixer, but no matter what, my playback is too fast AND I get messages of insufficient buffer. I tried increasing the buffer in I tried running the mixer with only a single file ( I've seen some mentions of buffered stream in the discussions, but not sure how I could add it here (and if that would solve the issue). Thanks in advance for any and all help Current code and mp3 files I use below: #include <SPI.h>
#include <SD.h>
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
const int chipSelect=PIN_AUDIO_KIT_SD_CARD_CS;
AudioBoardStream i2s(AudioKitEs8388V1); // final output of decoded stream
OutputMixer<int16_t> mixer(i2s, 2);
//audio [1]
VolumeStream volume1(mixer);
EncodedAudioStream decoder1(&volume1, new MP3DecoderHelix()); // Decoding stream
StreamCopy copier1;
File audioFile1;
//audio [2]
VolumeStream volume2(mixer);
EncodedAudioStream decoder2(&volume2, new MP3DecoderHelix()); // Decoding stream
StreamCopy copier2;
File audioFile2;
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
//setup i2s / audiokit before SD!
auto config = i2s.defaultConfig(TX_MODE);
config.sd_active = true;
i2s.begin(config);
// setup SD
SD.begin(chipSelect);
//load files
audioFile1 = SD.open("/demo.mp3");
audioFile2 = SD.open("/Static_master.mp3");
// set initial volume
volume1.setVolume(0.8);
volume1.begin();
volume2.setVolume(0.5);
volume2.begin();
//setup decoders
decoder1.begin();
decoder2.begin();
//start mixer
mixer.begin(2048);
//
copier1.begin(decoder1,audioFile1);
copier2.begin(decoder2,audioFile2);
}
void loop() {
//copier loop
copier2.copy();
copier1.copy();
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
Well, I can't seem to make two mp3s to play correctly with either input or output mixers. Tried buffering, tried resampling - the output is either sped-us mess or full of gaps and only playing one mp3. I know that I'm far from a good programmer and chances are I'm messing something up in code, but at this point I think ESP32 can't really mix mp3s. I mean, at least one of the methods I tried by modifying the existing examples should have gotten me somewhere closer. |
Beta Was this translation helpful? Give feedback.
Thanks Phil. I should have expected it being much more complex than I thought after a week of not finding a single example of ESP32 mixing mp3s.
I appropriate your recommendations. However, I don't feel skilled enough to tackle something that advanced at this point. I shouldn't be trying to implement multitasking when I'm still struggling with syntax! 😆 Maybe I'll come back to it one day when I get more familiar with writing code for ESP32. For now, I will investigate some alternative approaches (mixing mp3 with wav or stick with the generated audio to tackle the radio static, but make it more interesting than just noise).
So, at this point I'm marking this as answered with the answer bei…