diff --git a/_codec_m_p3_helix_8h_source.html b/_codec_m_p3_helix_8h_source.html index accb18607..500ad91cb 100644 --- a/_codec_m_p3_helix_8h_source.html +++ b/_codec_m_p3_helix_8h_source.html @@ -85,165 +85,145 @@
22  mp3 = new libhelix::MP3DecoderHelix();
23  if (mp3!=nullptr){
24  mp3->setReference(this);
-
25  filter.setDecoder(mp3);
-
26  } else {
-
27  LOGE("Not enough memory for libhelix");
-
28  }
-
29  }
-
35  MP3DecoderHelix(Print &out_stream){
-
36  TRACED();
-
37  mp3 = new libhelix::MP3DecoderHelix();
-
38  if (mp3!=nullptr){
-
39  mp3->setReference(this);
-
40  filter.setDecoder(mp3);
-
41  } else {
-
42  LOGE("Not enough memory for libhelix");
-
43  }
-
44  setOutput(out_stream);
-
45  }
-
46 
-
54  MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi){
-
55  TRACED();
-
56  mp3 = new libhelix::MP3DecoderHelix();
-
57  if (mp3!=nullptr){
-
58  mp3->setReference(this);
-
59  filter.setDecoder(mp3);
-
60  } else {
-
61  LOGE("Not enough memory for libhelix");
-
62  }
-
63  setOutput(out_stream);
-
64  addNotifyAudioChange(bi);
-
65  }
-
66 
-
71  ~MP3DecoderHelix(){
-
72  if (mp3!=nullptr) delete mp3;
-
73  }
-
74 
-
76  virtual void setOutput(Print &outStream){
-
77  if (mp3!=nullptr) mp3->setOutput(outStream);
-
78  }
-
79 
-
81  bool begin(){
-
82  TRACED();
-
83  if (mp3!=nullptr) {
-
84  //mp3->setDelay(CODEC_DELAY_MS);
-
85  mp3->begin();
-
86  filter.begin();
-
87  }
-
88  return true;
-
89  }
-
90 
-
92  void end(){
-
93  TRACED();
-
94  if (mp3!=nullptr) mp3->end();
+
25  } else {
+
26  LOGE("Not enough memory for libhelix");
+
27  }
+
28  }
+
34  MP3DecoderHelix(Print &out_stream){
+
35  TRACED();
+
36  mp3 = new libhelix::MP3DecoderHelix();
+
37  if (mp3!=nullptr){
+
38  mp3->setReference(this);
+
39  } else {
+
40  LOGE("Not enough memory for libhelix");
+
41  }
+
42  setOutput(out_stream);
+
43  }
+
44 
+
52  MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi){
+
53  TRACED();
+
54  mp3 = new libhelix::MP3DecoderHelix();
+
55  if (mp3!=nullptr){
+
56  mp3->setReference(this);
+
57  } else {
+
58  LOGE("Not enough memory for libhelix");
+
59  }
+
60  setOutput(out_stream);
+
61  addNotifyAudioChange(bi);
+
62  }
+
63 
+
68  ~MP3DecoderHelix(){
+
69  if (mp3!=nullptr) delete mp3;
+
70  }
+
71 
+
73  virtual void setOutput(Print &outStream){
+
74  if (mp3!=nullptr) mp3->setOutput(outStream);
+
75  }
+
76 
+
78  bool begin(){
+
79  TRACED();
+
80  if (mp3!=nullptr) {
+
81  //mp3->setDelay(CODEC_DELAY_MS);
+
82  mp3->begin();
+
83  }
+
84  return true;
+
85  }
+
86 
+
88  void end(){
+
89  TRACED();
+
90  if (mp3!=nullptr) mp3->end();
+
91  }
+
92 
+
93  MP3FrameInfo audioInfoEx(){
+
94  return mp3->audioInfo();
95  }
96 
-
97  MP3FrameInfo audioInfoEx(){
-
98  return mp3->audioInfo();
-
99  }
-
100 
-
101  AudioInfo audioInfo() override {
-
102  MP3FrameInfo i = audioInfoEx();
-
103  AudioInfo baseInfo;
-
104  baseInfo.channels = i.nChans;
-
105  baseInfo.sample_rate = i.samprate;
-
106  baseInfo.bits_per_sample = i.bitsPerSample;
-
107  return baseInfo;
-
108  }
-
109 
-
111  size_t write(const uint8_t* data, size_t len) {
-
112  LOGD("%s: %zu", LOG_METHOD, len);
-
113  if (mp3==nullptr) return 0;
-
114  return use_filter ? filter.write((uint8_t*)data, len): mp3->write((uint8_t*)data, len);
-
115  }
-
116 
-
118  operator bool(){
-
119  return mp3!=nullptr && (bool) *mp3;
+
97  AudioInfo audioInfo() override {
+
98  MP3FrameInfo i = audioInfoEx();
+
99  AudioInfo baseInfo;
+
100  baseInfo.channels = i.nChans;
+
101  baseInfo.sample_rate = i.samprate;
+
102  baseInfo.bits_per_sample = i.bitsPerSample;
+
103  return baseInfo;
+
104  }
+
105 
+
107  size_t write(const uint8_t* data, size_t len) {
+
108  LOGD("%s: %zu", LOG_METHOD, len);
+
109  if (mp3==nullptr) return 0;
+
110  return mp3->write((uint8_t*)data, len);
+
111  }
+
112 
+
114  operator bool(){
+
115  return mp3!=nullptr && (bool) *mp3;
+
116  }
+
117 
+
118  libhelix::MP3DecoderHelix *driver() {
+
119  return mp3;
120  }
121 
-
122  libhelix::MP3DecoderHelix *driver() {
-
123  return mp3;
-
124  }
-
125 
-
127  void addNotifyAudioChange(AudioInfoSupport &bi) override {
-
128  TRACED();
-
129  AudioDecoder::addNotifyAudioChange(bi);
-
130  if (mp3!=nullptr) mp3->setInfoCallback(infoCallback, this);
-
131  }
-
132 
-
134  static void infoCallback(MP3FrameInfo &i, void * ref){
-
135  MP3DecoderHelix* p_helix = (MP3DecoderHelix* )ref;
-
136  if (p_helix!=nullptr){
-
137  TRACED();
-
138  AudioInfo baseInfo;
-
139  baseInfo.channels = i.nChans;
-
140  baseInfo.sample_rate = i.samprate;
-
141  baseInfo.bits_per_sample = i.bitsPerSample;
-
142  baseInfo.logInfo("MP3DecoderHelix");
-
143  p_helix->notifyAudioChange(baseInfo);
-
144  } else {
-
145  LOGE("Wrong Libhelix Version");
-
146  }
-
147  }
-
148 
-
150  void setFilterMetaData(bool filter){
-
151  use_filter = filter;
-
152  }
-
153 
-
155  bool isFilterMetaData() {
-
156  return use_filter;
-
157  }
-
158 
-
160  size_t maxFrameSize() {
-
161  return mp3->maxFrameSize();
-
162  }
-
163 
-
165  void setMaxFrameSize(size_t len){
-
166  mp3->setMaxFrameSize(len);
-
167  }
+
123  void addNotifyAudioChange(AudioInfoSupport &bi) override {
+
124  TRACED();
+
125  AudioDecoder::addNotifyAudioChange(bi);
+
126  if (mp3!=nullptr) mp3->setInfoCallback(infoCallback, this);
+
127  }
+
128 
+
130  static void infoCallback(MP3FrameInfo &i, void * ref){
+
131  MP3DecoderHelix* p_helix = (MP3DecoderHelix* )ref;
+
132  if (p_helix!=nullptr){
+
133  TRACED();
+
134  AudioInfo baseInfo;
+
135  baseInfo.channels = i.nChans;
+
136  baseInfo.sample_rate = i.samprate;
+
137  baseInfo.bits_per_sample = i.bitsPerSample;
+
138  baseInfo.logInfo("MP3DecoderHelix");
+
139  p_helix->notifyAudioChange(baseInfo);
+
140  } else {
+
141  LOGE("Wrong Libhelix Version");
+
142  }
+
143  }
+
144 
+
146  size_t maxFrameSize() {
+
147  return mp3->maxFrameSize();
+
148  }
+
149 
+
151  void setMaxFrameSize(size_t len){
+
152  mp3->setMaxFrameSize(len);
+
153  }
+
154 
+
156  size_t maxPCMSize() {
+
157  return mp3->maxPCMSize();
+
158  }
+
159 
+
161  void setMaxPCMSize(size_t len) {
+
162  mp3->setMaxPCMSize(len);
+
163  }
+
164  protected:
+
165  libhelix::MP3DecoderHelix *mp3=nullptr;
+
166 
+
167 };
168 
-
170  size_t maxPCMSize() {
-
171  return mp3->maxPCMSize();
-
172  }
-
173 
-
175  void setMaxPCMSize(size_t len) {
-
176  mp3->setMaxPCMSize(len);
-
177  }
-
178  protected:
-
179  libhelix::MP3DecoderHelix *mp3=nullptr;
-
180  MetaDataFilter<libhelix::MP3DecoderHelix> filter;
-
181  bool use_filter = false;
-
182 
-
183 };
-
184 
-
185 
-
186 } // namespace
-
187 
-
188 
+
169 
+
170 } // namespace
+
171 
+
172 
audio_tools::AudioDecoder
Docoding of encoded audio into PCM data.
Definition: AudioCodecsBase.h:16
audio_tools::AudioInfoSource::addNotifyAudioChange
virtual void addNotifyAudioChange(AudioInfoSupport &bi)
Adds target to be notified about audio changes.
Definition: AudioTypes.h:160
audio_tools::AudioInfoSupport
Supports changes to the sampling rate, bits and channels.
Definition: AudioTypes.h:137
audio_tools::MP3DecoderHelix
MP3 Decoder using libhelix: https://github.com/pschatzmann/arduino-libhelix This is basically just a ...
Definition: CodecMP3Helix.h:17
-
audio_tools::MP3DecoderHelix::setMaxPCMSize
void setMaxPCMSize(size_t len)
Define your optimized maximum pwm buffer size.
Definition: CodecMP3Helix.h:175
-
audio_tools::MP3DecoderHelix::setMaxFrameSize
void setMaxFrameSize(size_t len)
Define your optimized maximum frame size.
Definition: CodecMP3Helix.h:165
-
audio_tools::MP3DecoderHelix::isFilterMetaData
bool isFilterMetaData()
Check if the metadata filter is active.
Definition: CodecMP3Helix.h:155
-
audio_tools::MP3DecoderHelix::addNotifyAudioChange
void addNotifyAudioChange(AudioInfoSupport &bi) override
Defines the callback object to which the Audio information change is provided.
Definition: CodecMP3Helix.h:127
-
audio_tools::MP3DecoderHelix::~MP3DecoderHelix
~MP3DecoderHelix()
Destroy the MP3DecoderMini object.
Definition: CodecMP3Helix.h:71
-
audio_tools::MP3DecoderHelix::setOutput
virtual void setOutput(Print &outStream)
Defines the output Stream.
Definition: CodecMP3Helix.h:76
-
audio_tools::MP3DecoderHelix::begin
bool begin()
Starts the processing.
Definition: CodecMP3Helix.h:81
-
audio_tools::MP3DecoderHelix::maxFrameSize
size_t maxFrameSize()
Provides the maximum frame size - this is allocated on the heap and you can reduce the heap size my m...
Definition: CodecMP3Helix.h:160
-
audio_tools::MP3DecoderHelix::maxPCMSize
size_t maxPCMSize()
Provides the maximum pwm buffer size - this is allocated on the heap and you can reduce the heap size...
Definition: CodecMP3Helix.h:170
-
audio_tools::MP3DecoderHelix::MP3DecoderHelix
MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi)
Construct a new MP3DecoderMini object. The decoded output will go to the print object.
Definition: CodecMP3Helix.h:54
-
audio_tools::MP3DecoderHelix::MP3DecoderHelix
MP3DecoderHelix(Print &out_stream)
Construct a new MP3DecoderMini object.
Definition: CodecMP3Helix.h:35
-
audio_tools::MP3DecoderHelix::infoCallback
static void infoCallback(MP3FrameInfo &i, void *ref)
notifies the subscriber about a change
Definition: CodecMP3Helix.h:134
-
audio_tools::MP3DecoderHelix::end
void end()
Releases the reserved memory.
Definition: CodecMP3Helix.h:92
-
audio_tools::MP3DecoderHelix::setFilterMetaData
void setFilterMetaData(bool filter)
Activates a filter that makes sure that helix does not get any metadata segments.
Definition: CodecMP3Helix.h:150
-
audio_tools::MP3DecoderHelix::audioInfo
AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition: CodecMP3Helix.h:101
-
audio_tools::MP3DecoderHelix::write
size_t write(const uint8_t *data, size_t len)
Write mp3 data to decoder.
Definition: CodecMP3Helix.h:111
-
audio_tools::MetaDataFilter< libhelix::MP3DecoderHelix >
-
audio_tools::MetaDataFilter::write
size_t write(uint8_t *data, size_t len)
Writes the data to the decoder.
Definition: MetaDataFilter.h:35
-
audio_tools::MetaDataFilter::setDecoder
void setDecoder(Decoder *decoder)
Defines the decoder to which we write the data.
Definition: MetaDataFilter.h:24
-
audio_tools::MetaDataFilter::begin
void begin()
(Re)starts the processing
Definition: MetaDataFilter.h:29
+
audio_tools::MP3DecoderHelix::setMaxPCMSize
void setMaxPCMSize(size_t len)
Define your optimized maximum pwm buffer size.
Definition: CodecMP3Helix.h:161
+
audio_tools::MP3DecoderHelix::setMaxFrameSize
void setMaxFrameSize(size_t len)
Define your optimized maximum frame size.
Definition: CodecMP3Helix.h:151
+
audio_tools::MP3DecoderHelix::addNotifyAudioChange
void addNotifyAudioChange(AudioInfoSupport &bi) override
Defines the callback object to which the Audio information change is provided.
Definition: CodecMP3Helix.h:123
+
audio_tools::MP3DecoderHelix::~MP3DecoderHelix
~MP3DecoderHelix()
Destroy the MP3DecoderMini object.
Definition: CodecMP3Helix.h:68
+
audio_tools::MP3DecoderHelix::setOutput
virtual void setOutput(Print &outStream)
Defines the output Stream.
Definition: CodecMP3Helix.h:73
+
audio_tools::MP3DecoderHelix::begin
bool begin()
Starts the processing.
Definition: CodecMP3Helix.h:78
+
audio_tools::MP3DecoderHelix::maxFrameSize
size_t maxFrameSize()
Provides the maximum frame size - this is allocated on the heap and you can reduce the heap size my m...
Definition: CodecMP3Helix.h:146
+
audio_tools::MP3DecoderHelix::maxPCMSize
size_t maxPCMSize()
Provides the maximum pwm buffer size - this is allocated on the heap and you can reduce the heap size...
Definition: CodecMP3Helix.h:156
+
audio_tools::MP3DecoderHelix::MP3DecoderHelix
MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi)
Construct a new MP3DecoderMini object. The decoded output will go to the print object.
Definition: CodecMP3Helix.h:52
+
audio_tools::MP3DecoderHelix::MP3DecoderHelix
MP3DecoderHelix(Print &out_stream)
Construct a new MP3DecoderMini object.
Definition: CodecMP3Helix.h:34
+
audio_tools::MP3DecoderHelix::infoCallback
static void infoCallback(MP3FrameInfo &i, void *ref)
notifies the subscriber about a change
Definition: CodecMP3Helix.h:130
+
audio_tools::MP3DecoderHelix::end
void end()
Releases the reserved memory.
Definition: CodecMP3Helix.h:88
+
audio_tools::MP3DecoderHelix::audioInfo
AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition: CodecMP3Helix.h:97
+
audio_tools::MP3DecoderHelix::write
size_t write(const uint8_t *data, size_t len)
Write mp3 data to decoder.
Definition: CodecMP3Helix.h:107
audio_tools::Print
Definition: NoArduino.h:58
audio_tools
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:821
audio_tools::AudioInfo
Basic Audio information which drives e.g. I2S.
Definition: AudioTypes.h:50
diff --git a/_meta_data_filter_8h_source.html b/_meta_data_filter_8h_source.html index da657f475..005c7dacc 100644 --- a/_meta_data_filter_8h_source.html +++ b/_meta_data_filter_8h_source.html @@ -71,128 +71,159 @@
1 #pragma once
2 #include "AudioLogger.h"
-
3 
-
4 namespace audio_tools {
+
3 #include "AudioTools/CoreAudio/AudioOutput.h"
+
4 #include "AudioTools/CoreAudio/Buffers.h"
5 
-
12 template <class Decoder>
- -
14  public:
-
16  MetaDataFilter() = default;
-
17 
-
19  MetaDataFilter(Decoder *decoder){
-
20  setDecoder(decoder);
-
21  }
+
6 namespace audio_tools {
+
7 
+
15 class MetaDataFilter : public AudioOutput {
+
16  public:
+
18  MetaDataFilter() = default;
+
19 
+
21  MetaDataFilter(Print &out) { setOutput(out); }
22 
-
24  void setDecoder(Decoder *decoder){
-
25  p_decoder = decoder;
-
26  }
-
27 
-
29  void begin() {
-
30  TRACED();
-
31  start = 0;
-
32  }
-
33 
-
35  size_t write(uint8_t* data, size_t len){
-
36  TRACED();
-
37  if (p_decoder==nullptr) return 0;
-
38  int pos=0; int meta_len=0;
-
39  if (findTag(data, len, pos, meta_len)){
-
40  LOGD("pos: %d len: %d",pos, meta_len);
-
41  if (start<pos){
-
42  p_decoder->write(data+start,pos);
-
43  }
-
44 
-
45  int start_idx2 = pos+meta_len;
-
46  int len2 = len-start_idx2;
-
47  if (start_idx2<len){
-
48  // we still have some audio to write
-
49  p_decoder->write(data+start_idx2,len2);
-
50  } else {
-
51  // ignore audio of next write
-
52  start = meta_len - len2;
-
53  }
-
54  } else {
-
55  // ignore start number of characters
-
56  if (start>=len){
-
57  start -= len;
-
58  } else {
-
59  p_decoder->write(data+start,len-start);
-
60  start = 0;
-
61  }
-
62  }
-
63  return len;
-
64  }
+
24  void setOutput(Print &out) { p_out = &out; }
+
25 
+
27  bool begin() override {
+
28  TRACED();
+
29  start = 0;
+
30  return true;
+
31  }
+
32 
+
34  size_t write(const uint8_t *data, size_t len) override {
+
35  TRACEI();
+
36  size_t result = len;
+
37  // prevent npe
+
38  if ((p_out == nullptr) || (data == nullptr) || (len == 0)) return 0;
+
39 
+
40  // find tag
+
41  int meta_len = 0;
+
42  if (findTag(data, len, metadata_range.from, meta_len)) {
+
43  current_pos = 0;
+
44  metadata_range.setLen(meta_len);
+
45  LOGI("ignoring metadata at pos: %d len: %d", metadata_range.from,
+
46  meta_len);
+
47  }
+
48 
+
49  // nothing to ignore
+
50  if (!metadata_range.isDefined()) {
+
51  return p_out->write(data, len);
+
52  }
+
53 
+
54  // ignore data in metadata range
+
55  SingleBuffer<uint8_t> tmp(len);
+
56  for (int j = 0; j < len; j++) {
+
57  if (!metadata_range.inRange(current_pos)) {
+
58  tmp.write(data[j]);
+
59  }
+
60  current_pos++;
+
61  }
+
62 
+
63  // write partial data
+
64  if (tmp.available() > 0) p_out->write(tmp.data(), tmp.available());
65 
-
66  protected:
-
67  Decoder *p_decoder=nullptr;
-
68  enum MetaType {TAG, TAG_PLUS, ID3};
-
69  int start = 0;
-
71  struct ID3v2 {
-
72  uint8_t header[3]; // ID3
-
73  uint8_t version[2];
-
74  uint8_t flags;
-
75  uint8_t size[4];
-
76  } tagv2;
-
77 
-
79  bool findTag(uint8_t* data, size_t len, int &pos_tag, int &meta_len){
-
80  MetaType tag_type;
-
81  if (find((const char*)data, len, pos_tag, tag_type)){
-
82  switch(tag_type){
-
83  case TAG:
-
84  LOGD("TAG");
-
85  meta_len = 128;
-
86  break;
-
87  case TAG_PLUS:
-
88  LOGD("TAG+");
-
89  meta_len = 227;
-
90  break;
-
91  case ID3:
-
92  LOGD("ID3");
-
93  memcpy(&tagv2, data+pos_tag, sizeof(ID3v2));
-
94  meta_len = calcSizeID3v2(tagv2.size);
-
95  break;
-
96 
-
97  }
-
98  return true;
-
99  }
-
100  return false;
-
101  }
+
66  // reset for next run
+
67  if (current_pos > metadata_range.to) {
+
68  current_pos = 0;
+
69  metadata_range.clear();
+
70  }
+
71 
+
72  return result;
+
73  }
+
74 
+
75  protected:
+
76  Print *p_out = nullptr;
+
77  int current_pos = 0;
+
78  enum MetaType { TAG, TAG_PLUS, ID3 };
+
79  int start = 0;
+
81  struct Range {
+
82  int from = -1;
+
83  int to = -1;
+
84 
+
85  bool inRange(int pos) { return pos >= from && pos < to; }
+
86  void setLen(int len) { to = from + len; }
+
87 
+
88  void clear() {
+
89  from = -1;
+
90  to = -1;
+
91  }
+
92  bool isDefined() { return from != -1; }
+
93  } metadata_range;
+
94 
+
96  struct ID3v2 {
+
97  uint8_t header[3]; // ID3
+
98  uint8_t version[2];
+
99  uint8_t flags;
+
100  uint8_t size[4];
+
101  } tagv2;
102 
-
103  // calculate the synch save size for ID3v2
-
104  uint32_t calcSizeID3v2(uint8_t chars[4]) {
-
105  uint32_t byte0 = chars[0];
-
106  uint32_t byte1 = chars[1];
-
107  uint32_t byte2 = chars[2];
-
108  uint32_t byte3 = chars[3];
-
109  return byte0 << 21 | byte1 << 14 | byte2 << 7 | byte3;
-
110  }
-
111 
-
113  bool find(const char*str, size_t len, int &pos, MetaType &type){
-
114  if (str==nullptr || len<=0) return false;
-
115  for (size_t j=0;j<=len-3;j++){
-
116  if (str[j]=='T' && str[j+1]=='A' && str[j+2]=='G'){
-
117  type = str[j+3]=='+' ? TAG_PLUS : TAG;
-
118  return true;
-
119  } else if (str[j]=='I' && str[j+1]=='D' && str[j+2]=='3'){
-
120  type = ID3;
-
121  return true;
-
122  }
-
123  }
-
124  return false;
-
125  }
-
126 };
-
127 
-
128 }
-
Class which filters out ID3v1 and ID3v2 Metadata and provides only the audio data to the decoder.
Definition: MetaDataFilter.h:13
-
bool find(const char *str, size_t len, int &pos, MetaType &type)
find the tag position in the string;
Definition: MetaDataFilter.h:113
-
size_t write(uint8_t *data, size_t len)
Writes the data to the decoder.
Definition: MetaDataFilter.h:35
-
void setDecoder(Decoder *decoder)
Defines the decoder to which we write the data.
Definition: MetaDataFilter.h:24
-
bool findTag(uint8_t *data, size_t len, int &pos_tag, int &meta_len)
determines if the data conatins a ID3v1 or ID3v2 tag
Definition: MetaDataFilter.h:79
-
void begin()
(Re)starts the processing
Definition: MetaDataFilter.h:29
+
104  bool findTag(const uint8_t *data, size_t len, int &pos_tag, int &meta_len) {
+
105  MetaType tag_type;
+
106  if (find((const char *)data, len, pos_tag, tag_type)) {
+
107  switch (tag_type) {
+
108  case TAG:
+
109  LOGD("TAG");
+
110  meta_len = 128;
+
111  break;
+
112  case TAG_PLUS:
+
113  LOGD("TAG+");
+
114  meta_len = 227;
+
115  break;
+
116  case ID3:
+
117  LOGD("ID3");
+
118  memcpy(&tagv2, data + pos_tag, sizeof(ID3v2));
+
119  meta_len = calcSizeID3v2(tagv2.size);
+
120  break;
+
121  }
+
122  return true;
+
123  }
+
124  return false;
+
125  }
+
126 
+
127  // calculate the synch save size for ID3v2
+
128  uint32_t calcSizeID3v2(uint8_t chars[4]) {
+
129  uint32_t byte0 = chars[0];
+
130  uint32_t byte1 = chars[1];
+
131  uint32_t byte2 = chars[2];
+
132  uint32_t byte3 = chars[3];
+
133  return byte0 << 21 | byte1 << 14 | byte2 << 7 | byte3;
+
134  }
+
135 
+
137  bool find(const char *str, size_t len, int &pos, MetaType &type) {
+
138  if (str == nullptr || len <= 0) return false;
+
139  for (size_t j = 0; j <= len - 3; j++) {
+
140  if (str[j] == 'T' && str[j + 1] == 'A' && str[j + 2] == 'G') {
+
141  type = str[j + 3] == '+' ? TAG_PLUS : TAG;
+
142  pos = j;
+
143  return true;
+
144  } else if (str[j] == 'I' && str[j + 1] == 'D' && str[j + 2] == '3') {
+
145  type = ID3;
+
146  pos = j;
+
147  return true;
+
148  }
+
149  }
+
150  return false;
+
151  }
+
152 };
+
153 
+
154 } // namespace audio_tools
+
Abstract Audio Ouptut class.
Definition: AudioOutput.h:22
+
Class which filters out ID3v1 and ID3v2 Metadata and provides only the audio data to the decoder.
Definition: MetaDataFilter.h:15
+
MetaDataFilter(Print &out)
Constructor which assigns the decoder.
Definition: MetaDataFilter.h:21
+
bool find(const char *str, size_t len, int &pos, MetaType &type)
find the tag position in the string;
Definition: MetaDataFilter.h:137
+
size_t write(const uint8_t *data, size_t len) override
Writes the data to the decoder.
Definition: MetaDataFilter.h:34
MetaDataFilter()=default
Default Constructor.
-
MetaDataFilter(Decoder *decoder)
Constructor which assigns the decoder.
Definition: MetaDataFilter.h:19
+
bool begin() override
(Re)starts the processing
Definition: MetaDataFilter.h:27
+
bool findTag(const uint8_t *data, size_t len, int &pos_tag, int &meta_len)
determines if the data conatins a ID3v1 or ID3v2 tag
Definition: MetaDataFilter.h:104
+
void setOutput(Print &out)
Defines the decoder to which we write the data.
Definition: MetaDataFilter.h:24
+
Definition: NoArduino.h:58
+ +
T * data()
Provides address of actual data.
Definition: Buffers.h:252
+
bool write(T sample) override
write add an entry to the buffer
Definition: Buffers.h:194
+
int available() override
provides the number of entries that are available to read
Definition: Buffers.h:219
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:821
-
ID3 verion 2 TAG Header (10 bytes)
Definition: MetaDataFilter.h:71
+
ID3 verion 2 TAG Header (10 bytes)
Definition: MetaDataFilter.h:96
+
Metadata range.
Definition: MetaDataFilter.h:81