wantSilence
Reports to the DAW whether our plugin wants to process silent blocks (undocumented function, plugin-format specific).
- return true;
- }
This is how it works (tested with VST3 format): if the upcoming block of samples is totally silent (all zeroes) we first get a call to this function (wantSilence) asking us, whether we want to process that silent block or not.
If we return true, then next we'll get a call to the processBlock function as usual. If we return false, there will be no call to processBlock. This can save CPU when there's no audio.
If we want to process silent and non-silent blocks slighly differently, we can add a flag to remember the state of the upcoming block.
- bool blockIsSilent = false; // global flag
- // function is called when the upcoming block is silent
- blockIsSilent = true; // flag to remember
- return true; // yes, we want to process silent blocks
- }
- // main processing function
- // do some processing for both silent and non-silent blocks
- ....
- if (blockIsSilent == false) {
- // do regular processing for non-silent blocks
- ...
- }
- blockIsSilent = false; // reset the flag for the next block
- }