Call a function after the plugin loaded
-
I need to call a function after the plugin loaded into the DAW. So am I making a mistake with below use? Or any more useful ideas?
Plugin performance is important for me, so do you think below usage can bring some trouble especially on the multi usage (let's say 30 instances) in the DAW project?
var startupSorter = Engine.createTimerObject(); startupSorter.setTimerCallback(function(t) { this.stopTimer(); myFunction(); }); startupSorter.startTimer(1000);
-
@harris-rosendahl What does the function do?
-
@d-healey The the plugin is loading with OpenGL is enabled by default. I don't want that. If the user wants, then he can enable it.
So I will store the OpenGL enabled status in a JSON object, it will be the main value, then while loading the plugin, I am using
Settings.setEnableOpenGL()
to control the OpenGL.I need a sanity check function to be executed after the plugin loaded to check whether if the user preference is equal to the current "Settings.isOpenGLEnabled" return value. But as I see, the plugin's "Settings.setEnableOpenGL()" value can be settled only after the plugin is loaded. Because of that I need this function to be executed after the loading.
By the way we can't check values inside the "GeneralSettings.xml" via scripting, right?
-
@harris-rosendahl If you add a custom settings floating tile the user can change the option there, and you should be able to set it to load disabled by default.
-
@d-healey Yes I've tried the FloatingTile, but unfortunately the plugin always load with "Yes" by default (I mean on the first plugin installation). And there isn't a "No" option by default.
So the user must deactivate it manually. I need the plugin is OpenGL disabled by default with the first installation because of the shitty OpenGL performance on some systems.
-
@harris-rosendahl What about if you set the floating tile to saveInPreset = true and save your project before exporting with the OpenGL option set to disabled?
-
@d-healey CustomSettings FT can't saved in a preset, I've tested it :/
Above timer object will always start 1 second after the plugin is loaded and then stop, right?
-
@harris-rosendahl what about using this flag:
HISE_USE_OPENGL_FOR_PLUGIN=0
? -
@ustk said in Call a function after the plugin loaded:
@harris-rosendahl what about using this flag:
HISE_USE_OPENGL_FOR_PLUGIN=0
?This time, OpenGL is completely disabled then :) And the user can't activate it if he wants. There is no middle way ahahah :D
I just need OpenGL is available according to the user demand, but disabled by default, that's it.
-
@harris-rosendahl said in Call a function after the plugin loaded:
I need to call a function after the plugin loaded into the DAW. So am I making a mistake with below use? Or any more useful ideas?
Plugin performance is important for me, so do you think below usage can bring some trouble especially on the multi usage (let's say 30 instances) in the DAW project?
var startupSorter = Engine.createTimerObject(); startupSorter.setTimerCallback(function(t) { this.stopTimer(); myFunction(); }); startupSorter.startTimer(1000);
In your timerCallback you have to switch places of myFunction() and this.stopTimer()
as you have it now the timer will stop before it reach your functionstartupSorter.setTimerCallback(function(t) { myFunction(); this.stopTimer(); });
-
@ulrik Oh, I see, thank you!
-
@ulrik said in Call a function after the plugin loaded:
In your timerCallback you have to switch places of myFunction() and this.stopTimer()
as you have it now the timer will stop before it reach your functionstartupSorter.setTimerCallback(function(t) { myFunction(); this.stopTimer(); });
Err, i'm not sure thats true.... the stopTimer call will stop subsequent calls to the timer - it wont stop execution of the current callback...
-
-
@ulrik No problem.
I think I found a bug,
Settings.isOpenGLEnabled()
returns alwaystrue
o the compiled plugin, but it works on Hise.If you set the OpenGL "No" on the CustomSettings FT,
GeneralSettings.xml
showsOPEN_GL="0"
when the plugin is closed, as it supposed to be. That's ok.But when you load the plugin again, even the OPEN_GL is set to 0 on the GeneralSettings.xml,
Settings.isOpenGLEnabled()
returns alwaystrue
.