Synthesiser Voice "...only 'protected' voices" error


I’ve been working on my synthesizer implementation, and every time I test with a midi controller I get this error

// We've only got "protected" voices now: lowest note takes priority
jassert (low != nullptr);

I see that the error traces back to my implementation of renderNextBlock(), so I went back and copied a friend’s synth implementation, and keep getting the same error though I’ve copied everything line for line. Is there something I’ve overlooked?

Here is my current renderNextBlock() implementation

while (--numSamples >= 0)
        const float currentSample = myOsc.sinewave(frequency) * level;
        for (int i = outputBuffer.getNumChannels(); --i >=0;)
        outputBuffer.addSample(i, startSample, currentSample);

Thanks for any help.


I found it…I was casting Synthesiser Voice rather than Synthesiser Sound in my canPlaySound() method.