PLUG'N SCRIPT
rapid plugin development
Tutorial
DSP
KUIML
How-to
Scripts
Main functions
  • processBlock
  • processSample
  • updateInputParameters
  • updateInputParametersForBlock
  • computeOutputData
Additional
  • initialize
  • shutdown
  • reset
  • getTailSize
  • getLatency
  • wantSilence
DSPwantSilence
January 28, 2022

wantSilence

Reports to the DAW whether our plugin wants to process silent blocks (undocumented function, plugin-format specific).

  1. bool wantSilence() {
  2. return true;
  3. }

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.

  1. bool blockIsSilent = false; // global flag
  2.  
  3. // function is called when the upcoming block is silent
  4. bool wantSilence() {
  5. blockIsSilent = true; // flag to remember
  6. return true; // yes, we want to process silent blocks
  7. }
  8.  
  9. // main processing function
  10. void processBlock(BlockData& data) {
  11. // do some processing for both silent and non-silent blocks
  12. ....
  13.  
  14. if (blockIsSilent == false) {
  15. // do regular processing for non-silent blocks
  16. ...
  17. }
  18.  
  19. blockIsSilent = false; // reset the flag for the next block
  20. }

Comments

2020 © Plug'n Script and KUIML by Blue Cat Audio  |  Site by LetiMix