arduino-audio-tools
Loading...
Searching...
No Matches
AudioOutput.h
1#pragma once
2#include "AudioTools/CoreAudio/AudioTypes.h"
3#include "AudioTools/CoreAudio/BaseConverter.h"
4#include "AudioTools/CoreAudio/Buffers.h"
5#include "AudioToolsConfig.h"
6#if defined(USE_ESP32_DSP)
7#include "esp_dsp.h"
8#endif
9
10namespace audio_tools {
11
12#if USE_PRINT_FLUSH
13#define PRINT_FLUSH_OVERRIDE override
14#else
15#define PRINT_FLUSH_OVERRIDE
16#endif
17
23class AudioOutput : public Print,
24 public AudioInfoSupport,
25 public AudioInfoSource {
26 public:
27 virtual ~AudioOutput() = default;
28
29 virtual size_t write(const uint8_t *data, size_t len) override = 0;
30
31 virtual size_t write(uint8_t ch) override {
32 if (tmp.isFull()) {
33 flush();
34 }
35 return tmp.write(ch);
36 }
37
38 virtual int availableForWrite() override { return DEFAULT_BUFFER_SIZE; }
39
40 // removed override because some old implementation did not define this method
41 // as virtual
42 virtual void flush() PRINT_FLUSH_OVERRIDE {
43 if (tmp.available() > 0) {
44 write((const uint8_t *)tmp.address(), tmp.available());
45 }
46 }
47
48 // overwrite to do something useful
49 virtual void setAudioInfo(AudioInfo newInfo) override {
50 TRACED();
51 if (cfg != newInfo) {
52 cfg = newInfo;
53 cfg.logInfo();
54 }
55 AudioInfo out = audioInfoOut();
56 if (out) notifyAudioChange(out);
57 }
58
60 virtual bool isDeletable() { return false; }
61
62 virtual AudioInfo audioInfo() override { return cfg; }
63
66 virtual void writeSilence(size_t len) {
67 int16_t zero = 0;
68 for (int j = 0; j < len / 2; j++) {
69 write((uint8_t *)&zero, 2);
70 }
71 }
72
73 virtual bool begin(AudioInfo info) {
74 setAudioInfo(info);
75 return begin();
76 }
77
78 virtual bool begin() {
79 is_active = true;
80 return true;
81 }
82 virtual void end() { is_active = false; }
83
84 virtual operator bool() { return is_active; }
85
86 protected:
87 int tmpPos = 0;
88 AudioInfo cfg;
89 SingleBuffer<uint8_t> tmp{MAX_SINGLE_CHARS};
90 bool is_active = false;
91};
92
101 public:
103 virtual void setOutput(Print &out) = 0;
104};
105
115template <typename T = int16_t>
116class CsvOutput : public AudioOutput {
117 public:
118 CsvOutput(int buffer_size = DEFAULT_BUFFER_SIZE, bool active = true) {
119 this->is_active = active;
120 }
121
123 CsvOutput(Print &out, int channels = 2, int buffer_size = DEFAULT_BUFFER_SIZE,
124 bool active = true) {
125 this->out_ptr = &out;
126 this->is_active = active;
127 cfg.channels = channels;
128 }
129
131 void setDelimiter(const char *del) { delimiter_str = del; }
132
134 const char *delimiter() { return delimiter_str; }
135
137
140 AudioInfo info;
141 info.channels = 2;
142 info.sample_rate = 44100;
143 info.bits_per_sample = sizeof(T) * 8;
144 return info;
145 }
146
148 bool begin(AudioInfo info) override { return begin(info.channels); }
149
151 bool begin(int channels) {
152 TRACED();
153 cfg.channels = channels;
154 return begin();
155 }
156
158 bool begin() override {
159 this->is_active = true;
160 // if (out_ptr == &Serial){
161 // Serial.setTimeout(60000);
162 // }
163 return true;
164 }
165
167 virtual void setAudioInfo(AudioInfo info) override {
168 TRACEI();
169 this->is_active = true;
170 info.logInfo();
171 cfg = info;
172 };
173
175 virtual size_t write(const uint8_t *data, size_t len) override {
176 LOGD("CsvOutput::write: %d", (int)len);
177 if (!is_active) {
178 LOGE("is not active");
179 return 0;
180 }
181
182 if (len == 0) {
183 return 0;
184 }
185
186 if (cfg.channels == 0) {
187 LOGW("Channels not defined: using 2");
188 cfg.channels = 2;
189 }
190 size_t lenChannels = len / (sizeof(T) * cfg.channels);
191 if (lenChannels > 0) {
192 writeFrames((T *)data, lenChannels);
193 } else if (len == sizeof(T)) {
194 // if the write contains less then a frame we buffer the data
195 T *data_value = (T *)data;
196 out_ptr->print(data_value[0]);
197 channel++;
198 if (channel == cfg.channels) {
199 out_ptr->println();
200 channel = 0;
201 } else {
202 out_ptr->print(delimiter_str);
203 }
204 } else {
205 LOGE("Unsupported size: %d for channels %d and bits: %d", (int)len,
206 cfg.channels, cfg.bits_per_sample);
207 }
208#if USE_PRINT_FLUSH
209 out_ptr->flush();
210#endif
211 return len;
212 }
213
214 int availableForWrite() override { return 1024; }
215
216 protected:
217 T *data_ptr;
218 Print *out_ptr = &Serial;
219 int channel = 0;
220 const char *delimiter_str = ",";
221
222 void writeFrames(T *data_ptr, int frameCount) {
223 for (size_t j = 0; j < frameCount; j++) {
224 for (int ch = 0; ch < cfg.channels; ch++) {
225 if (out_ptr != nullptr && data_ptr != nullptr) {
226 T value = *data_ptr;
227 out_ptr->print(value);
228 }
229 data_ptr++;
230 if (ch < cfg.channels - 1) this->out_ptr->print(delimiter_str);
231 }
232 this->out_ptr->println();
233 }
234 }
235};
236
244 public:
245 HexDumpOutput(int buffer_size = DEFAULT_BUFFER_SIZE, bool active = true) {
246 this->is_active = active;
247 }
248
250 HexDumpOutput(Print &out, int buffer_size = DEFAULT_BUFFER_SIZE,
251 bool active = true) {
252 this->out_ptr = &out;
253 this->is_active = active;
254 }
255
256 bool begin() override {
257 TRACED();
258 this->is_active = true;
259 pos = 0;
260 return is_active;
261 }
262
263 void flush() override {
264 out_ptr->println();
265 pos = 0;
266 }
267
268 virtual size_t write(const uint8_t *data, size_t len) override {
269 if (!is_active) return 0;
270 TRACED();
271 for (size_t j = 0; j < len; j++) {
272 out_ptr->print(data[j], HEX);
273 out_ptr->print(" ");
274 pos++;
275 if (pos == 8) {
276 out_ptr->print(" - ");
277 }
278 if (pos == 16) {
279 out_ptr->println();
280 pos = 0;
281 }
282 }
283 return len;
284 }
285
286 //
287 AudioInfo defaultConfig(RxTxMode mode = TX_MODE) {
288 AudioInfo info;
289 return info;
290 }
291
292 protected:
293 Print *out_ptr = &Serial;
294 int pos = 0;
295};
296
368template <typename T = int16_t>
369class OutputMixer : public Print {
370 public:
377 OutputMixer(Allocator &allocator = DefaultAllocatorRAM)
378 : allocator(allocator) {}
379
389 OutputMixer(Print &finalOutput, int outputStreamCount,
390 Allocator &allocator = DefaultAllocatorRAM)
391 : OutputMixer(allocator) {
392 setOutput(finalOutput);
393 setOutputCount(outputStreamCount);
394 }
395
397 void setOutput(Print &finalOutput) { p_final_output = &finalOutput; }
398
400 void setOutputCount(int count) {
401 output_count = count;
402 buffers.resize(count);
403 for (int i = 0; i < count; i++) {
404 buffers[i] = nullptr;
405 }
406 weights.resize(count);
407 for (int i = 0; i < count; i++) {
408 weights[i] = 1.0;
409 }
410
412 }
413
416 void setWeight(int channel, float weight) {
417 if (channel < size()) {
418 weights[channel] = weight;
419 } else {
420 LOGE("Invalid channel %d - max is %d", channel, size() - 1);
421 }
423 }
424
426 bool begin(int copy_buffer_size_bytes = DEFAULT_BUFFER_SIZE) {
427 is_active = true;
428 size_bytes = copy_buffer_size_bytes;
429 stream_idx = 0;
430 allocate_buffers(size_bytes);
431 return true;
432 }
433
435 void end() {
436 total_weights = 0.0;
437 is_active = false;
438 // release memory for buffers
439 free_buffers();
440 }
441
443 int size() { return output_count; }
444
446 size_t write(uint8_t) override { return 0; }
447
450 size_t write(const uint8_t *data, size_t len) override {
451 size_t result = write(stream_idx, data, len);
452 // after writing the last stream we flush
453 if (is_auto_index) {
454 stream_idx++;
455 if (stream_idx >= output_count) {
456 flushMixer();
457 }
458 }
459 return result;
460 }
461
463 size_t write(int idx, const uint8_t *buffer_c, size_t bytes) {
464 LOGD("write idx %d: %d", idx, (int)bytes);
465 size_t result = 0;
466 BaseBuffer<T> *p_buffer = idx < output_count ? buffers[idx] : nullptr;
467 assert(p_buffer != nullptr);
468 size_t samples = bytes / sizeof(T);
469 if (p_buffer->availableForWrite() >= samples) {
470 result = p_buffer->writeArray((T *)buffer_c, samples) * sizeof(T);
471 } else {
472 LOGW(
473 "Available Buffer %d too small %d: requested: %d -> increase the "
474 "buffer size",
475 (int)idx, static_cast<int>(p_buffer->availableForWrite() * sizeof(T)),
476 (int)bytes);
477 }
478 return result;
479 }
480
482 int availableForWrite() override {
483 return is_active ? availableForWrite(stream_idx) : 0;
484 }
485
487 int availableForWrite(int idx) {
488 BaseBuffer<T> *p_buffer = buffers[idx];
489 if (p_buffer == nullptr) return 0;
490 return p_buffer->availableForWrite() * sizeof(T);
491 }
492
494 int available(int idx) {
495 BaseBuffer<T> *p_buffer = buffers[idx];
496 if (p_buffer == nullptr) return 0;
497 return p_buffer->available() * sizeof(T);
498 }
499
501 int availablePercent(int idx) { return 100.0 * available(idx) / size_bytes; }
502
504 void flushMixer() {
505 LOGD("flush");
506 bool result = false;
507
508 // determine ringbuffer with mininum available data
509 size_t samples = availableSamples();
510 // sum up samples
511 if (samples > 0) {
512 result = true;
513 mixSamples(samples);
514 // write output
515 LOGD("write to final out: %d", static_cast<int>(samples * sizeof(T)));
516 p_final_output->write((uint8_t *)output.data(), samples * sizeof(T));
517 }
518 stream_idx = 0;
519 return;
520 }
521
522
523
526 size_t samples = 0;
527 for (int j = 0; j < output_count; j++) {
528 int available_samples = buffers[j]->available();
529 if (available_samples > 0) {
530 samples = MIN(size_bytes / sizeof(T), (size_t)available_samples);
531 }
532 }
533 return samples;
534 }
535
537 void resize(int sizeBytes) {
538 if (sizeBytes != size_bytes) {
539 allocate_buffers(sizeBytes);
540 }
541 size_bytes = sizeBytes;
542 }
543
545 size_t writeSilence(size_t bytes) {
546 if (bytes == 0) return 0;
547 uint8_t silence[bytes];
548 memset(silence, 0, bytes);
549 return write(stream_idx, silence, bytes);
550 }
551
553 size_t writeSilence(int idx, size_t bytes) {
554 if (bytes == 0) return 0;
555 uint8_t silence[bytes];
556 memset(silence, 0, bytes);
557 return write(idx, silence, bytes);
558 }
559
561 void setAutoIndex(bool flag) { is_auto_index = flag; }
562
564 void setIndex(int idx) { stream_idx = idx; }
565
567 void next() { stream_idx++; }
568
571 create_buffer_cb = cb;
572 }
573
576 return idx < output_count ? buffers[idx] : nullptr;
577 }
578
579 protected:
580 Vector<float> weights{0, DefaultAllocatorRAM};
581 Vector<BaseBuffer<T> *> buffers{0, DefaultAllocatorRAM};
582 Allocator &allocator;
583 Vector<T> output{0, allocator};
584 Print *p_final_output = nullptr;
585 float total_weights = 0.0;
586 bool is_active = false;
587 int stream_idx = 0;
588 int size_bytes = 0;
589 int output_count = 0;
590 void *p_memory = nullptr;
591 bool is_auto_index = true;
592 BaseBuffer<T> *(*create_buffer_cb)(int size,
593 Allocator &allocator) = create_buffer;
594
596 static BaseBuffer<T> *create_buffer(int sizeBytes, Allocator &allocator) {
597 return new RingBuffer<T>(sizeBytes / sizeof(T), allocator);
598 }
599
601 inline void mixSamples(size_t samples) {
602#if defined(USE_ESP32_DSP)
603 // Temporary float buffers for mixing
604 float mix_out[samples] = {0.0f};
605 float temp[samples] = {0.0f};
606
607 for (uint8_t j = 0; j < output_count; j++) {
608 const float factor = weights[j] / total_weights;
609 // Read int16_t samples and convert to float
610 for (uint16_t i = 0; i < samples; i++) {
611 int16_t s = 0;
612 buffers[j]->read(s);
613 temp[i] = static_cast<float>(s) * factor;
614 }
615 // Add to output
616 dsps_add_f32(mix_out, temp, mix_out, samples, 1, 1, 1);
617 }
618 // Convert back to int16_t with clamping
619 output.resize(samples);
620 for (size_t i = 0; i < samples; i++) {
621 float v = mix_out[i];
622 output[i] = static_cast<int16_t>(v);
623 }
624#else
625 // Fallback: original scalar code
626 output.resize(samples);
627 memset(output.data(), 0, samples * sizeof(T));
628 for (int j = 0; j < output_count; j++) {
629 float factor = weights[j] / total_weights;
630 for (int i = 0; i < samples; i++) {
631 int16_t sample = 0;
632 buffers[j]->read(sample);
633 output[i] += static_cast<int16_t>(factor * sample);
634 }
635 }
636#endif
637 }
638
641 total_weights = 0.0;
642 for (int j = 0; j < weights.size(); j++) {
643 total_weights += weights[j];
644 }
645 }
646
648 void allocate_buffers(int sizeBytes) {
649 // allocate ringbuffers for each output
650 for (int j = 0; j < output_count; j++) {
651 if (buffers[j] != nullptr) {
652 delete buffers[j];
653 }
654 buffers[j] = create_buffer(sizeBytes, allocator);
655 }
656 }
657
660 // allocate ringbuffers for each output
661 for (int j = 0; j < output_count; j++) {
662 if (buffers[j] != nullptr) {
663 delete buffers[j];
664 buffers[j] = nullptr;
665 }
666 }
667 }
668};
669
674class MemoryOutput : public AudioOutput {
675 public:
676 MemoryOutput(uint8_t *start, int len) {
677 p_start = start;
678 p_next = start;
679 max_size = len;
680 is_active = true;
681 if (p_next == nullptr) {
682 LOGE("start must not be null");
683 }
684 }
685
686 bool begin() override {
687 is_active = true;
688 p_next = p_start;
689 pos = 0;
690 return true;
691 }
692
693 size_t write(const uint8_t *data, size_t len) override {
694 if (p_next == nullptr) return 0;
695 if (pos + len <= max_size) {
696 memcpy(p_next, data, len);
697 pos += len;
698 p_next += len;
699 return len;
700 } else {
701 LOGE("Buffer too small: pos:%d, size: %d ", pos, (int)max_size);
702 return 0;
703 }
704 }
705
706 int availableForWrite() override { return max_size - pos; }
707
708 int size() { return max_size; }
709
710 protected:
711 int pos = 0;
712 uint8_t *p_start = nullptr;
713 uint8_t *p_next = nullptr;
714 size_t max_size;
715};
716
726 public:
727 ChannelSplitOutput() = default;
728
729 ChannelSplitOutput(Print &out, int channel) { addOutput(out, channel); }
730
733 void addOutput(Print &out, int channel) {
735 def.channel = channel;
736 def.p_out = &out;
737 out_channels.push_back(def);
738 }
739
740 size_t write(const uint8_t *data, size_t len) override {
741 switch (cfg.bits_per_sample) {
742 case 16:
743 return writeT<int16_t>(data, len);
744 case 24:
745 return writeT<int24_t>(data, len);
746 case 32:
747 return writeT<int32_t>(data, len);
748 default:
749 return 0;
750 }
751 }
752
753 protected:
755 Print *p_out = nullptr;
756 int channel;
757 };
759
760 template <typename T = int16_t>
761 size_t writeT(const uint8_t *buffer, size_t size) {
762 int sample_count = size / sizeof(T);
763 int result_size = sample_count / cfg.channels;
764 T *data = (T *)buffer;
765 T result[result_size];
766
767 for (int ch = 0; ch < out_channels.size(); ch++) {
768 ChannelSelectionOutputDef &def = out_channels[ch];
769 // extract mono result
770 int i = 0;
771 for (int j = def.channel; j < sample_count; j += cfg.channels) {
772 result[i++] = data[j];
773 }
774 // write mono result
775 size_t written =
776 def.p_out->write((uint8_t *)result, result_size * sizeof(T));
777 if (written != result_size * sizeof(T)) {
778 LOGW("Could not write all samples");
779 }
780 }
781 return size;
782 }
783};
784
785} // namespace audio_tools
Memory allocateator which uses malloc.
Definition Allocator.h:23
Supports the subscription to audio change notifications.
Definition AudioTypes.h:150
Supports changes to the sampling rate, bits and channels.
Definition AudioTypes.h:135
virtual AudioInfo audioInfoOut()
Definition AudioTypes.h:143
Abstract Audio Ouptut class.
Definition AudioOutput.h:25
virtual bool isDeletable()
If true we need to release the related memory in the destructor.
Definition AudioOutput.h:60
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
Shared functionality of all buffers.
Definition Buffers.h:22
virtual int writeArray(const T data[], int len)
Fills the buffer data.
Definition Buffers.h:55
virtual int availableForWrite()=0
provides the number of entries that are available to write
virtual int available()=0
provides the number of entries that are available to read
Simple functionality to extract mono streams from a multichannel (e.g. stereo) signal.
Definition AudioOutput.h:725
void addOutput(Print &out, int channel)
Definition AudioOutput.h:733
Stream Wrapper which can be used to print the values as readable ASCII to the screen to be analyzed i...
Definition AudioOutput.h:116
virtual size_t write(const uint8_t *data, size_t len) override
Writes the data - formatted as CSV - to the output stream.
Definition AudioOutput.h:175
AudioInfo defaultConfig()
Provides the default configuration.
Definition AudioOutput.h:139
bool begin(int channels)
Starts the processing with the defined number of channels.
Definition AudioOutput.h:151
CsvOutput(Print &out, int channels=2, int buffer_size=DEFAULT_BUFFER_SIZE, bool active=true)
Constructor.
Definition AudioOutput.h:123
virtual void setAudioInfo(AudioInfo info) override
defines the number of channels
Definition AudioOutput.h:167
bool begin(AudioInfo info) override
Starts the processing with the defined number of channels.
Definition AudioOutput.h:148
bool begin() override
(Re)start (e.g. if channels is set in constructor)
Definition AudioOutput.h:158
void setDelimiter(const char *del)
Defines an alternative (column) delimiter. The default is ,.
Definition AudioOutput.h:131
const char * delimiter()
Provides the current column delimiter.
Definition AudioOutput.h:134
Creates a Hex Dump.
Definition AudioOutput.h:243
HexDumpOutput(Print &out, int buffer_size=DEFAULT_BUFFER_SIZE, bool active=true)
Constructor.
Definition AudioOutput.h:250
Writes to a preallocated memory.
Definition AudioOutput.h:674
Abstract class: Objects can be put into a pipleline.
Definition AudioOutput.h:100
virtual void setOutput(Print &out)=0
Defines/Changes the output target.
Mixing of multiple audio input streams into a single output stream.
Definition AudioOutput.h:369
void next()
Moves to the next mixing index.
Definition AudioOutput.h:567
size_t writeSilence(size_t bytes)
Writes silence to the current stream buffer.
Definition AudioOutput.h:545
void setIndex(int idx)
Sets the Output Stream index.
Definition AudioOutput.h:564
void mixSamples(size_t samples)
Mixes the samples from all input streams into the output buffer.
Definition AudioOutput.h:601
int availableSamples()
Returns the minimum number of samples available across all buffers.
Definition AudioOutput.h:525
OutputMixer(Print &finalOutput, int outputStreamCount, Allocator &allocator=DefaultAllocatorRAM)
Constructor with output stream, number of input streams, and allocator.
Definition AudioOutput.h:389
size_t writeSilence(int idx, size_t bytes)
Writes silence to the specified stream buffer.
Definition AudioOutput.h:553
size_t write(int idx, const uint8_t *buffer_c, size_t bytes)
Write the data for an individual stream idx which will be mixed together.
Definition AudioOutput.h:463
size_t write(const uint8_t *data, size_t len) override
Definition AudioOutput.h:450
int available(int idx)
Provides the available bytes in the buffer.
Definition AudioOutput.h:494
BaseBuffer< T > * getBuffer(int idx)
Provides the write buffer for the indicated index.
Definition AudioOutput.h:575
void setCreateBufferCallback(BaseBuffer< T > *(*cb)(int size))
Define callback to allocate custum buffer types.
Definition AudioOutput.h:570
int availableForWrite() override
Provides the bytes available to write for the current stream buffer.
Definition AudioOutput.h:482
int availablePercent(int idx)
Provides the % fill level of the buffer for the indicated index.
Definition AudioOutput.h:501
void update_total_weights()
Recalculates the total weights for normalization.
Definition AudioOutput.h:640
void free_buffers()
Releases memory for all ring buffers.
Definition AudioOutput.h:659
void flushMixer()
Force output to final destination.
Definition AudioOutput.h:504
OutputMixer(Allocator &allocator=DefaultAllocatorRAM)
Default constructor. You must call setOutput() and setOutputCount() before use.
Definition AudioOutput.h:377
void end()
Remove all input streams.
Definition AudioOutput.h:435
void setOutput(Print &finalOutput)
Sets the final output destination for mixed audio.
Definition AudioOutput.h:397
void setWeight(int channel, float weight)
Definition AudioOutput.h:416
int availableForWrite(int idx)
Provides the bytes available to write for the indicated stream index.
Definition AudioOutput.h:487
void resize(int sizeBytes)
Resizes the buffer to the indicated number of bytes.
Definition AudioOutput.h:537
static BaseBuffer< T > * create_buffer(int sizeBytes, Allocator &allocator)
Creates a default ring buffer of the specified size.
Definition AudioOutput.h:596
void setAutoIndex(bool flag)
Automatically increment mixing index after each write.
Definition AudioOutput.h:561
bool begin(int copy_buffer_size_bytes=DEFAULT_BUFFER_SIZE)
Starts the processing.
Definition AudioOutput.h:426
int size()
Number of stremams to which are mixed together.
Definition AudioOutput.h:443
void setOutputCount(int count)
Sets the number of input streams to mix.
Definition AudioOutput.h:400
size_t write(uint8_t) override
Single byte write - not supported, returns 0.
Definition AudioOutput.h:446
void allocate_buffers(int sizeBytes)
Allocates ring buffers for all input streams.
Definition AudioOutput.h:648
Definition NoArduino.h:62
Implements a typed Ringbuffer.
Definition Buffers.h:341
bool write(T sample) override
write add an entry to the buffer
Definition Buffers.h:206
int available() override
provides the number of entries that are available to read
Definition Buffers.h:233
T * address() override
Provides address to beginning of the buffer.
Definition Buffers.h:281
bool isFull() override
checks if the buffer is full
Definition Buffers.h:240
Vector implementation which provides the most important methods as defined by std::vector....
Definition Vector.h:21
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:30
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
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