I have extended my arduino-audio-tools project to provide access to MP3 Meta Data.
ID3 is the metadata container which is most often used in conjunction with the MP3 audio file format. It allows information such as the title, artist, album, track number, and other information about the file to be stored in the file itself.
Both versions of ID3 (ID3v1 and ID3v2) are supported. I currently however only provide the information that is available in both which is:
- Artist
- Album
- Title
- Genre
The MetaDataID3 class is used as stream output destination and you register your callback method with setCallback()
:
#include "AudioTools.h"
#include "sample-12s.h"
MemoryStream mp3(sample_12s_mp3, sample_12s_mp3_len);
MetaDataOutput out;
StreamCopy copier(out, mp3); // copy in to out
// callback for meta data
void printMetaData(MetaDataType type, const char* str, int len){
Serial.print("==> ");
Serial.print(toStr(type));
Serial.print(": ");
Serial.println(str);
}
void setup(){
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
mp3.begin();
out.setCallback(printMetaData);
out.begin();
}
void loop(){
copier.copy();
}
The complete example is available on Github
0 Comments