From 4b3ca23d6e8b39ad7b9906fd73936e64ee65341c Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sat, 20 Jan 2018 08:42:51 -0800 Subject: [PATCH] Include ID3 tag scanner in MP3 test --- tests/host/mp3.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/host/mp3.cpp b/tests/host/mp3.cpp index f022abc..3c9578f 100644 --- a/tests/host/mp3.cpp +++ b/tests/host/mp3.cpp @@ -2,21 +2,48 @@ #include "AudioFileSourceSTDIO.h" #include "AudioOutputSTDIO.h" #include "AudioGeneratorMP3.h" +#include "AudioFileSourceID3.h" + +// Called when a metadata event occurs (i.e. an ID3 tag, an ICY block, etc. +void MDCallback(void *cbData, const char *type, bool isUnicode, const char *string) +{ + (void)cbData; + Serial.printf("ID3 callback for: %s = '", type); + + if (isUnicode) { + string += 2; + } + + while (*string) { + char a = *(string++); + if (isUnicode) { + string++; + } + Serial.printf("%c", a); + } + Serial.printf("'\n"); + Serial.flush(); +} + + int main(int argc, char **argv) { (void) argc; (void) argv; AudioFileSourceSTDIO *in = new AudioFileSourceSTDIO("jamonit.mp3"); + AudioFileSourceID3 *id3 = new AudioFileSourceID3(in); + id3->RegisterMetadataCB(MDCallback, (void*)"ID3TAG"); AudioOutputSTDIO *out = new AudioOutputSTDIO(); out->SetFilename("jamonit.wav"); AudioGeneratorMP3 *mp3 = new AudioGeneratorMP3(); - mp3->begin(in, out); + mp3->begin(id3, out); while (mp3->loop()) { /*noop*/ } mp3->stop(); delete mp3; delete out; + delete id3; delete in; }