How to process every other buffer?

I want to make calculations only on particular buffers, for example every other, or every 20th buffer. Rest of the buffers should be processed without changes.

I am creating a plugin and modify buffer in

 processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages); 

function. How to do this?

You are aware, that there is no guarantee of a certain buffer size, so it will lead to arbitrary results if you rely on the number of buffers.

However to achieve this, just use a member variable:

void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override
    if (++sinceLastProcessing < 20)

    sinceLastProcessing = 0;
    // ...
    int sinceLastProcessing = 0;
1 Like