Skip to content

Commit

Permalink
Reset I/O buffers when we re-init effects
Browse files Browse the repository at this point in the history
My bet is this also addresses surge-synthesizer#989 startup poly problem
  • Loading branch information
baconpaul committed Feb 16, 2024
1 parent 66e31c2 commit 6b05268
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 6b05268

Please sign in to comment.