arduino-audio-tools
Loading...
Searching...
No Matches
AudioPlayer.h
1#pragma once
2
3#include "AudioTools/AudioCodecs/AudioCodecs.h"
4#include "AudioTools/CoreAudio/AudioBasic/Debouncer.h"
5#include "AudioTools/CoreAudio/AudioLogger.h"
6#include "AudioTools/CoreAudio/AudioMetaData/MetaData.h"
7#include "AudioTools/CoreAudio/AudioStreams.h"
8#include "AudioTools/CoreAudio/AudioTypes.h"
9#include "AudioTools/CoreAudio/BaseConverter.h"
10#include "AudioTools/CoreAudio/Buffers.h"
11#include "AudioTools/CoreAudio/Fade.h"
12#include "AudioTools/CoreAudio/StreamCopy.h"
13#include "AudioTools/CoreAudio/VolumeStream.h"
14#include "AudioTools/Disk/AudioSource.h"
15#include "AudioToolsConfig.h"
16
23namespace audio_tools {
24
52 public:
54 AudioPlayer() { TRACED(); }
55
65 AudioPlayer(AudioSource& source, AudioOutput& output, AudioDecoder& decoder) {
66 TRACED();
67 this->p_source = &source;
68 this->p_decoder = &decoder;
69 setOutput(output);
70 // notification for audio configuration
71 decoder.addNotifyAudioChange(*this);
72 }
73
84 AudioPlayer(AudioSource& source, Print& output, AudioDecoder& decoder,
85 AudioInfoSupport* notify = nullptr) {
86 TRACED();
87 this->p_source = &source;
88 this->p_decoder = &decoder;
89 setOutput(output);
91 }
92
102 AudioPlayer(AudioSource& source, AudioStream& output, AudioDecoder& decoder) {
103 TRACED();
104 this->p_source = &source;
105 this->p_decoder = &decoder;
106 setOutput(output);
107 // notification for audio configuration
108 decoder.addNotifyAudioChange(*this);
109 }
110
112 AudioPlayer(AudioPlayer const&) = delete;
113
116
118 void setOutput(AudioOutput& output) {
119 if (p_decoder->isResultPCM()) {
120 this->fade.setOutput(output);
121 this->volume_out.setOutput(fade);
122 out_decoding.setOutput(&volume_out);
123 out_decoding.setDecoder(p_decoder);
124 } else {
125 out_decoding.setOutput(&output);
126 out_decoding.setDecoder(p_decoder);
127 }
128 this->p_final_print = &output;
129 this->p_final_stream = nullptr;
130 }
131
133 void setOutput(Print& output) {
134 if (p_decoder->isResultPCM()) {
135 this->fade.setOutput(output);
136 this->volume_out.setOutput(fade);
137 out_decoding.setOutput(&volume_out);
138 out_decoding.setDecoder(p_decoder);
139 } else {
140 out_decoding.setOutput(&output);
141 out_decoding.setDecoder(p_decoder);
142 }
143 this->p_final_print = nullptr;
144 this->p_final_stream = nullptr;
145 }
146
148 void setOutput(AudioStream& output) {
149 if (p_decoder->isResultPCM()) {
150 this->fade.setOutput(output);
151 this->volume_out.setOutput(fade);
152 out_decoding.setOutput(&volume_out);
153 out_decoding.setDecoder(p_decoder);
154 } else {
155 out_decoding.setOutput(&output);
156 out_decoding.setDecoder(p_decoder);
157 }
158 this->p_final_print = nullptr;
159 this->p_final_stream = &output;
160 }
161
163 void setBufferSize(int size) { copier.resize(size); }
164
166 bool begin(int index = 0, bool isActive = true) {
167 TRACED();
168 bool result = false;
169 // initilaize volume
170 if (current_volume == -1.0f) {
171 setVolume(1.0f);
172 } else {
173 setVolume(current_volume);
174 }
175
176 // take definition from source
177 autonext = p_source->isAutoNext();
178
179 // initial audio info for fade from output when not defined yet
180 setupFade();
181
182 // start dependent objects
183 out_decoding.begin();
184
185 if (!p_source->begin()) {
186 LOGE("Could not start audio source");
187 return false;
188 }
189 if (!meta_out.begin()) {
190 LOGE("Could not start metadata output");
191 return false;
192 }
193 if (!volume_out.begin()) {
194 LOGE("Could not start volume control");
195 return false;
196 }
197
198 if (index >= 0) {
199 setStream(p_source->selectStream(index));
200 if (p_input_stream != nullptr) {
201 if (meta_active) {
203 }
204 copier.begin(out_decoding, *p_input_stream);
205 timeout = millis() + p_source->timeoutAutoNext();
206 active = isActive;
207 result = true;
208 } else {
209 LOGW("-> begin: no data found");
210 active = false;
211 result = false;
212 }
213 } else {
214 LOGW("-> begin: no stream selected");
215 active = isActive;
216 result = false;
217 }
218 return result;
219 }
220
222 void end() {
223 TRACED();
224 active = false;
225 eof_called = false;
226 out_decoding.end();
227 meta_out.end();
228 // remove any data in the decoder
229 if (p_decoder != nullptr) {
230 LOGI("reset codec");
231 p_decoder->end();
232 p_decoder->begin();
233 }
234 }
235
237 AudioSource& audioSource() { return *p_source; }
238
240 void setAudioSource(AudioSource& source) { this->p_source = &source; }
241
243 void setDecoder(AudioDecoder& decoder) {
244 this->p_decoder = &decoder;
245 out_decoding.setDecoder(p_decoder);
246 }
247
250 this->p_final_notify = notify;
251 // notification for audio configuration
252 if (p_decoder != nullptr) {
253 p_decoder->addNotifyAudioChange(*this);
254 }
255 }
256
258 void setAudioInfo(AudioInfo info) override {
259 TRACED();
260 LOGI("sample_rate: %d", (int)info.sample_rate);
261 LOGI("bits_per_sample: %d", (int)info.bits_per_sample);
262 LOGI("channels: %d", (int)info.channels);
263 this->info = info;
264 // notifiy volume
265 volume_out.setAudioInfo(info);
266 fade.setAudioInfo(info);
267 // notifiy final ouput: e.g. i2s
268 if (p_final_print != nullptr) p_final_print->setAudioInfo(info);
269 if (p_final_stream != nullptr) p_final_stream->setAudioInfo(info);
270 if (p_final_notify != nullptr) p_final_notify->setAudioInfo(info);
271 };
272
274 AudioInfo audioInfo() override { return info; }
275
278 void play() {
279 TRACED();
280 setActive(true);
281 }
282
286 bool playPath(const char* path) {
287 TRACED();
288 if (!setPath(path)) {
289 LOGW("Could not open file: %s", path);
290 return false;
291 }
292
293 LOGI("Playing %s", path);
294 // start if inactive
295 play();
296 // process all data
297 copyAll();
298
299 LOGI("%s has finished playing", path);
300 return true;
301 }
302
304 bool playFile(const char* path) { return playPath(path); }
305
307 void stop() {
308 TRACED();
309 setActive(false);
310 }
311
313 bool next(int offset = 1) {
314 TRACED();
315 writeEnd();
316 stream_increment = offset >= 0 ? 1 : -1;
317 active = setStream(p_source->nextStream(offset));
318 return active;
319 }
320
322 bool setIndex(int idx) {
323 TRACED();
324 writeEnd();
325 stream_increment = 1;
326 active = setStream(p_source->selectStream(idx));
327 return active;
328 }
329
331 bool setPath(const char* path) {
332 TRACED();
333 writeEnd();
334 stream_increment = 1;
335 active = setStream(p_source->selectStream(path));
336 return active;
337 }
338
340 bool previous(int offset = 1) {
341 TRACED();
342 writeEnd();
343 stream_increment = -1;
344 active = setStream(p_source->previousStream(abs(offset)));
345 return active;
346 }
347
349 bool setStream(Stream* input) {
350 end();
351 out_decoding.begin();
352 p_input_stream = input;
353 eof_called = false; // reset EOF state for new stream
354 if (p_input_stream != nullptr) {
355 LOGD("open selected stream");
356 meta_out.begin();
357 copier.begin(out_decoding, *p_input_stream);
358 }
359 // execute callback if defined
360 if (on_stream_change_callback != nullptr)
361 on_stream_change_callback(p_input_stream, p_reference);
362 return p_input_stream != nullptr;
363 }
364
366 Stream* getStream() { return p_input_stream; }
367
369 bool isActive() { return active; }
370
372 operator bool() { return isActive(); }
373
375 void setActive(bool isActive) {
376 if (is_auto_fade) {
377 if (isActive) {
378 fade.setFadeInActive(true);
379 } else {
380 fade.setFadeOutActive(true);
381 copier.copy();
382 writeSilence(2048);
383 }
384 }
385 active = isActive;
386 }
387
389 bool setVolume(float volume) override {
390 bool result = true;
391 if (volume >= 0.0f && volume <= 1.0f) {
392 if (abs(volume - current_volume) > 0.01f) {
393 LOGI("setVolume(%f)", volume);
394 volume_out.setVolume(volume);
395 current_volume = volume;
396 }
397 } else {
398 LOGE("setVolume value '%f' out of range (0.0 -1.0)", volume);
399 result = false;
400 }
401 return result;
402 }
403
405 float volume() override { return current_volume; }
406
408 void setAutoNext(bool next) { autonext = next; }
409
411 void setDelayIfOutputFull(int delayMs) { delay_if_full = delayMs; }
412
415 size_t copy() { return copy(copier.bufferSize()); }
416
418 size_t copyAll() {
419 size_t result = 0;
420 size_t step = copy();
421 while (step > 0) {
422 result += step;
423 step = copy();
424 }
425 return result;
426 }
427
429 size_t copy(size_t bytes) {
430 size_t result = 0;
431 if (active) {
432 if (delay_if_full != 0 && ((p_final_print != nullptr &&
433 p_final_print->availableForWrite() == 0) ||
434 (p_final_stream != nullptr &&
435 p_final_stream->availableForWrite() == 0))) {
436 // not ready to do anything - so we wait a bit
437 delay(delay_if_full);
438 LOGD("copy: %d -> 0", (int)bytes);
439 return 0;
440 }
441
442 // handle sound
443 result = copier.copyBytes(bytes);
444 if (result > 0 || timeout == 0) {
445 // reset timeout if we had any data
446 timeout = millis() + p_source->timeoutAutoNext();
447 }
448
449 // move to next stream after timeout
450 moveToNextFileOnTimeout();
451
452 // return silence when there was no data
453 if (result < bytes && silence_on_inactive) {
454 writeSilence(bytes - result);
455 }
456
457 } else {
458 // e.g. A2DP should still receive data to keep the connection open
459 if (silence_on_inactive) {
460 writeSilence(bytes);
461 }
462 }
463 LOGD("copy: %d -> %d", (int)bytes, (int)result);
464 return result;
465 }
466
468 void setVolumeControl(VolumeControl& vc) { volume_out.setVolumeControl(vc); }
469
472 StreamCopy& getStreamCopy() { return copier; }
473
475 void setSilenceOnInactive(bool active) { silence_on_inactive = active; }
476
478 bool isSilenceOnInactive() { return silence_on_inactive; }
479
481 void writeSilence(size_t bytes) {
482 TRACEI();
483 if (p_final_print != nullptr) {
484 p_final_print->writeSilence(bytes);
485 } else if (p_final_stream != nullptr) {
486 p_final_stream->writeSilence(bytes);
487 }
488 }
489
491 VolumeStream& getVolumeStream() { return volume_out; }
492
494 void setAutoFade(bool active) { is_auto_fade = active; }
495
497 bool isAutoFade() { return is_auto_fade; }
498
500 void setMetaDataSize(int size) { meta_out.resize(size); }
501
503 void setReference(void* ref) { p_reference = ref; }
504
506 void setMetadataCallback(void (*callback)(MetaDataType type, const char* str,
507 int len),
508 ID3TypeSelection sel = SELECT_ID3) {
509 TRACEI();
510 // setup metadata.
511 if (p_source->setMetadataCallback(callback)) {
512 // metadata is handled by source
513 LOGI("Using ICY Metadata");
514 meta_active = false;
515 } else {
516 // metadata is handled here
517 meta_out.setCallback(callback);
518 meta_out.setFilter(sel);
519 meta_active = true;
520 }
521 }
522
524 void setOnStreamChangeCallback(void (*callback)(Stream* stream_ptr,
525 void* reference)) {
526 on_stream_change_callback = callback;
527 if (p_input_stream != nullptr) callback(p_input_stream, p_reference);
528 }
529
533 void setOnEOFCallback(void (*callback)(AudioPlayer& player)) {
534 on_eof_callback = callback;
535 }
536
538 bool setMuted(bool muted) {
539 if (muted) {
540 if (current_volume > 0.0f) {
541 muted_volume = current_volume;
542 setVolume(0.0f);
543 }
544 } else {
545 if (muted_volume > 0.0f) {
546 setVolume(muted_volume);
547 muted_volume = 0.0f;
548 }
549 }
550 return true;
551 }
552
554 bool isMuted() { return current_volume == 0.0f; }
555
556 protected:
557 bool active = false;
558 bool autonext = true;
559 bool silence_on_inactive = false;
560 AudioSource* p_source = nullptr;
561 VolumeStream volume_out; // Volume control
562 FadeStream fade; // Phase in / Phase Out to avoid popping noise
563 MetaDataID3 meta_out; // Metadata parser
564 EncodedAudioOutput out_decoding; // Decoding stream
565 CopyDecoder no_decoder{true};
566 AudioDecoder* p_decoder = &no_decoder;
567 Stream* p_input_stream = nullptr;
568 AudioOutput* p_final_print = nullptr;
569 AudioStream* p_final_stream = nullptr;
570 AudioInfoSupport* p_final_notify = nullptr;
571 StreamCopy copier; // copies sound into i2s
572 AudioInfo info;
573 bool meta_active = false;
574 uint32_t timeout = 0;
575 int stream_increment = 1; // +1 moves forward; -1 moves backward
576 float current_volume = -1.0f; // illegal value which will trigger an update
577 float muted_volume = 0.0f;
578 int delay_if_full = 100;
579 bool is_auto_fade = true;
580 void* p_reference = nullptr;
581 void (*on_stream_change_callback)(Stream* stream_ptr,
582 void* reference) = nullptr;
583 // EOF callback and guard (invoked once when current stream reaches end)
584 void (*on_eof_callback)(AudioPlayer& player) = nullptr;
585 bool eof_called = false;
586
587 void setupFade() {
588 if (p_final_print != nullptr) {
589 fade.setAudioInfo(p_final_print->audioInfo());
590 } else if (p_final_stream != nullptr) {
591 fade.setAudioInfo(p_final_stream->audioInfo());
592 }
593 }
594
595 void moveToNextFileOnTimeout() {
596 if (p_final_stream != nullptr && p_final_stream->availableForWrite() == 0)
597 return;
598 if (p_input_stream == nullptr || millis() > timeout) {
599 if (is_auto_fade) fade.setFadeInActive(true);
600
601 // EOF callback: trigger once per stream
602 if (!eof_called) {
603 eof_called = true;
604 if (on_eof_callback != nullptr) {
605 on_eof_callback(*this);
606 }
607 }
608
609 if (autonext) {
610 LOGI("-> timeout - moving by %d", stream_increment);
611 // open next stream
612 if (!next(stream_increment)) {
613 LOGD("stream is null");
614 }
615 } else {
616 active = false;
617 }
618 timeout = millis() + p_source->timeoutAutoNext();
619 }
620 }
621
622 void writeEnd() {
623 // end silently
624 TRACEI();
625 if (is_auto_fade) {
626 fade.setFadeOutActive(true);
627 copier.copy();
628 // start by fading in
629 fade.setFadeInActive(true);
630 }
631 // restart the decoder to make sure it does not contain any audio when we
632 // continue
633 p_decoder->begin();
634 eof_called = false; // prepare for next stream
635 }
636
638 static void decodeMetaData(void* obj, void* data, size_t len) {
639 LOGD("%s, %zu", LOG_METHOD, len);
640 AudioPlayer* p = (AudioPlayer*)obj;
641 if (p->meta_active) {
642 p->meta_out.write((const uint8_t*)data, len);
643 }
644 }
645};
646
647} // namespace audio_tools
Decoding of encoded audio into PCM data.
Definition AudioCodecsBase.h:18
virtual bool isResultPCM()
Returns true to indicate that the decoding result is PCM data.
Definition AudioCodecsBase.h:53
virtual void addNotifyAudioChange(AudioInfoSupport &bi)
Adds target to be notified about audio changes.
Definition AudioTypes.h:153
Supports changes to the sampling rate, bits and channels.
Definition AudioTypes.h:135
virtual void setAudioInfo(AudioInfo info)=0
Defines the input AudioInfo.
Abstract Audio Ouptut class.
Definition AudioOutput.h:25
virtual void setAudioInfo(AudioInfo newInfo) override
Defines the input AudioInfo.
Definition AudioOutput.h:49
virtual void writeSilence(size_t len)
Definition AudioOutput.h:66
High-level audio playback pipeline and controller.
Definition AudioPlayer.h:51
static void decodeMetaData(void *obj, void *data, size_t len)
Callback implementation which writes to metadata.
Definition AudioPlayer.h:638
void setOutput(Print &output)
Sets the final output to a Print (adds Volume/Fade for PCM)
Definition AudioPlayer.h:133
void setAudioSource(AudioSource &source)
Sets or replaces the AudioSource.
Definition AudioPlayer.h:240
void writeSilence(size_t bytes)
Writes the requested number of zero bytes to the output.
Definition AudioPlayer.h:481
AudioPlayer(AudioSource &source, AudioStream &output, AudioDecoder &decoder)
Construct a new Audio Player object. The processing chain is AudioSource -> Stream-copy -> EncodedAud...
Definition AudioPlayer.h:102
AudioSource & audioSource()
Returns the active AudioSource.
Definition AudioPlayer.h:237
size_t copy(size_t bytes)
Copies the requested bytes from source to decoder (call in loop)
Definition AudioPlayer.h:429
size_t copyAll()
Copies until source is exhausted (blocking)
Definition AudioPlayer.h:418
void setSilenceOnInactive(bool active)
When enabled, writes zeros while inactive to keep sinks alive.
Definition AudioPlayer.h:475
bool isMuted()
Returns true if the player is currently muted.
Definition AudioPlayer.h:554
void setOnEOFCallback(void(*callback)(AudioPlayer &player))
Definition AudioPlayer.h:533
bool isSilenceOnInactive()
Returns whether silence-on-inactive is enabled.
Definition AudioPlayer.h:478
void setOnStreamChangeCallback(void(*callback)(Stream *stream_ptr, void *reference))
Defines a callback that is called when the stream is changed.
Definition AudioPlayer.h:524
void setDelayIfOutputFull(int delayMs)
Sets delay (ms) to wait when output is full.
Definition AudioPlayer.h:411
void setMetaDataSize(int size)
Sets the maximum ID3 metadata buffer size (default 256)
Definition AudioPlayer.h:500
bool setStream(Stream *input)
Activates the provided Stream as current input.
Definition AudioPlayer.h:349
void setDecoder(AudioDecoder &decoder)
Sets or replaces the AudioDecoder.
Definition AudioPlayer.h:243
StreamCopy & getStreamCopy()
Definition AudioPlayer.h:472
bool isAutoFade()
Checks whether automatic fade in/out is enabled.
Definition AudioPlayer.h:497
bool playFile(const char *path)
Obsolete: use PlayPath!
Definition AudioPlayer.h:304
bool setVolume(float volume) override
Sets volume in range [0.0, 1.0]; updates VolumeStream.
Definition AudioPlayer.h:389
Stream * getStream()
Returns the currently active input Stream (e.g., file)
Definition AudioPlayer.h:366
void play()
Definition AudioPlayer.h:278
bool next(int offset=1)
Moves to the next/previous stream by offset (negative supported)
Definition AudioPlayer.h:313
float volume() override
Returns the current volume [0.0, 1.0].
Definition AudioPlayer.h:405
bool playPath(const char *path)
Definition AudioPlayer.h:286
void addNotifyAudioChange(AudioInfoSupport *notify)
Adds/updates a listener notified on audio info changes.
Definition AudioPlayer.h:249
void stop()
Halts playback; equivalent to setActive(false)
Definition AudioPlayer.h:307
void setAutoNext(bool next)
Enables/disables auto-advance at end/timeout (overrides AudioSource)
Definition AudioPlayer.h:408
void setReference(void *ref)
Sets a user reference passed to the stream-change callback.
Definition AudioPlayer.h:503
AudioPlayer()
Default constructor.
Definition AudioPlayer.h:54
void setAutoFade(bool active)
Enables/disables automatic fade in/out to prevent pops.
Definition AudioPlayer.h:494
void setMetadataCallback(void(*callback)(MetaDataType type, const char *str, int len), ID3TypeSelection sel=SELECT_ID3)
Defines the metadata callback.
Definition AudioPlayer.h:506
void setOutput(AudioOutput &output)
Sets the final output to an AudioOutput (adds Volume/Fade for PCM)
Definition AudioPlayer.h:118
bool isActive()
Checks whether playback is active.
Definition AudioPlayer.h:369
bool previous(int offset=1)
Moves back by offset streams (defaults to 1)
Definition AudioPlayer.h:340
void end()
Ends playback and resets decoder/intermediate stages.
Definition AudioPlayer.h:222
VolumeStream & getVolumeStream()
Returns the VolumeStream used by the player.
Definition AudioPlayer.h:491
bool setPath(const char *path)
Selects stream by path without changing the source iterator.
Definition AudioPlayer.h:331
bool begin(int index=0, bool isActive=true)
Starts or restarts playback from the first or given stream index.
Definition AudioPlayer.h:166
void setAudioInfo(AudioInfo info) override
Receives and forwards updated AudioInfo to the chain.
Definition AudioPlayer.h:258
void setActive(bool isActive)
Toggles playback activity; triggers fade and optional silence.
Definition AudioPlayer.h:375
void setBufferSize(int size)
Sets the internal copy buffer size (bytes)
Definition AudioPlayer.h:163
AudioPlayer & operator=(AudioPlayer const &)=delete
Non-assignable: assignment operator is deleted.
void setOutput(AudioStream &output)
Sets the final output to an AudioStream (adds Volume/Fade for PCM)
Definition AudioPlayer.h:148
size_t copy()
Definition AudioPlayer.h:415
AudioInfo audioInfo() override
Returns the current AudioInfo of the playback chain.
Definition AudioPlayer.h:274
bool setIndex(int idx)
Selects stream by absolute index in the source.
Definition AudioPlayer.h:322
AudioPlayer(AudioSource &source, AudioOutput &output, AudioDecoder &decoder)
Construct a new Audio Player object. The processing chain is AudioSource -> Stream-copy -> EncodedAud...
Definition AudioPlayer.h:65
bool setMuted(bool muted)
Mutes or unmutes the audio player.
Definition AudioPlayer.h:538
void setVolumeControl(VolumeControl &vc)
Sets a custom VolumeControl implementation.
Definition AudioPlayer.h:468
AudioPlayer(AudioSource &source, Print &output, AudioDecoder &decoder, AudioInfoSupport *notify=nullptr)
Construct a new Audio Player object. The processing chain is AudioSource -> Stream-copy -> EncodedAud...
Definition AudioPlayer.h:84
AudioPlayer(AudioPlayer const &)=delete
Non-copyable: copy constructor is deleted.
Abstract Audio Data Source for the AudioPlayer which is used by the Audio Players.
Definition AudioSource.h:16
virtual Stream * selectStream(int index)
Definition AudioSource.h:29
virtual Stream * previousStream(int offset)
Returns previous audio stream.
Definition AudioSource.h:25
virtual bool isAutoNext()
Returns default setting go to the next.
Definition AudioSource.h:63
virtual Stream * nextStream(int offset)=0
Returns next audio stream.
virtual int timeoutAutoNext()
Provides the timeout which is triggering to move to the next stream.
Definition AudioSource.h:50
virtual bool begin()=0
Reset actual stream and move to root.
Base class for all Audio Streams. It support the boolean operator to test if the object is ready with...
Definition BaseStream.h:122
virtual void setAudioInfo(AudioInfo newInfo) override
Defines the input AudioInfo.
Definition BaseStream.h:130
virtual void writeSilence(size_t len)
Writes len bytes of silence (=0).
Definition BaseStream.h:159
Dummy Decoder which just copies the provided data to the output. You can define if it is PCM data.
Definition CodecCopy.h:18
A more natural Print class to process encoded data (aac, wav, mp3...). Just define the output and the...
Definition AudioEncoded.h:21
void end() override
Ends the processing.
Definition AudioEncoded.h:183
bool begin() override
Starts the processing - sets the status to active.
Definition AudioEncoded.h:155
void setOutput(Print *outputStream)
Defines the output.
Definition AudioEncoded.h:104
Stream which can be used to manage fade in and fade out. Before you read or write data you need to ca...
Definition Fade.h:240
void setOutput(Print &out) override
Defines/Changes the output target.
Definition Fade.h:251
void setAudioInfo(AudioInfo info) override
Defines the input AudioInfo.
Definition Fade.h:267
Simple ID3 Meta Data Parser which supports ID3 V1 and V2 and implements the Stream interface....
Definition MetaDataID3.h:569
virtual size_t write(const uint8_t *data, size_t len)
Provide tha audio data to the API to parse for Meta Data.
Definition MetaDataID3.h:601
void resize(int size)
Defines the ID3V3 result buffer size (default is 256);.
Definition MetaDataID3.h:611
Definition NoArduino.h:62
size_t copyBytes(size_t bytes)
Definition StreamCopy.h:114
void resize(int len)
resizes the copy buffer
Definition StreamCopy.h:309
void setCallbackOnWrite(void(*onWrite)(void *obj, void *buffer, size_t len), void *obj)
Defines a callback that is notified with the wirtten data.
Definition StreamCopy.h:275
void begin()
(Re)starts the processing
Definition StreamCopy.h:56
int bufferSize()
Provides the buffer size.
Definition StreamCopy.h:291
size_t copy()
Definition StreamCopy.h:100
Definition NoArduino.h:142
Abstract class for handling of the linear input volume to determine the multiplication factor which s...
Definition VolumeControl.h:19
Adjust the volume of the related input or output: To work properly the class needs to know the bits p...
Definition VolumeStream.h:34
void setOutput(Print &out) override
Defines/Changes the output target.
Definition VolumeStream.h:70
bool setVolume(float vol) override
Defines the volume for all channels: needs to be in the range of 0 to 1.0 (if allow boost has not bee...
Definition VolumeStream.h:181
void setAudioInfo(AudioInfo cfg) override
Detines the Audio info - The bits_per_sample are critical to work properly!
Definition VolumeStream.h:165
void setVolumeControl(VolumeControl &vc)
Defines the volume control logic.
Definition VolumeStream.h:122
Supports the setting and getting of the volume.
Definition AudioTypes.h:191
ID3TypeSelection
Enum to filter by type of metadata.
Definition AbstractMetaData.h:8
MetaDataType
Type of meta info.
Definition AbstractMetaData.h:11
StreamCopyT< uint8_t > StreamCopy
We provide the typeless StreamCopy.
Definition StreamCopy.h:425
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
uint32_t millis()
Returns the milliseconds since the start.
Definition Time.h:12
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:55
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:57
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:59
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:61