arduino-audio-tools
AbstractMetaData.h
1 #pragma once
2 
3 #include <stdint.h>
4 
5 namespace audio_tools {
6 
8 enum ID3TypeSelection { SELECT_ID3V1=0b001, SELECT_ID3V2=0b010, SELECT_ID3=0b011, SELECT_ICY=0b100, SELECT_ANY=0b111 };
9 
11 enum MetaDataType { Title, Artist, Album, Genre, Name, Description };
12 
13 // Description for meta info
14 static const char* MetaDataTypeStr[] = {"Title", "Artist", "Album", "Genre","Name", "Description"};
15 
17 static const char *toStr(MetaDataType t){
18  return MetaDataTypeStr[t];
19 }
20 
22 static size_t strnlength (const char* s, size_t n) {
23  size_t i;
24  for (i = 0; i < n && s[i] != '\0'; i++)
25  continue;
26  return i;
27 }
28 
29 
35  public:
36  virtual ~AbstractMetaData() = default;
37 
38  // defines the callback which provides the metadata information
39  virtual void setCallback(void (*fn)(MetaDataType info, const char* str, int len)) = 0 ;
40  // starts the processing
41  virtual void begin() = 0;
42  // ends the processing
43  virtual void end() = 0;
44  // provide audio data which contains the metadata to be extracted
45  virtual size_t write(const uint8_t *data, size_t length) = 0;
46  // select Icecast/Shoutcast Metadata
47  virtual void setIcyMetaInt(int value){}
48 
49 };
50 
51 
52 
53 }
Common Metadata methods.
Definition: AbstractMetaData.h:34
ID3TypeSelection
Enum to filter by type of metadata.
Definition: AbstractMetaData.h:8
static const char * toStr(MetaDataType t)
Converts the MetaDataType to a string.
Definition: AbstractMetaData.h:17
MetaDataType
Type of meta info.
Definition: AbstractMetaData.h:11
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AnalogAudio.h:10
static size_t strnlength(const char *s, size_t n)
unfortunatly strnlen or strnlen_s is not available in all implementations
Definition: AbstractMetaData.h:22