As part of a MPE Synthesiser I am building I encountered a strange behavior when clearing voices.
I am finding the synth clears the note without me calling clearCurrentNote()
. More over, I get audible clicks when I do call the clearCurrentNote()
method.
Inspect below how I don’t call it in my renderNextBlock()
or noteStopped()
methods.
void renderNextBlock(juce::AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override
{
auto blockWrite = outputBuffer.getArrayOfWritePointers();
for (int sampleIndex = startSample; sampleIndex < numSamples; ++sampleIndex)
{
if (env1.isActive())
{
auto sample = (osc1.getNextSample() + osc2.getNextSample()) * env1.getCurrentValue();
for (int channel = 0; channel < outputBuffer.getNumChannels(); channel++)
{
blockWrite[channel][sampleIndex] += sample * 0.3f;
}
}
else
{
// Works with this commented out. Actually removes audible clicks
// clearCurrentNote();
break;
}
}
}
// Notice I am not calling it here either
void noteStopped(bool allowTailOff) override
{
env1.noteOff();
}
So I am just wondering why this sounds right? Removing the clearCurrentNote()
method seems to solve all problems