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.
50 lines
1.3 KiB
50 lines
1.3 KiB
#ifndef _MP3_H
|
|
#define _MP3_H
|
|
|
|
#include <Arduino.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);
|
|
char URL[80];
|
|
void stop(void);
|
|
void start(void);
|
|
void start(const char*);
|
|
void start_Progmem();
|
|
void playRTTTL(const char *, size_t);
|
|
void setVolume(int);
|
|
int getVolume();
|
|
bool playing = false;
|
|
bool aborted = false;
|
|
int volume = 4;
|
|
bool volumeChanged = true;
|
|
uint32_t getBuffFill(void);
|
|
bool fromProgmem;
|
|
const char* rtttl PROGMEM;
|
|
size_t rtttl_len = (size_t)0;
|
|
private:
|
|
TaskHandle_t audioTaskHandle;
|
|
void mp3_decoder_task(void*);
|
|
static void cTaskWrapper(void*);
|
|
|
|
static constexpr int preallocateBufferSize = 16*1024;
|
|
static constexpr int preallocateCodecSize = 29192; // MP3 codec max mem needed
|
|
void *preallocateBuffer = NULL;
|
|
void *preallocateCodec = NULL;
|
|
|
|
AudioFileSourceBuffer *audiobuffer = nullptr;
|
|
};
|
|
|
|
#endif /* _MP3_H */
|
|
|