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


#1

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);
        
        
        ++startSample;
    }

Thanks for any help.


#2

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