arduino-audio-tools
Loading...
Searching...
No Matches
AudioPlayer.h
Go to the documentation of this file.
1#pragma once
2
15#include "AudioToolsConfig.h"
16
23namespace audio_tools {
24
52 public:
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);
124 } else {
125 out_decoding.setOutput(&output);
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);
139 } else {
140 out_decoding.setOutput(&output);
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);
154 } else {
155 out_decoding.setOutput(&output);
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 {
174 }
175
176 // take definition from source
178
179 // initial audio info for fade from output when not defined yet
180 setupFade();
181
182 // start dependent objects
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) {
200 if (p_input_stream != nullptr) {
201 if (meta_active) {
203 }
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");
216 result = false;
217 }
218 return result;
219 }
220
222 void end() {
223 TRACED();
224 active = false;
225 eof_called = false;
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
238
240 void setAudioSource(AudioSource& source) { this->p_source = &source; }
241
243 void setDecoder(AudioDecoder& decoder) {
244 this->p_decoder = &decoder;
246 }
247
250 this->p_final_notify = notify;
251 // notification for audio configuration
252 if (p_decoder != nullptr) {
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
267 // notifiy final ouput: e.g. i2s
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;
318 return active;
319 }
320
322 bool setIndex(int idx) {
323 TRACED();
324 writeEnd();
327 return active;
328 }
329
331 bool setPath(const char* path) {
332 TRACED();
333 writeEnd();
336 return active;
337 }
338
340 bool previous(int offset = 1) {
341 TRACED();
342 writeEnd();
343 stream_increment = -1;
345 return active;
346 }
347
349 bool setStream(Stream* input) {
350 end();
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();
358 }
359 // execute callback if defined
360 if (on_stream_change_callback != nullptr)
362 return p_input_stream != nullptr;
363 }
364
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 {
381 copier.copy();
382 writeSilence(2048);
383 }
384 }
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);
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 bool setVolume(float volume, int channel) {
406 return volume_out.setVolume(volume, channel);
407 }
408
410 float volume() override { return current_volume; }
411
413 float volume(int channel) { return volume_out.volume(channel); }
414
416 void setAutoNext(bool next) { autonext = next; }
417
420
423 size_t copy() { return copy(copier.bufferSize()); }
424
426 size_t copyAll() {
427 size_t result = 0;
428 size_t step = copy();
429 while (step > 0) {
430 result += step;
431 step = copy();
432 }
433 return result;
434 }
435
437 size_t copy(size_t bytes) {
438 size_t result = 0;
439 if (active) {
440 if (delay_if_full != 0 && ((p_final_print != nullptr &&
442 (p_final_stream != nullptr &&
444 // not ready to do anything - so we wait a bit
446 LOGD("copy: %d -> 0", (int)bytes);
447 return 0;
448 }
449
450 // handle sound
451 result = copier.copyBytes(bytes);
452 if (result > 0 || timeout == 0) {
453 // reset timeout if we had any data
455 }
456
457 // move to next stream after timeout
459
460 // return silence when there was no data
461 if (result < bytes && silence_on_inactive) {
462 writeSilence(bytes - result);
463 }
464
465 } else {
466 // e.g. A2DP should still receive data to keep the connection open
469 }
470 }
471 LOGD("copy: %d -> %d", (int)bytes, (int)result);
472 return result;
473 }
474
477
481
484
487
489 void writeSilence(size_t bytes) {
490 TRACEI();
491 if (p_final_print != nullptr) {
493 } else if (p_final_stream != nullptr) {
495 }
496 }
497
500
503
505 bool isAutoFade() { return is_auto_fade; }
506
508 void setMetaDataSize(int size) { meta_out.resize(size); }
509
511 void setReference(void* ref) { p_reference = ref; }
512
514 void setMetadataCallback(void (*callback)(MetaDataType type, const char* str,
515 int len),
517 TRACEI();
518 // setup metadata.
519 if (p_source->setMetadataCallback(callback)) {
520 // metadata is handled by source
521 LOGI("Using ICY Metadata");
522 meta_active = false;
523 } else {
524 // metadata is handled here
525 meta_out.setCallback(callback);
527 meta_active = true;
528 }
529 }
530
532 void setOnStreamChangeCallback(void (*callback)(Stream* stream_ptr,
533 void* reference)) {
534 on_stream_change_callback = callback;
535 if (p_input_stream != nullptr) callback(p_input_stream, p_reference);
536 }
537
541 void setOnEOFCallback(void (*callback)(AudioPlayer& player)) {
542 on_eof_callback = callback;
543 }
544
546 bool setMuted(bool muted) {
547 if (muted) {
548 if (current_volume > 0.0f) {
550 setVolume(0.0f);
551 }
552 } else {
553 if (muted_volume > 0.0f) {
555 muted_volume = 0.0f;
556 }
557 }
558 return true;
559 }
560
562 bool isMuted() { return current_volume == 0.0f; }
563
564 protected:
565 bool active = false;
566 bool autonext = true;
569 VolumeStream volume_out; // Volume control
570 FadeStream fade; // Phase in / Phase Out to avoid popping noise
571 MetaDataID3 meta_out; // Metadata parser
579 StreamCopy copier; // copies sound into i2s
581 bool meta_active = false;
583 int stream_increment = 1; // +1 moves forward; -1 moves backward
584 float current_volume = -1.0f; // illegal value which will trigger an update
585 float muted_volume = 0.0f;
586 int delay_if_full = 100;
587 bool is_auto_fade = true;
588 void* p_reference = nullptr;
590 void* reference) = nullptr;
591 // EOF callback and guard (invoked once when current stream reaches end)
592 void (*on_eof_callback)(AudioPlayer& player) = nullptr;
593 bool eof_called = false;
594
595 void setupFade() {
596 if (p_final_print != nullptr) {
598 } else if (p_final_stream != nullptr) {
600 }
601 }
602
604 if (p_final_stream != nullptr && p_final_stream->availableForWrite() == 0)
605 return;
606 if (p_input_stream == nullptr || millis() > timeout) {
608
609 // EOF callback: trigger once per stream
610 if (!eof_called) {
611 eof_called = true;
612 if (on_eof_callback != nullptr) {
613 on_eof_callback(*this);
614 }
615 }
616
617 if (autonext) {
618 LOGI("-> timeout - moving by %d", stream_increment);
619 // open next stream
620 if (!next(stream_increment)) {
621 LOGD("stream is null");
622 }
623 } else {
624 active = false;
625 }
627 }
628 }
629
630 void writeEnd() {
631 // end silently
632 TRACEI();
633 if (is_auto_fade) {
635 copier.copy();
636 // start by fading in
637 fade.setFadeInActive(true);
638 }
639 // restart the decoder to make sure it does not contain any audio when we
640 // continue
641 p_decoder->begin();
642 eof_called = false; // prepare for next stream
643 }
644
646 static void decodeMetaData(void* obj, void* data, size_t len) {
647 LOGD("%s, %zu", LOG_METHOD, len);
649 if (p->meta_active) {
650 p->meta_out.write((const uint8_t*)data, len);
651 }
652 }
653};
654
655} // namespace audio_tools
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACEI()
Definition AudioLoggerIDF.h:32
#define TRACED()
Definition AudioLoggerIDF.h:31
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define LOG_METHOD
Definition AudioToolsConfig.h:64
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 bool begin(AudioInfo info) override
Definition AudioCodecsBase.h:54
void end() override
Definition AudioCodecsBase.h:59
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 int availableForWrite() override
Definition AudioOutput.h:38
virtual void setAudioInfo(AudioInfo newInfo) override
Defines the input AudioInfo.
Definition AudioOutput.h:49
virtual void writeSilence(size_t len)
Definition AudioOutput.h:66
virtual AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition AudioOutput.h:62
High-level audio playback pipeline and controller.
Definition AudioPlayer.h:51
void setupFade()
Definition AudioPlayer.h:595
bool active
Definition AudioPlayer.h:565
void writeEnd()
Definition AudioPlayer.h:630
static void decodeMetaData(void *obj, void *data, size_t len)
Callback implementation which writes to metadata.
Definition AudioPlayer.h:646
void setOutput(Print &output)
Sets the final output to a Print (adds Volume/Fade for PCM)
Definition AudioPlayer.h:133
bool meta_active
Definition AudioPlayer.h:581
void setAudioSource(AudioSource &source)
Sets or replaces the AudioSource.
Definition AudioPlayer.h:240
int delay_if_full
Definition AudioPlayer.h:586
void writeSilence(size_t bytes)
Writes the requested number of zero bytes to the output.
Definition AudioPlayer.h:489
AudioOutput * p_final_print
Definition AudioPlayer.h:576
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
CopyDecoder no_decoder
Definition AudioPlayer.h:573
bool eof_called
Definition AudioPlayer.h:593
size_t copy(size_t bytes)
Copies the requested bytes from source to decoder (call in loop)
Definition AudioPlayer.h:437
int stream_increment
Definition AudioPlayer.h:583
size_t copyAll()
Copies until source is exhausted (blocking)
Definition AudioPlayer.h:426
void setSilenceOnInactive(bool active)
When enabled, writes zeros while inactive to keep sinks alive.
Definition AudioPlayer.h:483
bool isMuted()
Returns true if the player is currently muted.
Definition AudioPlayer.h:562
void moveToNextFileOnTimeout()
Definition AudioPlayer.h:603
void setOnEOFCallback(void(*callback)(AudioPlayer &player))
Definition AudioPlayer.h:541
bool isSilenceOnInactive()
Returns whether silence-on-inactive is enabled.
Definition AudioPlayer.h:486
void(* on_stream_change_callback)(Stream *stream_ptr, void *reference)
Definition AudioPlayer.h:589
void setOnStreamChangeCallback(void(*callback)(Stream *stream_ptr, void *reference))
Defines a callback that is called when the stream is changed.
Definition AudioPlayer.h:532
void(* on_eof_callback)(AudioPlayer &player)
Definition AudioPlayer.h:592
void setDelayIfOutputFull(int delayMs)
Sets delay (ms) to wait when output is full.
Definition AudioPlayer.h:419
void setMetaDataSize(int size)
Sets the maximum ID3 metadata buffer size (default 256)
Definition AudioPlayer.h:508
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:480
bool isAutoFade()
Checks whether automatic fade in/out is enabled.
Definition AudioPlayer.h:505
AudioInfo info
Definition AudioPlayer.h:580
AudioStream * p_final_stream
Definition AudioPlayer.h:577
bool playFile(const char *path)
Obsolete: use PlayPath!
Definition AudioPlayer.h:304
VolumeStream volume_out
Definition AudioPlayer.h:569
FadeStream fade
Definition AudioPlayer.h:570
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
AudioSource * p_source
Definition AudioPlayer.h:568
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:410
bool playPath(const char *path)
Definition AudioPlayer.h:286
bool silence_on_inactive
Definition AudioPlayer.h:567
EncodedAudioOutput out_decoding
Definition AudioPlayer.h:572
bool autonext
Definition AudioPlayer.h:566
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
AudioDecoder * p_decoder
Definition AudioPlayer.h:574
StreamCopy copier
Definition AudioPlayer.h:579
void setAutoNext(bool next)
Enables/disables auto-advance at end/timeout (overrides AudioSource)
Definition AudioPlayer.h:416
void setReference(void *ref)
Sets a user reference passed to the stream-change callback.
Definition AudioPlayer.h:511
AudioInfoSupport * p_final_notify
Definition AudioPlayer.h:578
AudioPlayer()
Default constructor.
Definition AudioPlayer.h:54
void setAutoFade(bool active)
Enables/disables automatic fade in/out to prevent pops.
Definition AudioPlayer.h:502
void setMetadataCallback(void(*callback)(MetaDataType type, const char *str, int len), ID3TypeSelection sel=SELECT_ID3)
Defines the metadata callback.
Definition AudioPlayer.h:514
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
bool is_auto_fade
Definition AudioPlayer.h:587
uint32_t timeout
Definition AudioPlayer.h:582
VolumeStream & getVolumeStream()
Returns the VolumeStream used by the player.
Definition AudioPlayer.h:499
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
MetaDataID3 meta_out
Definition AudioPlayer.h:571
Stream * p_input_stream
Definition AudioPlayer.h:575
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
float muted_volume
Definition AudioPlayer.h:585
AudioPlayer & operator=(AudioPlayer const &)=delete
Non-assignable: assignment operator is deleted.
void * p_reference
Definition AudioPlayer.h:588
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:423
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:546
bool setVolume(float volume, int channel)
Defines the volume for the indicated channel.
Definition AudioPlayer.h:405
float current_volume
Definition AudioPlayer.h:584
void setVolumeControl(VolumeControl &vc)
Sets a custom VolumeControl implementation.
Definition AudioPlayer.h:476
float volume(int channel)
Returns the current volume for the indicated channel.
Definition AudioPlayer.h:413
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 bool setMetadataCallback(void(*fn)(MetaDataType info, const char *str, int len), ID3TypeSelection sel=SELECT_ICY)
Definition AudioSource.h:53
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:123
virtual void setAudioInfo(AudioInfo newInfo) override
Defines the input AudioInfo.
Definition BaseStream.h:131
virtual void writeSilence(size_t len)
Writes len bytes of silence (=0).
Definition BaseStream.h:160
virtual AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition BaseStream.h:154
virtual int availableForWrite() override
Definition BaseStream.h:60
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 setDecoder(AudioDecoder *decoder)
Definition AudioEncoded.h:141
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
void setFadeOutActive(bool flag)
Definition Fade.h:308
void setFadeInActive(bool flag)
Definition Fade.h:304
Simple ID3 Meta Data Parser which supports ID3 V1 and V2 and implements the Stream interface....
Definition MetaDataID3.h:569
void setFilter(ID3TypeSelection sel)
Definition MetaDataID3.h:583
void setCallback(void(*fn)(MetaDataType info, const char *str, int len))
Definition MetaDataID3.h:578
bool begin()
Definition MetaDataID3.h:587
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 end()
Definition MetaDataID3.h:594
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
float volume() override
Provides the current (avg) volume accross all channels.
Definition VolumeStream.h:229
bool begin() override
Definition VolumeStream.h:90
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:187
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
@ SELECT_ID3
Definition AbstractMetaData.h:8
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
void delay(unsigned long ms)
Definition Time.h:23
uint32_t millis()
Returns the milliseconds since the start.
Definition Time.h:12
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:512
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