Inefficieny with Synthesiser class? (renderNextBlock constantly being called)

Hi, I’m developing a synth plugin and I’m still figuring out what structures I will use to build it. At first I decided to use the MPESynthesiser as it seemed to have some nice features. Then for curiostiy I refactored my code to use the legacy Synthesiser class. However I have noticed that even when I do not press any key on my MIDI controller, renderNextBlock is called on all my voices, meaning that at idle, with no voices playing, Ableton registers a CPU usage of 3% (when I build for release):
image
Is there a way to make this more efficient by only calling renderNextBlock if a voice is currently active?
The MPESythesiser does not call renderNextBlock until you actually press a key.

*I have made sure to call clear current note in renderNextBlock using this code:

int e = 0;
iterate([&](unsigned i)
    {
        if (envelopes[i].isFinshed())
            e++;
    });

if (e == NUMBER_OF_OSCILLATORS)
{
    clearCurrentNote();
}

It just checks if all the envelopes have finished and if so then it calls clearCurrentNote()

I simply do the following, not sure if it is the best way, but it works.

void renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples)
  {		
	if (isVoiceActive ())
      {
          // Do magic stuff here......
      }
  }
1 Like