Remove unwanted sliding between notes in synth

Hello:
I am making a synthesizer, and am following this method of adding voices:

// constructor of PluginProcessor class
for (int i = 0; i < 32; i++)
{
    synth.addSound(new SynthSound());
    synth.addVoice(new SynthVoice());
}

This seems to add a sort of portamento effect when switching between two notes. Is there something that I can add to this to avoid said note sliding, or is there something wrong in my SynthVoice class?
For Reference, here’s the implementation of my voice’s renderNextBlock() minus the processing of my custom DSP modules.

void SynthVoice::renderNextBlock(juce::AudioBuffer<float>& outputBuffer, int startSamples, int numSamples)
{
    jassert(isPrepared);
    if(!isVoiceActive())
        return;
    synthBuffer.setSize(outputBuffer.getNumChannels(), numSamples, false, false, true);
    // ...
    synthBuffer.clear();
    
    // ...

    for (int channel = 0; channel < outputBuffer.getNumChannels(); ++channel)
    {
        outputBuffer.addFrom(channel, startSamples, synthBuffer, channel, 0, numSamples);
        // ...
    }
}
}

Any help is much appreciated.

Are you using the JUCE DSP oscillator class by any chance? By default there’s a ramp time that isn’t instant. setFrequency() has an optional second argument to force the change instantly.

That was exactly what was needed…thanks for the help!

1 Like

Nice! Glad I could help!