|
|
@ -3,6 +3,7 @@ |
|
|
|
#include <HTTPClient.h> |
|
|
|
#include <SD.h> |
|
|
|
#include "AudioFileSourceICYStream.h" |
|
|
|
#include "AudioFileSourcePROGMEM.h" |
|
|
|
#include "AudioFileSourceBuffer.h" |
|
|
|
#include "AudioGeneratorMP3.h" |
|
|
|
#include "AudioOutputI2S.h" |
|
|
@ -17,6 +18,8 @@ |
|
|
|
#include "esp_system.h" |
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
#include "alarmsound.h" |
|
|
|
|
|
|
|
char titleStr[64]; |
|
|
|
|
|
|
|
// convert mp3 files with `xxd -i alarm.wav > alarmsound.h`
|
|
|
@ -54,6 +57,7 @@ void MP3::stop() { |
|
|
|
void MP3::start(const char* url) { |
|
|
|
strncpy(URL, url, sizeof(URL)); |
|
|
|
URL[sizeof(URL)-1] = '\0'; |
|
|
|
fromProgmem = false; |
|
|
|
start(); |
|
|
|
} |
|
|
|
|
|
|
@ -74,6 +78,11 @@ void MP3::start() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MP3::start_Progmem() { |
|
|
|
fromProgmem = true; |
|
|
|
start(); |
|
|
|
} |
|
|
|
|
|
|
|
void MP3::setVolume(int volume) { |
|
|
|
if (volume > 0 && volume <= 100) { |
|
|
|
this->volume = volume; |
|
|
@ -92,13 +101,14 @@ uint32_t MP3::getBuffFill() { |
|
|
|
|
|
|
|
void MP3::mp3_decoder_task(void *pvParameters) { |
|
|
|
AudioGenerator *decoder = nullptr; |
|
|
|
AudioFileSourceICYStream *file = nullptr; |
|
|
|
AudioFileSource *file = nullptr; |
|
|
|
AudioFileSourceBuffer *buff = nullptr; |
|
|
|
AudioOutputI2S *out = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
// strcpy(titleStr, "loading...");
|
|
|
|
file = new AudioFileSourceICYStream(URL); |
|
|
|
if (fromProgmem) file = new AudioFileSourcePROGMEM(alarmsound, sizeof(alarmsound)); |
|
|
|
else file = new AudioFileSourceICYStream(URL); |
|
|
|
file->RegisterMetadataCB(MDCallback, (void*)"ICY"); |
|
|
|
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize); |
|
|
|
audiobuffer = buff; |
|
|
|