Q: Does HISE still split included modules?
-
I read from this post that when all five functions are defined within a script, HISE splits the file and place the callback into their own tabs.
I wrote a test file including only the following:
// test.js Console.print("init"); function onNoteOn() { Console.print("noteOn"); } function onNoteOff() { Console.print("noteOff"); } function onController() { Console.print("controller"); } function onTimer() { Console.print("timer"); } function onControl(number, value) { Console.print("control"); }
I tried to import this file, and no matter where I import this with
include("test.js")
, I only get feedback from the tab which I import from plus onInit. So apparently HISE is not splitting the file into tabs.
Am I missing something? -
HISE splits the file and place the callback into their own tabs.
That doesn't happen when using includes. That happens when you replace a script with one on the clipboard by right clicking in the script editor and selecting Load script from clipboard.
-
@d-healey I see! Thank you.
A question then,
If I want to apply the same behavior to multiple processors, with only difference in the value of variable, what's the best way to do so without hardcoding everything? -
Could you describe what you're trying to achieve in more details so I can best advise a suitable approach?
-
@d-healey I'm trying to build a guitar strumming library where each fret is sampled on each string, and each string is triggered with a different MIDI channel.
So each string has similar behavior, except that each string has its own boolean variable to detect whether to play muted sample.
The boolean is latched with a dedicated CC or Key, all notes played during the latch is muted. So I need a variable to save whether it's open or muted, and use that variable in an if clause.I just found out about the ability to connect to an external script, are variables declared in the external script stay local to each processor that uses it?
-
@RCJacH Oh you're doing something fun. I spent several months of 2019 working on a still unfinished guitar strumming engine. :D
When you include a script it's the same as if you've copied/pasted the script directly in to the MIDI processor's on init callback. So yes, each one is independent. You should use a namespace in your external script too so that a) you get access to more reg variables and b) it's easier to see where various function calls are coming from.
If you edit the external script though those changes will be reflected wherever you have included it.