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
DSPupdateInputParametersForBlock
August 04, 2020

updateInputParametersForBlock

This function does almost the same as updateInputParameters. 

  1. // called when input parameters change
  2. void updateInputParametersForBlock(const TransportInfo@ transport) {
  3. // recalculate gain
  4. gain = pow(10, inputParameters[0]/20);
  5. // get some transport info
  6. if(@transport != null) {
  7. is_playing = transport.isPlaying;
  8. }
  9. }

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

  1. // is playing or recording
  2. transport.isPlaying // (bool) is host application playing
  3. transport.isRecording // (bool) is host application recording
  4.  
  5. // tempo and time signature
  6. transport.bpm // (double) current tempo (beats per minute)
  7. transport.timeSigTop // (uint) upper value of time signature (3 for 3/4)
  8. transport.timeSigBottom // (uint) lower value of time signature (4 for 3/4)
  9.  
  10. // position in song
  11. transport.positionInSamples // (int64) position in samples of the first sample of the current block since the beginning of the song
  12. transport.positionInQuarterNotes // (double) position in quarter notes of the first sample of the current block since the beginning of the song
  13. transport.positionInSeconds // (double) position in seconds of the first sample of the current block since the beginning of the song
  14. transport.currentMeasureDownBeat // (double) position in quarter notes of the first bar of the current measure
  15.  
  16. // loop-related
  17. transport.isLooping // (bool) is host application in a loop
  18. transport.loopStart // (double) pos in quarter notes of the beginning of the loop
  19. 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.
 


Comments

Please, authorize to view and post comments.

2020 - 2025 © Site by LetiMix · Donate  |  Plug'n Script and KUIML by Blue Cat Audio