Post init callback
-
I have need to trigger some components in my secondary scripts from my main interface script at init. The problem is the init function of the main script triggers before all of the other scripts are initialiased. My current solution is to use a timer in the main script to delay this action but this is imprecise.
A better way I think would be to have a post init callback that triggers after everything (not just the main script) is ready.
-
@d-healey That would be nice to have indeed...
In the waiting, what if you do the opposite? check from the secondary scripts the state of the interface script components?
Or even a script at the end of the "script chain", so it is the last one to be triggered and checks for everything that you need? I never tried such a thing...
-
@d-healey It should work. I just tested and the component's CBs are called before the init of the next script begins...
-
@ustk said in Post init callback:
what if you do the opposite? check from the secondary scripts the state of the interface script components?
The timer is fine for me for now until we have a proper solution.
-
@d-healey I have kind of the same issue with the samplerate. It is not ready at init so I use a timer that sets all the depending variables.
Not a neat solution because I cannot use const variables since they cannot be updated later. -
@d-healey said in Post init callback:
The timer is fine for me for now until we have a proper solution.
Problem with the timer. If you reopen a saved session in the DAW it will run the timer and reload the default preset. I think the same problem will exist with a post init callback too...
-
Did this ever get implemented? I seem to recall @Christoph posting something about it recently but I cant find anything with a forum search.
-
@Lindon OK back at this poiint again -- did we ever get anywhere?
-
@Lindon
You could load a default preset when you load the plug-in. Create a Preset hander and set the post load callback:UserPresetHandler.setPostCallback(var presetPostCallback)
Maybe this works?
All the best
Oli -
@Oli-Ullmann well even if it does it will p**s off the user base - every time they start the plugin - like in loading an already saved project in their DAW - we get the wrong preset loaded..or at least teh risk of that.
No what we need here is a post init call back.
-
@Lindon
Perhaps you could useif(Engine.getCurrentUserPresetName() != "")
to
check whether a preset is loaded. If not, load the Init preset.Regardless of whether a preset is loaded by the saved DAW project or by your script, the post callback is always executed.
It is even much easier!
In the HISE settings you can define exactly this behavior under “Default User Preset”. Then you don't even have to script!
All the best
Oli -
@Oli-Ullmann said in Post init callback:
Perhaps you could use if(Engine.getCurrentUserPresetName() != "") to
check whether a preset is loaded. If not, load the Init preset.Might be able to do it using this - https://docs.hise.audio/scripting/scripting-api/userpresethandler/index.html#isinternalpresetload
-
really none of this is much use, I have a panel with some data in it - it might be empty it might not.
if its not empty I want to draw the path it describes in a panel, on init. But on init (no matter the preset you are loading) the data panel load takes longer than the init processing AND any post-load processing(so anything in your post-preset callback)....so it never draws itself...
What I'm looking for is a "proper" post init call back that accounts for any panel data load scenario...
-
@Lindon said in Post init callback:
the data panel load takes longer than the init
Could you provide more detail about what you're doing?
-
@d-healey sure:
See that grey circle inside the XY pad? Thats a path, its held in a Panel.data object, when I load this preset the data is passed to an array and from there it gets drawn correctly in the paint routine..., but on init - it all goes too fast and it doesnt get drawn - the array holding the Panel data object = 0.....
-
@Lindon What's the reason for storing this in the panel's data object? And why do you need a path to draw a circle, I assume there is more going on?
-
@d-healey said in Post init callback:
@Lindon What's the reason for storing this in the panel's data object? And why do you need a path to draw a circle, I assume there is more going on?
So its not always a circle its whatever the user draws (see the Record button in there?)- this is just one of the pre-loadable shapes.... when the user hits Play the XY pad follows this path and this modulates volume in the voices....
Every preset needs to save its own "XY path shape".
I would add an video showing you - but the forum wont let me load mp4 files.
-
@Lindon said in Post init callback:
Every preset needs to save its own "XY path shape".
Ah I understand now. Are you able to store the path as a base64 string? Perhaps that will speed up the loading. Do you have some method to be able to test when the loading is complete?
-
@d-healey said in Post init callback:
@Lindon said in Post init callback:
Every preset needs to save its own "XY path shape".
Ah I understand now. Are you able to store the path as a base64 string? Perhaps that will speed up the loading. Do you have some method to be able to test when the loading is complete?
not really and no in that order - especially the last bit - thats where the problem is - there is no notification that the data is loaded, if there was a callback for this I could do the repaint then...
-
@Lindon Can you make a minimal snippet I can play with? Something that just draws one of these stored paths on a panel and takes too long to load.