@@ -365,8 +365,19 @@ class HexDumpOutput : public AudioOutput {
365
365
template <typename T>
366
366
class OutputMixer : public Print {
367
367
public:
368
+ /* *
369
+ * @brief Default constructor. You must call setOutput() and setOutputCount() before use.
370
+ * @param allocator Reference to the allocator to use for internal buffers (default: DefaultAllocatorRAM)
371
+ */
368
372
OutputMixer (Allocator &allocator = DefaultAllocatorRAM) : allocator(allocator) {}
369
373
374
+ /* *
375
+ * @brief Constructor with output stream, number of input streams, and allocator.
376
+ *
377
+ * @param finalOutput Reference to the Print object for mixed audio output
378
+ * @param outputStreamCount Number of input streams to mix
379
+ * @param allocator Reference to the allocator to use for internal buffers (default: DefaultAllocatorRAM)
380
+ */
370
381
OutputMixer (Print &finalOutput, int outputStreamCount, Allocator &allocator = DefaultAllocatorRAM) : OutputMixer(allocator) {
371
382
setOutput (finalOutput);
372
383
setOutputCount (outputStreamCount);
@@ -525,11 +536,11 @@ class OutputMixer : public Print {
525
536
}
526
537
527
538
// / Resizes the buffer to the indicated number of bytes
528
- void resize (int size ) {
529
- if (size != size_bytes) {
530
- allocate_buffers (size );
539
+ void resize (int sizeBytes ) {
540
+ if (sizeBytes != size_bytes) {
541
+ allocate_buffers (sizeBytes );
531
542
}
532
- size_bytes = size ;
543
+ size_bytes = sizeBytes ;
533
544
}
534
545
535
546
// / Writes silence to the current stream buffer
@@ -589,8 +600,8 @@ class OutputMixer : public Print {
589
600
BaseBuffer<T>* (*create_buffer_cb)(int size, Allocator &allocator) = create_buffer;
590
601
591
602
// / Creates a default ring buffer of the specified size
592
- static BaseBuffer<T>* create_buffer (int size , Allocator &allocator) {
593
- return new RingBuffer<T>(size / sizeof (T), allocator);
603
+ static BaseBuffer<T>* create_buffer (int sizeBytes , Allocator &allocator) {
604
+ return new RingBuffer<T>(sizeBytes / sizeof (T), allocator);
594
605
}
595
606
596
607
// / Recalculates the total weights for normalization
@@ -602,13 +613,13 @@ class OutputMixer : public Print {
602
613
}
603
614
604
615
// / Allocates ring buffers for all input streams
605
- void allocate_buffers (int size ) {
616
+ void allocate_buffers (int sizeBytes ) {
606
617
// allocate ringbuffers for each output
607
618
for (int j = 0 ; j < output_count; j++) {
608
619
if (buffers[j] != nullptr ) {
609
620
delete buffers[j];
610
621
}
611
- buffers[j] = create_buffer (size , allocator);
622
+ buffers[j] = create_buffer (sizeBytes , allocator);
612
623
}
613
624
}
614
625
0 commit comments