From af33f198e7cc7ce260d0d8e16de28609c6f4942f Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 16 Feb 2024 09:53:46 -0500 Subject: [PATCH] Reset I/O buffers when we re-init effects (#990) My bet is this also addresses #989 startup poly problem --- src/FX.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/FX.h b/src/FX.h index c62d2f2..41c96a8 100644 --- a/src/FX.h +++ b/src/FX.h @@ -642,16 +642,34 @@ struct FX : modules::XTModule, sst::rackhelpers::module_connector::NeighborConne { if (c == -1) { + // Re-initialize everything surge_effect->init(); halfbandIN.reset(); for (const auto &s : surge_effect_poly) if (s) + { s->init(); + } + + // We are just starting over so clear all the buffers + bufferPos = 0; + + memset(processedL, 0, sizeof(float) * MAX_POLY * BLOCK_SIZE); + memset(processedR, 0, sizeof(float) * MAX_POLY * BLOCK_SIZE); + memset(bufferL, 0, sizeof(float) * MAX_POLY * BLOCK_SIZE); + memset(bufferR, 0, sizeof(float) * MAX_POLY * BLOCK_SIZE); } else { // poly nan case surge_effect_poly[c]->init(); + + // Other buffers are fine. Just clear mine. And don't change + // pos since the zeros wont hurt me. + memset(processedL[c], 0, sizeof(float) * BLOCK_SIZE); + memset(processedR[c], 0, sizeof(float) * BLOCK_SIZE); + memset(bufferL[c], 0, sizeof(float) * BLOCK_SIZE); + memset(bufferR[c], 0, sizeof(float) * BLOCK_SIZE); } }