39 lines
892 B
Arduino
39 lines
892 B
Arduino
#include <Arduino.h>
|
|
#include <ESP8266WiFi.h>
|
|
#include "AudioFileSourceSPIFFS.h"
|
|
#include "AudioGeneratorMP3.h"
|
|
#include "AudioOutputI2SNoDAC.h"
|
|
|
|
// To run, set your ESP8266 build to 160MHz, and include a SPIFFS of 512KB or greater.
|
|
// Use the "Tools->ESP8266 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;
|
|
AudioOutputI2SNoDAC *out;
|
|
|
|
void setup()
|
|
{
|
|
WiFi.forceSleepBegin();
|
|
Serial.begin(115200);
|
|
delay(1000);
|
|
SPIFFS.begin();
|
|
file = new AudioFileSourceSPIFFS("/pno-cs.mp3");
|
|
out = new AudioOutputI2SNoDAC();
|
|
mp3 = new AudioGeneratorMP3();
|
|
mp3->begin(file, out);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
if (mp3->isRunning()) {
|
|
if (!mp3->loop()) mp3->stop();
|
|
} else {
|
|
Serial.printf("MP3 done\n");
|
|
delay(1000);
|
|
}
|
|
}
|
|
|