Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayMP3ToSPDIF logs the message "MP3 source file not open" to the Serial monitor. #632

Open
matthewdrummond opened this issue Jun 2, 2023 · 1 comment

Comments

@matthewdrummond
Copy link

Playback ends immediately, as in Serial.printf("MP3 done\n"); executes right away. Here is the code that I have

#include <Arduino.h>
#if defined(ARDUINO_ARCH_RP2040)
void setup() {}
void loop() {}
#else

#ifdef ESP32
#include <WiFi.h>
#include "SPIFFS.h"
#else
#include <ESP8266WiFi.h>
#endif
#include "AudioFileSourceSPIFFS.h"
#include "AudioFileSourceID3.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"

// To run, set your ESP8266 build to 160MHz, and include a SPIFFS of 512KB or greater.
// Use the "Tools->ESP8266/ESP32 Sketch Data Upload" menu to write the MP3 to SPIFFS
// Then upload the sketch normally.

// pno_cs from https://ccrma.stanford.edu/~jos/pasp/Sound_Examples.html

AudioGeneratorMP3 *mp3;
AudioFileSourceSPIFFS *file;
AudioOutputI2S *out;
AudioFileSourceID3 *id3;

// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc.
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string)
{
(void)cbData;
Serial.printf("ID3 callback for: %s = '", type);

if (isUnicode) {
string += 2;
}

while (*string) {
char a = *(string++);
if (isUnicode) {
string++;
}
Serial.printf("%c", a);
}
Serial.printf("'\n");
Serial.flush();
}

void setup()
{
WiFi.mode(WIFI_OFF);
Serial.begin(115200);
delay(1000);
SPIFFS.begin();
Serial.printf("Sample MP3 playback begins...\n");

audioLogger = &Serial;
file = new AudioFileSourceSPIFFS("/pno-cs.mp3");
id3 = new AudioFileSourceID3(file);
id3->RegisterMetadataCB(MDCallback, (void*)"ID3TAG");
out = new AudioOutputI2S();
mp3 = new AudioGeneratorMP3();
mp3->begin(id3, out);
}

void loop()
{
if (mp3->isRunning()) {
if (!mp3->loop()) mp3->stop();
} else {
//Serial.printf("MP3 done\n");
delay(1000);
}
}
#endif

And here is the Serial Monitors output:

Sample MP3 playback begins...
MP3 source file not open

Anyone have any experience with this example? I am stuck here. Where is the Serial.println() that logs "MP3 source file not open" coming from? Thank you for any help

@ChulseungYoo
Copy link

I am having same problem.
did you resolved the issue?

I am using nodemcu board with esp-12f from ai thinker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants