@@ -367,7 +367,7 @@ class OutputMixer : public Print {
367
367
size_t write (const uint8_t *buffer_c, size_t bytes) override {
368
368
size_t result = write (stream_idx, buffer_c, bytes);
369
369
// after writing the last stream we flush
370
- stream_idx++;
370
+ if (is_auto_index) stream_idx++;
371
371
if (stream_idx >= output_count) {
372
372
flushMixer ();
373
373
}
@@ -444,12 +444,8 @@ class OutputMixer : public Print {
444
444
size_bytes = size;
445
445
}
446
446
447
- // / Sets the Output Stream index
448
- void setIndex (int idx){
449
- stream_idx = idx;
450
- }
451
447
452
- size_t writeSilence (size_t bytes) override {
448
+ size_t writeSilence (size_t bytes) {
453
449
if (bytes == 0 ) return 0 ;
454
450
byte silence[bytes] = {0 };
455
451
return write (stream_idx, silence, bytes);
@@ -461,6 +457,21 @@ class OutputMixer : public Print {
461
457
return write (idx, silence, bytes);
462
458
}
463
459
460
+ // / Automatically increment mixing index after each write
461
+ void setAutoIndex (bool flag){
462
+ is_auto_index = flag;
463
+ }
464
+
465
+ // / Sets the Output Stream index
466
+ void setIndex (int idx){
467
+ stream_idx = idx;
468
+ }
469
+
470
+ // / Moves to the next mixing index
471
+ void next () {
472
+ stream_idx++;
473
+ }
474
+
464
475
protected:
465
476
Vector<RingBuffer<T> *> buffers{0 };
466
477
Vector<T> output{0 };
@@ -473,6 +484,7 @@ class OutputMixer : public Print {
473
484
int output_count;
474
485
MemoryType memory_type;
475
486
void *p_memory = nullptr ;
487
+ bool is_auto_index = true ;
476
488
477
489
void update_total_weights () {
478
490
total_weights = 0.0 ;
0 commit comments