processSample
This function can be used instead of processBlock for simple audio processing.
- // keep gain here (from 0 to 1 to decrease, >1 to increase level)
- double gain = 0.5;
- // per-sample processing all channels
- for(uint channel=0;channel<audioInputsCount;channel++) {
- ioSample[channel]*=gain;
- }
- }
The advantage of this processSample function is that it doesn't require you to write an additional cycle to process samples in block.
Another advantage is that when processSample is used, updateInputParameters is called for every sample with auto-updated parameter value (of course, only when input parameters are changing). In comparison, when using processBlock, you get parameter values for start and end of the block, and (if needed) you have to interpolate them manually for each sample inside the block.
If this function is used, then processBlock is ignored.
The main disadvantage is that you cannot process MIDI using processSample. Also sometimes it can be more efficient to process data in blocks and to have more control.
You can see another example in "How to make a simple low-cut filter".