You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

#ifndef _MP3_H
#define _MP3_H
#include <HTTPClient.h>
#include <SD.h>
#include "AudioFileSourceICYStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string);
void StatusCallback(void *cbData, int code, const char *string);
extern char titleStr[];
class MP3 {
public:
MP3();
bool begin(void);
const char *URL="http://streaming.shoutcast.com/80sPlanet?lang=en-US";
//const char *URL="http://swr-swr1-bw.cast.addradio.de/swr/swr1/bw/mp3/64/stream.mp3";
void stop(void);
void start(void);
bool playing = false;
private:
AudioGenerator *decoder;
AudioFileSourceICYStream *file;
AudioFileSourceBuffer *buff;
AudioOutputI2S *out;
TaskHandle_t audioTaskHandle;
void mp3_decoder_task(void*);
static void cTaskWrapper(void*);
static constexpr int preallocateBufferSize = 5*1024;
static constexpr int preallocateCodecSize = 29192; // MP3 codec max mem needed
void *preallocateBuffer = NULL;
void *preallocateCodec = NULL;
int lastms = 0;
};
#endif /* _MP3_H */