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/AudioHttp/AudioHttp.h"
6#include "AudioTools/CoreAudio/AudioLogger.h"
7#include "AudioTools/CoreAudio/AudioMetaData/MetaData.h"
8#include "AudioTools/CoreAudio/AudioStreams.h"
9#include "AudioTools/CoreAudio/AudioTypes.h"
10#include "AudioTools/CoreAudio/BaseConverter.h"
11#include "AudioTools/CoreAudio/Buffers.h"
12#include "AudioTools/CoreAudio/Fade.h"
13#include "AudioTools/CoreAudio/StreamCopy.h"
14#include "AudioTools/CoreAudio/VolumeStream.h"
15#include "AudioTools/Disk/AudioSource.h"
16#include "AudioToolsConfig.h"
17
24namespace audio_tools {
25
39 public:
41 AudioPlayer() { TRACED(); }
42
52 AudioPlayer(AudioSource &source, AudioOutput &output, AudioDecoder &decoder) {
53 TRACED();
54 this->p_source = &source;
55 this->p_decoder = &decoder;
56 setOutput(output);
57 // notification for audio configuration
58 decoder.addNotifyAudioChange(*this);
59 }
60
71 AudioPlayer(AudioSource &source, Print &output, AudioDecoder &decoder,
72 AudioInfoSupport *notify = nullptr) {
73 TRACED();
74 this->p_source = &source;
75 this->p_decoder = &decoder;
76 setOutput(output);
78 }
79
89 AudioPlayer(AudioSource &source, AudioStream &output, AudioDecoder &decoder) {
90 TRACED();
91 this->p_source = &source;
92 this->p_decoder = &decoder;
93 setOutput(output);
94 // notification for audio configuration
95 decoder.addNotifyAudioChange(*this);
96 }
97
98 AudioPlayer(AudioPlayer const &) = delete;
99
100 AudioPlayer &operator=(AudioPlayer const &) = delete;
101
102 void setOutput(AudioOutput &output) {
103 if (p_decoder->isResultPCM()) {
104 this->fade.setOutput(output);
105 this->volume_out.setOutput(fade);
106 out_decoding.setOutput(&volume_out);
107 out_decoding.setDecoder(p_decoder);
108 } else {
109 out_decoding.setOutput(&output);
110 out_decoding.setDecoder(p_decoder);
111 }
112 this->p_final_print = &output;
113 this->p_final_stream = nullptr;
114 }
115
116 void setOutput(Print &output) {
117 if (p_decoder->isResultPCM()) {
118 this->fade.setOutput(output);
119 this->volume_out.setOutput(fade);
120 out_decoding.setOutput(&volume_out);
121 out_decoding.setDecoder(p_decoder);
122 } else {
123 out_decoding.setOutput(&output);
124 out_decoding.setDecoder(p_decoder);
125 }
126 this->p_final_print = nullptr;
127 this->p_final_stream = nullptr;
128 }
129
130 void setOutput(AudioStream &output) {
131 if (p_decoder->isResultPCM()) {
132 this->fade.setOutput(output);
133 this->volume_out.setOutput(fade);
134 out_decoding.setOutput(&volume_out);
135 out_decoding.setDecoder(p_decoder);
136 } else {
137 out_decoding.setOutput(&output);
138 out_decoding.setDecoder(p_decoder);
139 }
140 this->p_final_print = nullptr;
141 this->p_final_stream = &output;
142 }
143
145 void setBufferSize(int size) { copier.resize(size); }
146
149 bool begin(int index = 0, bool isActive = true) {
150 TRACED();
151 bool result = false;
152 // initilaize volume
153 if (current_volume == -1.0f) {
154 setVolume(1.0f);
155 } else {
156 setVolume(current_volume);
157 }
158
159 // take definition from source
160 autonext = p_source->isAutoNext();
161
162 // initial audio info for fade from output when not defined yet
163 setupFade();
164
165 // start dependent objects
166 out_decoding.begin();
167 p_source->begin();
168 meta_out.begin();
169 volume_out.begin();
170
171 if (index >= 0) {
172 setStream(p_source->selectStream(index));
173 if (p_input_stream != nullptr) {
174 if (meta_active) {
176 }
177 copier.begin(out_decoding, *p_input_stream);
178 timeout = millis() + p_source->timeoutAutoNext();
179 active = isActive;
180 result = true;
181 } else {
182 LOGW("-> begin: no data found");
183 active = false;
184 result = false;
185 }
186 } else {
187 LOGW("-> begin: no stream selected");
188 active = isActive;
189 result = false;
190 }
191 return result;
192 }
193
194 void end() {
195 TRACED();
196 active = false;
197 out_decoding.end();
198 meta_out.end();
199 // remove any data in the decoder
200 if (p_decoder != nullptr) {
201 LOGI("reset codec");
202 p_decoder->end();
203 p_decoder->begin();
204 }
205 }
206
208 AudioSource &audioSource() { return *p_source; }
209
211 void setAudioSource(AudioSource &source) { this->p_source = &source; }
212
214 void setDecoder(AudioDecoder &decoder) {
215 this->p_decoder = &decoder;
216 out_decoding.setDecoder(p_decoder);
217 }
218
221 this->p_final_notify = notify;
222 // notification for audio configuration
223 if (p_decoder != nullptr) {
224 p_decoder->addNotifyAudioChange(*this);
225 }
226 }
227
229 void setAudioInfo(AudioInfo info) override {
230 TRACED();
231 LOGI("sample_rate: %d", (int)info.sample_rate);
232 LOGI("bits_per_sample: %d", (int)info.bits_per_sample);
233 LOGI("channels: %d", (int)info.channels);
234 this->info = info;
235 // notifiy volume
236 volume_out.setAudioInfo(info);
237 fade.setAudioInfo(info);
238 // notifiy final ouput: e.g. i2s
239 if (p_final_print != nullptr) p_final_print->setAudioInfo(info);
240 if (p_final_stream != nullptr) p_final_stream->setAudioInfo(info);
241 if (p_final_notify != nullptr) p_final_notify->setAudioInfo(info);
242 };
243
244 AudioInfo audioInfo() override { return info; }
245
247 void play() {
248 TRACED();
249 setActive(true);
250 }
251
255 bool playPath(const char *path) {
256 TRACED();
257 if (!setPath(path)) {
258 LOGW("Could not open file: %s", path);
259 return false;
260 }
261
262 LOGI("Playing %s", path);
263 // start if inactive
264 play();
265 // process all data
266 copyAll();
267
268 LOGI("%s has finished playing", path);
269 return true;
270 }
271
273 bool playFile(const char *path) { return playPath(path); }
274
275
277 void stop() {
278 TRACED();
279 setActive(false);
280 }
281
284 bool next(int offset = 1) {
285 TRACED();
286 writeEnd();
287 stream_increment = offset >= 0 ? 1 : -1;
288 active = setStream(p_source->nextStream(offset));
289 return active;
290 }
291
293 bool setIndex(int idx) {
294 TRACED();
295 writeEnd();
296 stream_increment = 1;
297 active = setStream(p_source->selectStream(idx));
298 return active;
299 }
300
302 bool setPath(const char *path) {
303 TRACED();
304 writeEnd();
305 stream_increment = 1;
306 active = setStream(p_source->selectStream(path));
307 return active;
308 }
309
311 bool previous(int offset = 1) {
312 TRACED();
313 writeEnd();
314 stream_increment = -1;
315 active = setStream(p_source->previousStream(abs(offset)));
316 return active;
317 }
318
320 bool setStream(Stream *input) {
321 end();
322 out_decoding.begin();
323 p_input_stream = input;
324 if (p_input_stream != nullptr) {
325 LOGD("open selected stream");
326 meta_out.begin();
327 copier.begin(out_decoding, *p_input_stream);
328 }
329 // execute callback if defined
330 if (on_stream_change_callback != nullptr)
331 on_stream_change_callback(p_input_stream, p_reference);
332 return p_input_stream != nullptr;
333 }
334
336 Stream *getStream() { return p_input_stream; }
337
339 bool isActive() { return active; }
340
342 operator bool() { return isActive(); }
343
345 void setActive(bool isActive) {
346 if (is_auto_fade) {
347 if (isActive) {
348 fade.setFadeInActive(true);
349 } else {
350 fade.setFadeOutActive(true);
351 copier.copy();
352 writeSilence(2048);
353 }
354 }
355 active = isActive;
356 }
357
359 bool setVolume(float volume) override {
360 bool result = true;
361 if (volume >= 0.0f && volume <= 1.0f) {
362 if (abs(volume - current_volume) > 0.01f) {
363 LOGI("setVolume(%f)", volume);
364 volume_out.setVolume(volume);
365 current_volume = volume;
366 }
367 } else {
368 LOGE("setVolume value '%f' out of range (0.0 -1.0)", volume);
369 result = false;
370 }
371 return result;
372 }
373
375 float volume() override { return current_volume; }
376
380 void setAutoNext(bool next) { autonext = next; }
381
383 void setDelayIfOutputFull(int delayMs) { delay_if_full = delayMs; }
384
387 size_t copy() { return copy(copier.bufferSize()); }
388
390 size_t copyAll() {
391 size_t result = 0;
392 size_t step = copy();
393 while (step > 0) {
394 result += step;
395 step = copy();
396 }
397 return result;
398 }
399
402 size_t copy(size_t bytes) {
403 size_t result = 0;
404 if (active) {
405 TRACED();
406 if (delay_if_full != 0 && ((p_final_print != nullptr &&
407 p_final_print->availableForWrite() == 0) ||
408 (p_final_stream != nullptr &&
409 p_final_stream->availableForWrite() == 0))) {
410 // not ready to do anything - so we wait a bit
411 delay(delay_if_full);
412 return 0;
413 }
414 // handle sound
415 result = copier.copyBytes(bytes);
416 if (result > 0 || timeout == 0) {
417 // reset timeout if we had any data
418 timeout = millis() + p_source->timeoutAutoNext();
419 }
420 // move to next stream after timeout
421 moveToNextFileOnTimeout();
422
423 // return silence when there was no data
424 if (result < bytes && silence_on_inactive) {
425 writeSilence(bytes - result);
426 }
427
428 } else {
429 // e.g. A2DP should still receive data to keep the connection open
430 if (silence_on_inactive) {
431 writeSilence(1024);
432 }
433 }
434 return result;
435 }
436
438 void setVolumeControl(VolumeControl &vc) { volume_out.setVolumeControl(vc); }
439
442 StreamCopy &getStreamCopy() { return copier; }
443
446 void setSilenceOnInactive(bool active) { silence_on_inactive = active; }
447
449 bool isSilenceOnInactive() { return silence_on_inactive; }
450
452 void writeSilence(size_t bytes) {
453 TRACEI();
454 if (p_final_print != nullptr) {
455 p_final_print->writeSilence(bytes);
456 } else if (p_final_stream != nullptr) {
457 p_final_stream->writeSilence(bytes);
458 }
459 }
460
461 // /// Provides the Print object to which we send the decoding result
462 // Print *getVolumeOutput() { return &volume_out; }
463
465 VolumeStream &getVolumeStream() { return volume_out; }
466
469 void setAutoFade(bool active) { is_auto_fade = active; }
470
471 bool isAutoFade() { return is_auto_fade; }
472
474 void setMetaDataSize(int size) { meta_out.resize(size); }
475
477 void setReference(void *ref) { p_reference = ref; }
478
480 void setMetadataCallback(void (*callback)(MetaDataType type, const char *str,
481 int len),
482 ID3TypeSelection sel = SELECT_ID3) {
483 TRACEI();
484 // setup metadata.
485 if (p_source->setMetadataCallback(callback)) {
486 // metadata is handled by source
487 LOGI("Using ICY Metadata");
488 meta_active = false;
489 } else {
490 // metadata is handled here
491 meta_out.setCallback(callback);
492 meta_out.setFilter(sel);
493 meta_active = true;
494 }
495 }
496
498 void setOnStreamChangeCallback(void (*callback)(Stream *stream_ptr,
499 void *reference)) {
500 on_stream_change_callback = callback;
501 if (p_input_stream!=nullptr) callback(p_input_stream, p_reference);
502 }
503
504 protected:
505 bool active = false;
506 bool autonext = true;
507 bool silence_on_inactive = false;
508 AudioSource *p_source = nullptr;
509 VolumeStream volume_out; // Volume control
510 FadeStream fade; // Phase in / Phase Out to avoid popping noise
511 MetaDataID3 meta_out; // Metadata parser
512 EncodedAudioOutput out_decoding; // Decoding stream
513 CopyDecoder no_decoder{true};
514 AudioDecoder *p_decoder = &no_decoder;
515 Stream *p_input_stream = nullptr;
516 AudioOutput *p_final_print = nullptr;
517 AudioStream *p_final_stream = nullptr;
518 AudioInfoSupport *p_final_notify = nullptr;
519 StreamCopy copier; // copies sound into i2s
520 AudioInfo info;
521 bool meta_active = false;
522 uint32_t timeout = 0;
523 int stream_increment = 1; // +1 moves forward; -1 moves backward
524 float current_volume = -1.0f; // illegal value which will trigger an update
525 int delay_if_full = 100;
526 bool is_auto_fade = true;
527 void *p_reference = nullptr;
528 void (*on_stream_change_callback)(Stream *stream_ptr,
529 void *reference) = nullptr;
530
531 void setupFade() {
532 if (p_final_print != nullptr) {
533 fade.setAudioInfo(p_final_print->audioInfo());
534 } else if (p_final_stream != nullptr) {
535 fade.setAudioInfo(p_final_stream->audioInfo());
536 }
537 }
538
539 void moveToNextFileOnTimeout() {
540 if (p_final_stream != nullptr && p_final_stream->availableForWrite() == 0)
541 return;
542 if (p_input_stream == nullptr || millis() > timeout) {
543 if (is_auto_fade) fade.setFadeInActive(true);
544 if (autonext) {
545 LOGI("-> timeout - moving by %d", stream_increment);
546 // open next stream
547 if (!next(stream_increment)) {
548 LOGD("stream is null");
549 }
550 } else {
551 active = false;
552 }
553 timeout = millis() + p_source->timeoutAutoNext();
554 }
555 }
556
557 void writeEnd() {
558 // end silently
559 TRACEI();
560 if (is_auto_fade) {
561 fade.setFadeOutActive(true);
562 copier.copy();
563 // start by fading in
564 fade.setFadeInActive(true);
565 }
566 // restart the decoder to make sure it does not contain any audio when we
567 // continue
568 p_decoder->begin();
569 }
570
572 static void decodeMetaData(void *obj, void *data, size_t len) {
573 LOGD("%s, %zu", LOG_METHOD, len);
574 AudioPlayer *p = (AudioPlayer *)obj;
575 if (p->meta_active) {
576 p->meta_out.write((const uint8_t *)data, len);
577 }
578 }
579};
580
581} // 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:151
Supports changes to the sampling rate, bits and channels.
Definition AudioTypes.h:133
virtual void setAudioInfo(AudioInfo info)=0
Defines the input AudioInfo.
Abstract Audio Ouptut class.
Definition AudioOutput.h:22
virtual void setAudioInfo(AudioInfo newInfo) override
Defines the input AudioInfo.
Definition AudioOutput.h:46
virtual void writeSilence(size_t len)
Definition AudioOutput.h:63
Implements a simple audio player which supports the following commands:
Definition AudioPlayer.h:38
static void decodeMetaData(void *obj, void *data, size_t len)
Callback implementation which writes to metadata.
Definition AudioPlayer.h:572
void setAudioSource(AudioSource &source)
(Re)defines the audio source
Definition AudioPlayer.h:211
void writeSilence(size_t bytes)
Sends the requested bytes as 0 values to the output.
Definition AudioPlayer.h:452
AudioPlayer(AudioSource &source, AudioStream &output, AudioDecoder &decoder)
Construct a new Audio Player object. The processing chain is AudioSource -> Stream-copy -> EncodedAud...
Definition AudioPlayer.h:89
AudioSource & audioSource()
Provides the actual audio source.
Definition AudioPlayer.h:208
size_t copy(size_t bytes)
Definition AudioPlayer.h:402
size_t copyAll()
Copies all the data.
Definition AudioPlayer.h:390
void setSilenceOnInactive(bool active)
Definition AudioPlayer.h:446
bool isSilenceOnInactive()
Checks if silence_on_inactive has been activated (default false)
Definition AudioPlayer.h:449
void setOnStreamChangeCallback(void(*callback)(Stream *stream_ptr, void *reference))
Defines a callback that is called when the stream is changed.
Definition AudioPlayer.h:498
void setDelayIfOutputFull(int delayMs)
Defines the wait time in ms if the target output is full.
Definition AudioPlayer.h:383
void setMetaDataSize(int size)
Change the default ID3 max metadata size (256)
Definition AudioPlayer.h:474
bool setStream(Stream *input)
start selected input stream
Definition AudioPlayer.h:320
void setDecoder(AudioDecoder &decoder)
(Re)defines the decoder
Definition AudioPlayer.h:214
StreamCopy & getStreamCopy()
Definition AudioPlayer.h:442
bool playFile(const char *path)
Obsolete: use PlayPath!
Definition AudioPlayer.h:273
bool setVolume(float volume) override
sets the volume - values need to be between 0.0 and 1.0
Definition AudioPlayer.h:359
Stream * getStream()
Provides the actual stream (=e.g.file)
Definition AudioPlayer.h:336
void play()
starts / resumes the playing after calling stop(): same as setActive(true)
Definition AudioPlayer.h:247
bool next(int offset=1)
Definition AudioPlayer.h:284
float volume() override
Determines the actual volume.
Definition AudioPlayer.h:375
bool playPath(const char *path)
Definition AudioPlayer.h:255
void addNotifyAudioChange(AudioInfoSupport *notify)
(Re)defines the notify
Definition AudioPlayer.h:220
void stop()
halts the playing: same as setActive(false)
Definition AudioPlayer.h:277
void setAutoNext(bool next)
Definition AudioPlayer.h:380
void setReference(void *ref)
this is used to set the reference for the stream change callback
Definition AudioPlayer.h:477
AudioPlayer()
Default constructor.
Definition AudioPlayer.h:41
void setAutoFade(bool active)
Definition AudioPlayer.h:469
void setMetadataCallback(void(*callback)(MetaDataType type, const char *str, int len), ID3TypeSelection sel=SELECT_ID3)
Defines the medatadata callback.
Definition AudioPlayer.h:480
bool isActive()
determines if the player is active
Definition AudioPlayer.h:339
bool previous(int offset=1)
moves to previous file
Definition AudioPlayer.h:311
VolumeStream & getVolumeStream()
Provides the reference to the volume stream.
Definition AudioPlayer.h:465
bool setPath(const char *path)
Moves to the selected file w/o updating the actual file position.
Definition AudioPlayer.h:302
bool begin(int index=0, bool isActive=true)
Definition AudioPlayer.h:149
void setAudioInfo(AudioInfo info) override
Updates the audio info in the related objects.
Definition AudioPlayer.h:229
void setActive(bool isActive)
The same like start() / stop()
Definition AudioPlayer.h:345
void setBufferSize(int size)
Defines the number of bytes used by the copier.
Definition AudioPlayer.h:145
size_t copy()
Definition AudioPlayer.h:387
AudioInfo audioInfo() override
provides the actual input AudioInfo
Definition AudioPlayer.h:244
bool setIndex(int idx)
moves to the selected file position
Definition AudioPlayer.h:293
AudioPlayer(AudioSource &source, AudioOutput &output, AudioDecoder &decoder)
Construct a new Audio Player object. The processing chain is AudioSource -> Stream-copy -> EncodedAud...
Definition AudioPlayer.h:52
void setVolumeControl(VolumeControl &vc)
Change the VolumeControl implementation.
Definition AudioPlayer.h:438
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:71
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 void begin()=0
Reset actual stream and move to root.
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
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:176
bool begin() override
Starts the processing - sets the status to active.
Definition AudioEncoded.h:149
void setOutput(Print *outputStream)
Defines the output.
Definition AudioEncoded.h:98
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:567
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:598
void resize(int size)
Defines the ID3V3 result buffer size (default is 256);.
Definition MetaDataID3.h:608
Definition NoArduino.h:62
size_t copyBytes(size_t bytes)
copies the inicated number of bytes from the source to the destination and returns the processed numb...
Definition StreamCopy.h:107
void resize(int len)
resizes the copy buffer
Definition StreamCopy.h:308
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:266
void begin()
(Re)starts the processing
Definition StreamCopy.h:50
int bufferSize()
Provides the buffer size.
Definition StreamCopy.h:283
size_t copy()
copies the data from the source to the destination and returns the processed number of bytes
Definition StreamCopy.h:95
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:179
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:189
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:433
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:53
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:55
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:57
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:59