MP3 comes in chunks of encoded data started by a header sequence. Scan for it in the decoder and only pass in data that starts with this header to avoid the burst errors Avoids a avalanche of `lost synchronization` error reports when there is a file error. Also enable additional sketches on the RP2040/RP2350
33 lines
645 B
Arduino
33 lines
645 B
Arduino
#include <Arduino.h>
|
|
#include <AudioOutputI2S.h>
|
|
#include <AudioFileSourcePROGMEM.h>
|
|
#include <AudioGeneratorFLAC.h>
|
|
|
|
#include "sample.h"
|
|
|
|
AudioOutputI2S *out;
|
|
AudioFileSourcePROGMEM *file;
|
|
AudioGeneratorFLAC *flac;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.println("Starting up...\n");
|
|
|
|
audioLogger = &Serial;
|
|
file = new AudioFileSourcePROGMEM(sample_flac, sizeof(sample_flac));
|
|
out = new AudioOutputI2S();
|
|
flac = new AudioGeneratorFLAC();
|
|
flac->begin(file, out);
|
|
}
|
|
|
|
void loop() {
|
|
if (flac->isRunning()) {
|
|
if (!flac->loop()) {
|
|
flac->stop();
|
|
}
|
|
} else {
|
|
Serial.printf("FLAC done\n");
|
|
delay(1000);
|
|
}
|
|
}
|