From f9df51e94e0991647a273fd2cc0d24314512985c Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Mon, 28 Oct 2024 16:38:12 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20doxygen=20from=20@=20pschatzma?= =?UTF-8?q?nn/arduino-audio-tools@b3dec883d082cb6149c3e41ed36817658783080d?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _codec_m_p3_helix_8h_source.html | 280 ++++---- _meta_data_filter_8h_source.html | 263 ++++---- annotated.html | 1 + classaudio__tools_1_1_audio_info_source.html | 17 +- classaudio__tools_1_1_audio_info_source.png | Bin 49845 -> 50032 bytes classaudio__tools_1_1_audio_info_support.html | 17 +- classaudio__tools_1_1_audio_info_support.png | Bin 35281 -> 35554 bytes classaudio__tools_1_1_audio_output.html | 17 +- classaudio__tools_1_1_audio_output.png | Bin 10493 -> 10948 bytes ..._tools_1_1_m_p3_decoder_helix-members.html | 24 +- classaudio__tools_1_1_m_p3_decoder_helix.html | 14 - ...o__tools_1_1_meta_data_filter-members.html | 61 +- classaudio__tools_1_1_meta_data_filter.html | 191 +++++- classaudio__tools_1_1_meta_data_filter.png | Bin 0 -> 1213 bytes classaudio__tools_1_1_print.html | 17 +- classaudio__tools_1_1_print.png | Bin 13946 -> 14492 bytes classes.html | 2 +- functions_b.html | 2 +- functions_f.html | 4 +- functions_func_b.html | 2 +- functions_func_f.html | 4 +- functions_func_i.html | 3 - functions_func_m.html | 2 +- functions_func_s.html | 15 +- functions_func_w.html | 2 +- functions_i.html | 3 - functions_m.html | 2 +- functions_s.html | 35 +- functions_w.html | 2 +- group__metadata.html | 2 +- hierarchy.html | 506 +++++++------- namespaces.html | 1 + search/all_1.js | 179 +++-- search/all_10.js | 180 ++--- search/all_11.js | 18 +- search/all_12.js | 185 +++--- search/all_13.js | 629 +++++++++--------- search/all_14.js | 126 ++-- search/all_15.js | 36 +- search/all_16.js | 154 ++--- search/all_17.js | 70 +- search/all_18.js | 2 +- search/all_19.js | 4 +- search/all_1a.js | 50 +- search/all_2.js | 88 +-- search/all_3.js | 232 +++---- search/all_4.js | 116 ++-- search/all_5.js | 76 +-- search/all_6.js | 180 ++--- search/all_7.js | 136 ++-- search/all_8.js | 54 +- search/all_9.js | 213 +++--- search/all_a.js | 6 +- search/all_b.js | 8 +- search/all_c.js | 78 +-- search/all_d.js | 167 +++-- search/all_e.js | 52 +- search/all_f.js | 68 +- search/classes_0.js | 222 +++---- search/classes_1.js | 46 +- search/classes_10.js | 16 +- search/classes_11.js | 83 +-- search/classes_12.js | 136 ++-- search/classes_13.js | 58 +- search/classes_14.js | 18 +- search/classes_15.js | 122 ++-- search/classes_16.js | 26 +- search/classes_2.js | 92 +-- search/classes_3.js | 56 +- search/classes_4.js | 30 +- search/classes_5.js | 96 +-- search/classes_6.js | 52 +- search/classes_7.js | 34 +- search/classes_8.js | 62 +- search/classes_9.js | 6 +- search/classes_a.js | 2 +- search/classes_b.js | 42 +- search/classes_c.js | 73 +- search/classes_d.js | 30 +- search/classes_e.js | 32 +- search/classes_f.js | 58 +- search/enums_0.js | 6 +- search/enums_1.js | 2 +- search/enums_2.js | 2 +- search/enums_3.js | 2 +- search/enums_4.js | 2 +- search/enums_5.js | 8 +- search/enums_6.js | 8 +- search/enums_7.js | 2 +- search/enums_8.js | 2 +- search/enums_9.js | 2 +- search/files_0.js | 10 +- search/files_1.js | 18 +- search/files_2.js | 2 +- search/files_3.js | 2 +- search/functions_0.js | 2 +- search/functions_1.js | 148 ++--- search/functions_10.js | 4 +- search/functions_11.js | 90 +-- search/functions_12.js | 485 +++++++------- search/functions_13.js | 52 +- search/functions_14.js | 14 +- search/functions_15.js | 22 +- search/functions_16.js | 46 +- search/functions_17.js | 50 +- search/functions_2.js | 26 +- search/functions_3.js | 102 +-- search/functions_4.js | 64 +- search/functions_5.js | 32 +- search/functions_6.js | 66 +- search/functions_7.js | 82 +-- search/functions_8.js | 24 +- search/functions_9.js | 125 ++-- search/functions_a.js | 4 +- search/functions_b.js | 40 +- search/functions_c.js | 76 +-- search/functions_d.js | 20 +- search/functions_e.js | 40 +- search/functions_f.js | 110 +-- search/groups_0.js | 2 +- search/groups_1.js | 4 +- search/groups_2.js | 14 +- search/groups_3.js | 4 +- search/groups_4.js | 10 +- search/groups_5.js | 6 +- search/groups_6.js | 4 +- search/groups_7.js | 2 +- search/groups_8.js | 6 +- search/groups_9.js | 2 +- search/groups_a.js | 6 +- search/groups_b.js | 4 +- search/groups_c.js | 4 +- search/groups_d.js | 2 +- search/groups_e.js | 6 +- search/groups_f.js | 4 +- search/namespaces_0.js | 4 +- search/namespaces_1.js | 2 +- search/namespaces_2.js | 2 +- search/pages_0.js | 2 +- search/related_0.js | 2 +- search/typedefs_0.js | 2 +- search/typedefs_1.js | 2 +- search/typedefs_2.js | 2 +- search/typedefs_3.js | 2 +- search/variables_0.js | 6 +- search/variables_1.js | 12 +- search/variables_10.js | 10 +- search/variables_11.js | 6 +- search/variables_12.js | 2 +- search/variables_13.js | 4 +- search/variables_2.js | 14 +- search/variables_3.js | 14 +- search/variables_4.js | 4 +- search/variables_5.js | 18 +- search/variables_6.js | 26 +- search/variables_7.js | 2 +- search/variables_8.js | 18 +- search/variables_9.js | 2 +- search/variables_a.js | 4 +- search/variables_b.js | 8 +- search/variables_c.js | 12 +- search/variables_d.js | 20 +- search/variables_e.js | 12 +- search/variables_f.js | 8 +- ...1_meta_data_filter_1_1_i_d3v2-members.html | 12 +- ...tools_1_1_meta_data_filter_1_1_i_d3v2.html | 9 +- ..._1_meta_data_filter_1_1_range-members.html | 87 +++ ..._tools_1_1_meta_data_filter_1_1_range.html | 117 ++++ 168 files changed, 4324 insertions(+), 3983 deletions(-) create mode 100644 classaudio__tools_1_1_meta_data_filter.png create mode 100644 structaudio__tools_1_1_meta_data_filter_1_1_range-members.html create mode 100644 structaudio__tools_1_1_meta_data_filter_1_1_range.html diff --git a/_codec_m_p3_helix_8h_source.html b/_codec_m_p3_helix_8h_source.html index accb186074..500ad91cbf 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 
Docoding of encoded audio into PCM data.
Definition: AudioCodecsBase.h:16
virtual void addNotifyAudioChange(AudioInfoSupport &bi)
Adds target to be notified about audio changes.
Definition: AudioTypes.h:160
Supports changes to the sampling rate, bits and channels.
Definition: AudioTypes.h:137
MP3 Decoder using libhelix: https://github.com/pschatzmann/arduino-libhelix This is basically just a ...
Definition: CodecMP3Helix.h:17
-
void setMaxPCMSize(size_t len)
Define your optimized maximum pwm buffer size.
Definition: CodecMP3Helix.h:175
-
void setMaxFrameSize(size_t len)
Define your optimized maximum frame size.
Definition: CodecMP3Helix.h:165
-
bool isFilterMetaData()
Check if the metadata filter is active.
Definition: CodecMP3Helix.h:155
-
void addNotifyAudioChange(AudioInfoSupport &bi) override
Defines the callback object to which the Audio information change is provided.
Definition: CodecMP3Helix.h:127
-
~MP3DecoderHelix()
Destroy the MP3DecoderMini object.
Definition: CodecMP3Helix.h:71
-
virtual void setOutput(Print &outStream)
Defines the output Stream.
Definition: CodecMP3Helix.h:76
-
bool begin()
Starts the processing.
Definition: CodecMP3Helix.h:81
-
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
-
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
-
MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi)
Construct a new MP3DecoderMini object. The decoded output will go to the print object.
Definition: CodecMP3Helix.h:54
-
MP3DecoderHelix(Print &out_stream)
Construct a new MP3DecoderMini object.
Definition: CodecMP3Helix.h:35
-
static void infoCallback(MP3FrameInfo &i, void *ref)
notifies the subscriber about a change
Definition: CodecMP3Helix.h:134
-
void end()
Releases the reserved memory.
Definition: CodecMP3Helix.h:92
-
void setFilterMetaData(bool filter)
Activates a filter that makes sure that helix does not get any metadata segments.
Definition: CodecMP3Helix.h:150
-
AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition: CodecMP3Helix.h:101
-
size_t write(const uint8_t *data, size_t len)
Write mp3 data to decoder.
Definition: CodecMP3Helix.h:111
-
-
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
-
void begin()
(Re)starts the processing
Definition: MetaDataFilter.h:29
+
void setMaxPCMSize(size_t len)
Define your optimized maximum pwm buffer size.
Definition: CodecMP3Helix.h:161
+
void setMaxFrameSize(size_t len)
Define your optimized maximum frame size.
Definition: CodecMP3Helix.h:151
+
void addNotifyAudioChange(AudioInfoSupport &bi) override
Defines the callback object to which the Audio information change is provided.
Definition: CodecMP3Helix.h:123
+
~MP3DecoderHelix()
Destroy the MP3DecoderMini object.
Definition: CodecMP3Helix.h:68
+
virtual void setOutput(Print &outStream)
Defines the output Stream.
Definition: CodecMP3Helix.h:73
+
bool begin()
Starts the processing.
Definition: CodecMP3Helix.h:78
+
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
+
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
+
MP3DecoderHelix(Print &out_stream, AudioInfoSupport &bi)
Construct a new MP3DecoderMini object. The decoded output will go to the print object.
Definition: CodecMP3Helix.h:52
+
MP3DecoderHelix(Print &out_stream)
Construct a new MP3DecoderMini object.
Definition: CodecMP3Helix.h:34
+
static void infoCallback(MP3FrameInfo &i, void *ref)
notifies the subscriber about a change
Definition: CodecMP3Helix.h:130
+
void end()
Releases the reserved memory.
Definition: CodecMP3Helix.h:88
+
AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition: CodecMP3Helix.h:97
+
size_t write(const uint8_t *data, size_t len)
Write mp3 data to decoder.
Definition: CodecMP3Helix.h:107
Definition: NoArduino.h:58
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition: AudioConfig.h:821
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 da657f475f..005c7dacc5 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