Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
I keep getting a Error opening 'File1.mp3 in the Serial Monitor. I think I've gotten most of it correct, the code is debugging without issues, but I'm getting stuck on this.
I've swapped MOSI and MISO around to make sure the monitor would throw an error if the SD Reader wasn't correct (it did). So im pretty sure my wiring is good.
#include <Arduino.h>
#include "AudioFileSourceSD.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
//SD Card Pins
#define SCK 18
#define MISO 19
#define MOSI 23
#define CS 2
// Analog Audio Out = Pin 25
File dir;
AudioFileSourceSD *source = NULL;
AudioOutputI2S *output = NULL;
AudioGeneratorMP3 *decoder = NULL;
bool first = true;
void setup() {
Serial.begin(115200);
Serial.println();
delay(1000);
audioLogger = &Serial;
source = new AudioFileSourceSD();
output = new AudioOutputI2S(0, 1); //Using Internal DAC, Analog Audio on Pin 25
decoder = new AudioGeneratorMP3();
if (!SD.begin(CS)) {
Serial.println("Problem starting SD");
return;
}
Serial.println("SD initialised.");
dir = SD.open("/");
}
void loop() {
if ((decoder) && (decoder->isRunning())) {
if (!decoder->loop()) decoder->stop();
} else {
File file = dir.openNextFile();
if (file) {
if (!first) {
source->close();
if (source->open(file.name())) {
Serial.printf_P(PSTR("Playing '%s' from SD card...\n"), file.name());
decoder->begin(source, output);
} else {
Serial.printf_P(PSTR("Error opening '%s'\n"), file.name());
}
}else first = false;
} else {
Serial.println(F("Playback from SD card done\n"));
delay(1000);
}
}
}
I keep getting a
Error opening 'File1.mp3
in the Serial Monitor. I think I've gotten most of it correct, the code is debugging without issues, but I'm getting stuck on this.I've swapped MOSI and MISO around to make sure the monitor would throw an error if the SD Reader wasn't correct (it did). So im pretty sure my wiring is good.