ESP8266Audio
ESP8266Audio copied to clipboard
Playing Mp3 from SD_MMC is not working
I need help in an issue; I have develop the code for esp32 to play mp3 file from the sd_mmc using I2S. I believe the esp32 is reading perfectly from the card but not able to play it. The hardware i am using is ESP32, MAX98357A I2S amplifier module and SD_CARD_MMC.
Here is the code: `#define MP3_FILENAME "/video/audio.mp3"
#include <Arduino.h> #include "SD_MMC.h" #include <AudioFileSourceFS.h> #include <AudioGeneratorMP3.h> #include "AudioOutputI2SNoDAC.h"
static AudioGeneratorMP3 *mp3; static AudioOutputI2SNoDAC *out; // Use AudioOutputI2SNoDAC for MAX98357A static AudioFileSourceFS *aFile;
void setup() { Serial.begin(115200);
// Init SD card if (!SD_MMC.begin("/sdcard", true)) // 1 bit mode { Serial.println(F("ERROR: SD card mount failed!")); while (1); }
out = new AudioOutputI2SNoDAC(); // Output to MAX98357A out->SetPinout(22, 26, 25); // DOUT on pin GPIO_22, BCLK on pin GPIO_26, LRC on pin GPIO_25 out->SetGain(2); mp3 = new AudioGeneratorMP3();
// Open the MP3 file aFile = new AudioFileSourceFS(SD_MMC, MP3_FILENAME); if (!aFile) { Serial.println(F("MP3 file not found!")); while (1); }
Serial.println(F("End Setup")); }
void loop() { Serial.println(F("MP3 audio start"));
// Init audio mp3->begin(aFile, out);
// Play audio while (mp3->isRunning()) { Serial.println(F("MP3 is Running")); Serial.println(mp3->isRunning()); if (!mp3->loop()) { Serial.println(F("MP3 Stop")); mp3->stop(); } }
aFile->close(); Serial.println(F("MP3 audio end")); delay(5000); }`
From the print statement i think in starts playing and stop immediately.
Here is the log:
Any help :)