Skip to content

Commit

Permalink
Fix popping on increase of polyphony channels (EvenVCO)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemmer committed Feb 3, 2022
1 parent db5be84 commit 76822a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,8 @@
* Added Noise Plethora
* Chopping Kinky upgraded to use improved DC blocker
* Added bypass for Spring Reverb
* Minor fix for Kickall trigger
* Bugfix: Kickall trigger input and button can now work independently
* Bugfix: remove pop on number of polyphony engines change

## v2.0.0
* update to Rack 2 API (added tooltips, bypass, removed boilerplate etc)
Expand Down
22 changes: 12 additions & 10 deletions src/EvenVCO.cpp
Expand Up @@ -120,8 +120,10 @@ struct EvenVCO : Module {
phase[c / 4] += deltaPhase[c / 4];
}

// the next block can't be done with SIMD instructions:
for (int c = 0; c < channels; c++) {
// the next block can't be done with SIMD instructions, but should at least be completed with
// blocks of 4 (otherwise popping artfifacts are generated from invalid phase/oldPhase/deltaPhase)
int channelsRoundedUpNearestFour = std::ceil(channels / 4.f) * 4;
for (int c = 0; c < channelsRoundedUpNearestFour; c++) {

if (oldPhase[c / 4].s[c % 4] < 0.5 && phase[c / 4].s[c % 4] >= 0.5) {
float crossing = -(phase[c / 4].s[c % 4] - 0.5) / deltaPhase[c / 4].s[c % 4];
Expand Down Expand Up @@ -161,20 +163,13 @@ struct EvenVCO : Module {
float_4 square[4] = {};
float_4 triOut[4] = {};

for (int c = 0; c < channels; c++) {
for (int c = 0; c < channelsRoundedUpNearestFour; c++) {
triSquareMinBlepOut[c / 4].s[c % 4] = triSquareMinBlep[c].process();
doubleSawMinBlepOut[c / 4].s[c % 4] = doubleSawMinBlep[c].process();
sawMinBlepOut[c / 4].s[c % 4] = sawMinBlep[c].process();
squareMinBlepOut[c / 4].s[c % 4] = squareMinBlep[c].process();
}

// Outputs
outputs[TRI_OUTPUT].setChannels(channels);
outputs[SINE_OUTPUT].setChannels(channels);
outputs[EVEN_OUTPUT].setChannels(channels);
outputs[SAW_OUTPUT].setChannels(channels);
outputs[SQUARE_OUTPUT].setChannels(channels);

for (int c = 0; c < channels; c += 4) {

triSquare[c / 4] = simd::ifelse((phase[c / 4] < 0.5f), -1.f, +1.f);
Expand Down Expand Up @@ -208,6 +203,13 @@ struct EvenVCO : Module {
outputs[SAW_OUTPUT].setVoltageSimd(saw[c / 4], c);
outputs[SQUARE_OUTPUT].setVoltageSimd(square[c / 4], c);
}

// Outputs
outputs[TRI_OUTPUT].setChannels(channels);
outputs[SINE_OUTPUT].setChannels(channels);
outputs[EVEN_OUTPUT].setChannels(channels);
outputs[SAW_OUTPUT].setChannels(channels);
outputs[SQUARE_OUTPUT].setChannels(channels);
}
};

Expand Down

0 comments on commit 76822a2

Please sign in to comment.