How do I load a midi script programmatically?
-
@rglides I don't think that is relevant really. I'm wanting to load a file on disk into a midi script processor. I'm not looking to clear a midi player. Thanks though!
-
@Orvillain I thought the issue was needing to load an empty (or predefined) file into the midi player via script rather than having to do it manually, sorry I totally misunderstood
-
The reference path doesn't need to include "/scripts/" as
{PROJECT_FOLDER}
will automatically go to the scripts folder.Does
midi_processor
contain an index? -
@d-healey I bet you that's what it is! I bet it is looking inside:
PROJECT_FOLDER/Scripts/Scripts/ScriptProcessors/midi_processor.jsIf the project folder flag automatically includes the scripts sub folder.
I will check and get back to you. Yes, midi_processor does have an index assigned to it.
-
@Orvillain said in How do I load a midi script programmatically?:
Yes, midi_processor does have an index assigned to it.
But is midi_processor itself an index? The documentation your posted indicates that first parameter is a buildIndex, and you're passing midi_processor.
-
@d-healey Yes, because builder.create(blahblahblah) returns the build index. So midi_processor is the build index. Variable name could be clearer, I grant you.
-
There is DEFINITELY something funky with this. If I start a new project, add a sampler, add a midi script processor to it, and then right-click the script processor in the module tree, choose 'connect to external script' and choose my script, it also fails.
But then if I unload the external script, all of a sudden my test variable is then right there in the onInit method.
If I write a script in HISE manually, right-click and save as a new file... and then try and connect to that file... again... HISE fails to connect....
If I then disconnect, the new script is there.
@Christoph-Hart I'm 100% convinced this is a bug.
-
I made a video showing what happens when you just try to connect to an external script manually, not even using code.
It seems to be broken.
-
@Orvillain That's the correct behaviour. Once you're connected to an external script you lose those tabs. The idea is if it's external you shouldn't be editing it in HISE - although you still can in the main code editor but I think that's a more recent feature.
I made a video about this several years ago:
-
@d-healey Riiiiight. That seems very odd to me. HISE could at least draw in the scripts and make it read only, or otherwise indicate success. Because it looks broken to me, and is the same "symptom" as what I see when trying to connect a script in code.
The only difference being when I try to connect a script in code, I get an error that says "onControl could not be parsed!"
Hmmmmm. I guess I need to dig into this some more. Your tip about removing the "Scripts" folder from the path was a good one, but does not seem to have made any difference.
But now that you've said what you've said... I'm wondering, how do I even confirm the script has been attached successfully? It looks exactly the same in the actual project:
And alllllll this time, I've been assuming it didn't work properly because of how empty it looks, and also because of the parse error in the log.
-
@Orvillain If you add controls to your scripts interface they will show up in that blank area.
-
Okay. I've gotten it to work by replacing the forward slash with a backslash. This is on Windows. I don't know if MacOS will cope with that???
I was reasonably sure that even on Windows this should work?? It works for a bunch of other things, iirc.
-
@Orvillain you are going to have to use different separators based on the OS in question
fwd slash for mac os backslash for windows: -
@Lindon Thanks!
Really sorry for the n00b question here. It was just boggling my mind, and I was making it a lot more complicated than it needed to be.
-
@Lindon said in How do I load a midi script programmatically?:
you are going to have to use different separators based on the OS in question
fwd slash for mac os backslash for windows:You should be able to use the same on all OS and HISE will handle it. I think the issue here is you don't need to put a slash of any kind after
{PROJECT_FOLDER}
because that wildcard includes a slash. -
@d-healey said in How do I load a midi script programmatically?:
@Lindon said in How do I load a midi script programmatically?:
you are going to have to use different separators based on the OS in question
fwd slash for mac os backslash for windows:You should be able to use the same on all OS and HISE will handle it. I think the issue here is you don't need to put a slash of any kind after
{PROJECT_FOLDER}
because that wildcard includes a slash.You should, but my experience is you cant...
-
@Lindon How do you include files or fonts?
I do this and it works on all systems
Engine.loadFontAs("{PROJECT_FOLDER}Fonts/Text/Inter-Regular.ttf", "regular");
-
@d-healey I do what i've always done and put the font in the images folder and call this:
Engine.loadFontAs("{PROJECT_FOLDER}DIN Alternate Bold.otf", "DIN Alternate");
works everywhere.
Where it doesnt work is if you want to declare some sub-folder path i.e.
{PROJECTS}\mysub\yoursub\afile.ext
so its simple to work around:
// on init const var WINDOWS = "WIN"; const var MAC = "OSX"; const var OS = Engine.getOS(); //elsewhere... if(OS == WINDOWS) { theLoopPlayers[pos].setFile(LP_LoopFileFolder + "\\"+ component.get("text") + ".wav"); }else{ theLoopPlayers[pos].setFile(LP_LoopFileFolder + "/"+ component.get("text") + ".wav"); };
You of course will also want to check for Linux...
-
@Lindon said in How do I load a midi script programmatically?:
{PROJECTS}\mysub\yoursub\afile.ext
You don't need a slash after the wildcard, and if you use forward slashes only it will work on all systems. Don't know about the lopp player though.
-
@d-healey said in How do I load a midi script programmatically?:
@Lindon said in How do I load a midi script programmatically?:
{PROJECTS}\mysub\yoursub\afile.ext
You don't need a slash after the wildcard, and if you use forward slashes only it will work on all systems. Don't know about the lopp player though.
yeah that might work for you but as I say its at the very least unreliable for me, it might be cases of paths without {PROJECT_FOLDER} in them