MPESynthesiserBase::renderNextBlock bug or expected behaviour?

I’m having an issue where MPESynthesiserBase is calling noteStarted multiple times for each note on.

Function looks like this:

    void renderNextBlock (AudioBuffer<floatType>& outputAudio,
                          const MidiBuffer& inputMidi,
                          int startSample,
                          int numSamples)

Comment says this:

This will chop up the AudioBuffer into subBlock
        pieces separated by events in the MIDI buffer, and then call
        processNextSubBlock on each one of them.

I would expect that if I called it like such:
renderNextBlock (audio, midi, 0, 32)
That it would ONLY process midi events with sample numbers between 0 and 32. However it processes midi events from startSample all the way to the end of the midi buffer. Also it says it’ll call processNextSubBlock but no such function exists.

I want to process my audio in blocks no bigger than 32 and update my modulation in between.

So my main loop looks like this:

    while (todo > 0)
    {
        int thisBlock = std::min (todo, 32);

        updateParams (thisBlock);
        renderNextBlock (buffer, midi, pos, thisBlock);
        
        pos += thisBlock;
        todo -= thisBlock;
    }

Let’s say the host is giving me a block size of 512 and there is a note on at 511. This will cause noteStarted to be called 16 times. That doesn’t seem correct.

If this is the expected behaviour then the documentation needs to be made clear that where should be no extra midi events in the buffer >= startSample + numSamples

Thanks for raising this, the observed behaviour was indeed a bug. The issue should be resolved by this commit:

1 Like

Thank you