@@ -372,8 +372,10 @@ class OutputMixer : public Print {
372
372
setOutputCount (outputStreamCount);
373
373
}
374
374
375
+ // / Sets the final output destination for mixed audio
375
376
void setOutput (Print &finalOutput) { p_final_output = &finalOutput; }
376
377
378
+ // / Sets the number of input streams to mix
377
379
void setOutputCount (int count) {
378
380
output_count = count;
379
381
buffers.resize (count);
@@ -419,6 +421,7 @@ class OutputMixer : public Print {
419
421
// / Number of stremams to which are mixed together
420
422
int size () { return output_count; }
421
423
424
+ // / Single byte write - not supported, returns 0
422
425
size_t write (uint8_t ) override { return 0 ; }
423
426
424
427
// / Write the data from a simgle stream which will be mixed together (the
@@ -509,6 +512,7 @@ class OutputMixer : public Print {
509
512
return ;
510
513
}
511
514
515
+ // / Returns the minimum number of samples available across all buffers
512
516
int availableSamples () {
513
517
size_t samples = 0 ;
514
518
for (int j = 0 ; j < output_count; j++) {
@@ -528,13 +532,15 @@ class OutputMixer : public Print {
528
532
size_bytes = size;
529
533
}
530
534
535
+ // / Writes silence to the current stream buffer
531
536
size_t writeSilence (size_t bytes) {
532
537
if (bytes == 0 ) return 0 ;
533
538
uint8_t silence[bytes];
534
539
memset (silence, 0 , bytes);
535
540
return write (stream_idx, silence, bytes);
536
541
}
537
542
543
+ // / Writes silence to the specified stream buffer
538
544
size_t writeSilence (int idx, size_t bytes){
539
545
if (bytes == 0 ) return 0 ;
540
546
uint8_t silence[bytes];
@@ -581,17 +587,20 @@ class OutputMixer : public Print {
581
587
bool is_auto_index = true ;
582
588
BaseBuffer<T>* (*create_buffer_cb)(int size) = create_buffer;
583
589
590
+ // / Creates a default ring buffer of the specified size
584
591
static BaseBuffer<T>* create_buffer (int size) {
585
592
return new RingBuffer<T>(size / sizeof (T));
586
593
}
587
594
595
+ // / Recalculates the total weights for normalization
588
596
void update_total_weights () {
589
597
total_weights = 0.0 ;
590
598
for (int j = 0 ; j < weights.size (); j++) {
591
599
total_weights += weights[j];
592
600
}
593
601
}
594
602
603
+ // / Allocates ring buffers for all input streams
595
604
void allocate_buffers (int size) {
596
605
// allocate ringbuffers for each output
597
606
for (int j = 0 ; j < output_count; j++) {
@@ -602,6 +611,7 @@ class OutputMixer : public Print {
602
611
}
603
612
}
604
613
614
+ // / Releases memory for all ring buffers
605
615
void free_buffers () {
606
616
// allocate ringbuffers for each output
607
617
for (int j = 0 ; j < output_count; j++) {
0 commit comments