I have a PnS script in which there is a one-element inputStrings defined. If I put a value in the corresponding screen field and save and close my DAW project (Cubase 8.0) and reload the project, the value previously placed in the field is shown on the screen. All well and good - just the way I would expect things to work.
However, if I read that field (assign it to a string and print that string) when in initialize(), inputStrings[0] appears to be empty. If I access the valud of inputStrings[0] again in the first invocation of updateInputParametersForBlock, the value shown on the screen is returned as expected.
Am I doing something wrong or is this not behaving as it should?
Plug'n'Script Bug?
-
Blue Cat Audio Blue Cat Audio https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=39981
- KVRAF
- 6349 posts since 8 Sep, 2004 from Paris (France)
The initialize function is called before the actual parameters and strings are created. You can even change the definition of the exposed parameters and strings in it (in case it depends on the number of audio channels or sample rate). So it is expected that the values are not initialized by the audio engine at this stage.
updateInputParametersForBlock or updateInputParameters is the place where input data is set by the audio engine, so that's where you can read the actual state of the variables as set by the GUI or automation.
Can you maybe tell us what you are trying to achieve so that we can help?
updateInputParametersForBlock or updateInputParameters is the place where input data is set by the audio engine, so that's where you can read the actual state of the variables as set by the GUI or automation.
Can you maybe tell us what you are trying to achieve so that we can help?
-
- KVRAF
- Topic Starter
- 1759 posts since 11 Nov, 2009 from Northern CA
Simple. I have a plug-in that reads a control file in a specific directory. The file name has a default name that's to be used if none is specified in the UI field. If there is a name given in the override field in the UI, the plug-in needs to read that control file instead. Since the control file governs what happens even in the first call to processBlock, I need to read that file before anything else happens.Blue Cat Audio wrote:Can you maybe tell us what you are trying to achieve so that we can help?
I could introduce some trickery to check if the control file hasn't yet been processed when I get to the first process block call, but reading and parsing the control file results in some slightly sluggish processing (like reading several short sample files), so I'd like to keep that out of processBlock where optimal efficiency is desirable.
Does updateInputParametersForBlock get called upon the value being written into an inputStrings slot some time after initialize has been called? I could defer reading and parsing the control file until that point, if so.
Thanks for any suggestions.
-
Blue Cat Audio Blue Cat Audio https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=39981
- KVRAF
- 6349 posts since 8 Sep, 2004 from Paris (France)
updateInputParametersForBlock or updateInputParameters is indeed guaranteed to be called before any block is processed, so that your internal variables are up to date.