updateInputParametersForBlock
This function does almost the same as updateInputParameters.
- // called when input parameters change
- // recalculate gain
- gain = pow(10, inputParameters[0]/20);
- // get some transport info
- if(@transport != null) {
- is_playing = transport.isPlaying;
- }
- }
The differences with updateInputParameters are:
- Even when using processSample, this function is called no more than once per block (updateInputParameters can be called once per sample together with processSample).
- updateInputParametersForBlock also received transport information, and is additionally called when tempo or time signature changes.
Transport info available
- // is playing or recording
- transport.isPlaying // (bool) is host application playing
- transport.isRecording // (bool) is host application recording
- // tempo and time signature
- transport.bpm // (double) current tempo (beats per minute)
- transport.timeSigTop // (uint) upper value of time signature (3 for 3/4)
- transport.timeSigBottom // (uint) lower value of time signature (4 for 3/4)
- // position in song
- transport.positionInSamples // (int64) position in samples of the first sample of the current block since the beginning of the song
- transport.positionInQuarterNotes // (double) position in quarter notes of the first sample of the current block since the beginning of the song
- transport.positionInSeconds // (double) position in seconds of the first sample of the current block since the beginning of the song
- transport.currentMeasureDownBeat // (double) position in quarter notes of the first bar of the current measure
- // loop-related
- transport.isLooping // (bool) is host application in a loop
- transport.loopStart // (double) pos in quarter notes of the beginning of the loop
- transport.loopEnd // (double) position in quarter notes of the end of the loop
When to use which one
Use updateInputParameters with processSample, because you can get smooth param changes (see examples in "How to make a gain plugin" article).
However, if you need transport information, use updateInputParametersForBlock. By the way, you can use them both, it's fine.
If you're using processBlock (which gives you access to transport info as well), there's not much difference which one to use. In such case updateInputParameters we be also called once per block when input parameters change, and updateInputParametersForBlock will be additionally called when tempo or time signature changes.
How often it can be called?
While your input parameter is changing, updateInputParametersForBlock can be called as often as processBlock. So if you have a large buffer size (say 2048 samples), and sampleRate is 48000, then processBlock will be called 23-24 times per second, and so does updateInputParametersForBlock (and updateInputParameters as well in this case). So you will not get input parameters updates more than 23-24 times per second.
Another limiting factor may be the GUI speed. Even if the buffer size is small (say 128 samples with 48000 samplerate), so processBlock will be called 375 times per second, you still will hardly get 375 calls to updateInputParametersForBlock while turning a knob, because of GUI refresh time (SKIN attributes refresh_time_ms and refresh_priority).
Also keep in mind, that when parameter is changing in the GUI, it doesn't immediately change in DSP, it takes some time for DSP to retrieve it.