Run Script In Expansion
-
@d-healey My preset browser is based on a custom file structure in the user presets folder and thered be subfolders that I'd need to manually add to the user presets folder, right? or will it just create the subfolders if there are none and add presets if there are none? And yeah forgot to mention the file browser part too. how would I call a script in the expansion though? Do i use includes()?
-
I'd need to manually add to the user presets folder, right? or will it just create the subfolders if there are none and add presets
No idea, see what happens with the expansion installer. If it doesn't do what you want then we can work on it.
And yeah forgot to mention the file browser part too. how would I call a script in the expansion though? Do i use includes()?
You don't need to call it from the expansion. You're calling it from your player/installer in order to install the expansion.
-
@d-healey huh, could you give me an example?
-
I assume you have a button in your player called something like
btnInstallExpansion
When the user clicks this button you show a file browser and allow them to select the hr file.
Now that you have the file you can call the
installExpansionFromPackage
functionOnce the expansion has been installed you can call
Expansion.rebuildUserPresets()
although I'm not sure if this is necessary. -
@d-healey got you! But I’m also trying to do some other things with the main plugin for each expansion, for example my samplemap swapping. Basically, I have three samplers and for each sampler, you can mix and match samplemaps from all the expansions the user has. I’ve made this browser for each sampler that lets you select samplemaps with two viewports, one viewport for tags and categories (All, Pad, Chord, Pluck) and the second (with a label to search the viewport) for seeing the available samplemaps and selecting them to change the samplemap for that layer. To accomplish this, I’ve set made an object which has multiple objects inside (these are the tags and categories). In those objects, I’ve put in an object for each samplemap entry. So this object system acts as a file system where the objects are kind of the directories. (Is this a good system, first thing to come in mind to try, but I feel like there may be a better one) Basically, each expansion I add would come with a set amount of samplemaps and there would need to be a script which pushes the samplemap objects into the main object if that makes any sense. To do this, wouldn’t I need to somehow run the script after installing from the hr1 package?
-
@Casmat I'm not sure it's possible to load sample maps from multiple expansions since only one expansion can be loaded at a time.
-
@d-healey Ohhhhhh noooo… that’s a major problem for me, since the plugin is heavily reliant on being able to mix and match said samplemaps, is there a workaround to this or a fix I can make?
-
@Casmat Try it first, because I could be wrong. I haven't used regular expansions for quite a while.
But if it doesn't work I think the solution would be to include all the sample maps in the main plugin. There might be another solution but I can't think of one at the moment.
-
@d-healey yeah, just tried it, the samplemap from the other expansion when the sampler is clicked on turns pink/purple and no sound is outputted, don’t know what it means though
-
@d-healey yeah, hopefully the samples aren’t tied to it as well.. so id need to make a script which copies the samplemap in the expansion and put it into the main samplemap folder?
-
@d-healey said in Run Script In Expansion:
@Casmat I'm not sure it's possible to load sample maps from multiple expansions since only one expansion can be loaded at a time.
Yes you can - just refer to the expansion in the load - you can combine any sample map from any expansion with any other...
-
Ok so how I handle expansions;
- std expansion folder structure
- Samples all get put into the AppData LinkFile location
2.a All expansion presets get put in the User Presets folder - A custom piece of json that ships with each expansion - read by the plugin on init - that says the name of the sample map - and which expansion its in (as well as some sound tags for a tag-based browser - but that's entirely optional.
- when the user selects a sound from the browser - look up its expansion and load it...
TheSamplers[pos].loadSampleMap("{EXP::" + vox.VoiceLocation +"}" + vox.VoiceMapName);
All of this is installed using a simple set of zip files - so I dont use the "std" expansion hxi system at all...
-
Yes you can - just refer to the expansion in the load - you can combine any sample map from any expansion with any other...
This is only true if you're using regular expansions - if you're running in Full Instrument Expansion mode, then the expansions become encapsulated entities that can't load content from other expansions.
-
and put it into the main samplemap folder
There is no sample map folder for compiled projects. The sample maps are embedded in the binary or the expansions. Lindon's solution is the way to go.
You can simplify it a little bit though by using the
getWildcardReference
function. -
@Lindon @d-healey @Christoph-Hart thanks guys! Makes sense to me! Just a couple questions:
-
How do I get to the linkfile location in appdata? Is it just
FileSystem.getFolder(AppData).getChildFile(LinkFile)
-
Yup, I'm planning on putting a js script file in each of my expansions, so How would I run the actual script file? do we use include() to run it, and if so, how do I get the name of the expansion to put in the include function?
-
So if i'm understanding correctly, the samples getting put in the appdata and expansion presets require some code, so do we put the code on the main plugin script or the script in the expansion folder?
-
@Christoph-Hart This is only true if you're using regular expansions - if you're running in Full Instrument Expansion mode, then the expansions become encapsulated entities that can't load content from other expansions.
So if this is the case, then why does my system right now not work? What does it mean when the samplemaps turn pink in the sampler?
- So I see that the best way to go about this is via a zip file, but of course, there isn't any protection methods implemented for zips. Sooo, how do you guys suggest copy protecting this whole system?
Thanks again!
-
-
-
Why do you want the link file? Yes you can use the file system API to get it but remember it will be different for each OS.
-
All js code must be included at compile time, you can't add it dynamically. What is your goal?
-
User Presets are automatically put into the correct location if you are using the built in expansion installer. Samples shouldn't go in the app data folder. Or did you mean sample maps? In which case as I said previously sample maps aren't in a folder once your project/expansion is compiled.
-
Pink sample maps mean the samples are purged/not loaded
-
I don't see why zip files are better that the built in system, except for the update situation I mentioned earlier.
-
-
@d-healey Thanks David!
-
@Lindon said that he put his samples in the appdata link file location.. what is it really? I was just basing it off of what he said
-
I have the main object which takes care of my samplemap identifying and I’m planning on using the JS script to push the samplemap object into the main object:
I’m also trying to do some other things with the main plugin for each expansion, for example my samplemap swapping. Basically, I have three samplers and for each sampler, you can mix and match samplemaps from all the expansions the user has. I’ve made this browser for each sampler that lets you select samplemaps with two viewports, one viewport for tags and categories (All, Pad, Chord, Pluck) and the second (with a label to search the viewport) for seeing the available samplemaps and selecting them to change the samplemap for that layer. To accomplish this, I’ve set made an object which has multiple objects inside (these are the tags and categories). In those objects, I’ve put in an object for each samplemap entry. So this object system acts as a file system where the objects are kind of the directories. (Is this a good system, first thing to come in mind to try, but I feel like there may be a better one) Basically, each expansion I add would come with a set amount of samplemaps and there would need to be a script which pushes the samplemap objects into the main object if that makes any sense..
-
Basically #1 in that what did @Lindon mean by putting samples in the linkfile location?
-
Ahh, so the samples being in different locations are what’s throwing off hise when I try to load different samplemaps from different locations/expansions.
-
So with my use case I could still use the standard encoding files from hise?
Thanks again!
-
-
-
Well that's automatic with the hr installer if I remember correctly because it gives the user the choice of where to install the samples and that populates the link file. You really should just go an try the built in installer and see how it works.
-
You'll have to find another way, you can't include extra scripts in your expansions.
-
Yeah the samples need to be in the location the link file in app data is pointing to.
-
I haven't seen anything in your use case that would prevent it.
-
-
@d-healey Tried exporting samples as an archive but the end result hr1 file doesn't seem to have the samples included as the file size is very small and is the exact same as the hxi file size. Do you know what I may be doing wrong? And i'm deciding on putting all samples into the main samples folder under my project folder, so I've set the location in the installer function to the samples folder, but after installing the hr file, nothing happens... Is there something I'm not getting?
Thanks for your help!
-
Do you know what I may be doing wrong?
Did you select the hxi in the sample exporter dialog window?