Best way for deferred interface <> realtime script communication
-
What would be the best way to set up communication between the interface script and the realtime MIDI script?
Let's say I have an interface where the users can set parameters and these alter the realtime behavior. Also, these parameters can be assigned to CCs in a separate panel, and would need to be updated appropriately.
So, what's the best approach? Declaring the controls as global? Is accessing the values from the realtime MIDI script slow in that case?
Does the realtime script then set its own global variable that is referenced in the oncontrol callback in the interface script, along with Control.changed() so that the callback gets triggered?
I read the example in https://forum.hise.audio/topic/79/scripting-best-practices but that looks like it's setting up the interface twice for all the controls that affect realtime.
Should I set up these controls in the realtime script, then? I'm not sure I like the idea as I wanna do custom paint routines with fancy animations and that stuff belongs in the worker thread.
Thanks.
-
it's setting up the interface twice for all the controls that affect realtime.
No, it just separates the UI script from the logic script and treats the logic script like a "native" module.
It's still the recommended way (unless you need to pass on complex data that can't be described as a float number) - on the first look it looks like redundant duplication, but it keeps the things modularized and consistent with talking to other modules.
HiseSnippet 931.3oc0VssaSjCF1NstKI.UKGd.FwUoRkpDnvtRHDcaZKJBZIhof3NjqGOMVwi8nwd51.h61mm8U.dF12f8p818MX2e6Yljo6NpTBfDjKhh+O98e3K1ixzLtwnyP31GNMkivWgDNUYGOXLUnPC2AgWkrO0X4YAEh1dZJ0X3QHLdoG6DfauLx+4uez1TIUw3yEgPuTKX7mJRD14RGs0SDR4dzH9ghjZVu4VCYZ0.sTmC3YIROTJkMgdL+.pyrVDDdkciDVcVnkZ4Fvls0QSCGq+UUg8uTXDGI4tC8QgPfJDiFLVHiFUUqFDBu7n4U9REU9MI6KhDyjOuC7idEAy8ndO.257fT+OAH0pFjVt.RWiDxxDo14Zb34xjgJXfDSgVccnTXKB+Ax.MXfxtQBcBeuL3vLG5d+d8VO.9ZsGDmqXVgVEnUGns7mo5tVm21ocm20I3+pJNtQctzjokRdVipcS2ryywtp7ji3YqGbBUlymYHT9msmtxEqmxJp5ZFpUCUB6yR4km2SKib8J2u++S.TYaClE3RDBlZ8ShUKmDgRQDOCIff7CjmnzG0G4Ae8cdzKFtC0RqBCDQHKo7LqvUL3c3m.bhhAbaxNbyDqN0aaRpV4xOd0OZROEgI3+.x0T2O9K3GF6TWKYEuAnDQTjjORaDtVdMR56AtbZn3MdD+1a96O9Oeyu8nj57XDJgdZcZsIONVbpm.FKjIFKfogI.uDguN4EFdPDOllKsAlIPbjB0DdzgZu8oUs2g.1uQY4LmI0GX3Y.4FVNcFbUx9Sep9XAyWBnKJeno31.unkASfUDiEV2xBlD7vfJZBMJxkwt2pV5u05A.QAnIc5zQnfhhWeAtlgU6xrpwW80YPoQK4ajlIT1tExePm2AAsJ2GysyF7mE.qsgwoyG8ATo7H3OC61TpgH98CWl7khK+YyeO611WAV7Utfo1ykQUbYz2pb4F3ivMi5nbI0d1qKcuKnTgCv04htKhTPgLsNn9DtCs24dG5EEhWiLRXYiaFisZ.itqm+JfwxWdbUxtwwblcN.Wlr2qVzmY7QR+y04Vg538ovn2s4cPdRH7fKFGxtRwkNNJtkiMUbtW0RYHWE4O7OvmRk8cmwkJ6WoDV5XY5WyJ3ft21bIuD.SJ+S4ZCuoDNGL6xSBo2F8bK5hWyXtx+18Qnl84NKfO2cA7YyEvm6s.9b+EvmeZA74mOWebuv8Wxs5jB5.HXzt9+9Ci2UQgMK+VH5eAR5kWXC
-
Alright, so you're assigning it in the Property Editor. How to do it with scripts that allows for clearer code instead of relying on definition order? I saw there was a commit the other day,
555cd89 - - added virtual method to get the parameter index by ID
. Does it address this?Btw. I noticed a strange behavior of the Property Editor and widget selection when working with two scripts. This can be replicated in your snippet.
I opened an issue on GitHub, the forum won't let me upload the gif here (too big).