Script reflect Property Editor changes
-
Is there a preference to have any changes made in the property editor (when you're working with an interface object) be reflected in the script? In the tutorials the script seems to be automatically updated when you edit a parameter in the property editor panel. I'm not getting this behavior.
-
We had that half a year ago :)
Basically a JSON object with the properties of the objects is created, and updated on change. (sometimes compiling via [F5] can be helpful, too).The auto-updating of the JSON in the code-editor was a mess, and had a lot of boilerplate code in it, so since 1.5.0 the whole GUI-property-updating was put behind the scenes. On the first view it might look a bit unintuitive, but in comparison to the earlier stage its quite a progress ;).
And every property is still accessible by script. You can change them via:
ContentObj.set(String <propertyName>, var <value>)
Best,d
-
You might find this video helpful - https://www.youtube.com/watch?v=hfcIuvJZMyE&t=100s
-
Ah. Victim of the old tutorial.
I’m going to watch that video but what’s the best practice when you’re switching between scripting and editing via the property editor?
So say in the inInit callback I add a button:
Content.addButton(“myButton”);
I then hit compile and the button shows up in the interface editor, so then I grab the button with my mouse and move it to where I want it and then use the interface editor to set its color.
Then when I hit compile, the button returns to its default coordinates. :(
I know I can set these properties in the script as well, but sometimes it’s more intuitive to just grab and move.
I guess I don’t have a full grasp of the difference between JSON and the standard scripting window.
Slightly off topic, but in line with old features phased out...what’s replaced the assign parameter wizard? Say I want to assign “myButton” to the power button of a filter module in my main container? Again I know this is probably easy to do with scripting, but the old way of right clicking on the interface object and setting it to whatever seemed pretty easy for JavaScript noob like me.
Thanks everyone for the help! Love this platform.
-
@bpford Don't use
Content.addControl()
for the front interface, only use this command for other external scripts that you'll load in to other modules. For your front interface everything should be done using the interface designer. If you need to access the control in your script (which you won't always need to do) then you can useContent.getComponent()
. I didn't like this workflow at all at first but I quickly learned to love it :)In previous versions of HISE all of the properties for all of the controls were dumped in your script, now it's handled behind the scenes so you can just see the JSON for each control as you need to by selecting the control and hitting J. The properties you see here can all be set in the interface designer property editor though so you won't need to go in there much. The property editor replaced the assign parameter wizard. You should watch my video :p
-
@d-healey Thanks! I've been diving into the Interface Editor for the last couple days and am pretty happy with what I'm able to accomplish. And the linking widgets to parameter id's is a breeze.
But there are still some things I'll have to script and I'm unsure about how to go about it. For instance, say I setup a knob called "randomPitch" in the interface. I assign the processor id to "detuneRandom" (a Random Modulator in a pitch modulation module in the sampler container). I then assign the parameter id to "Intensity". Works. Great! But I don't want the knob to be able to go all the way 12. ;) This knob is for a chorus-y detuned effect, so I really only want it to have a range of +/- 50 cents. Well, I can sort of do this in the component specific properties by setting the "Max" field to .041 (1/24), but then the smallest step size available is .01....so not enough resolution for this type of control. So, I tried a little scripting. I put this in the onControl callback:
if(number==randomPitch) { const var detuneRandom = Synth.getModulator("detuneRandom"); detuneRandom.setAttribute(detuneRandom.Intensity, (value/24); }
where "randomPitch" is my widget id, and "detuneRandom" is my pitch random modulator module. A couple of questions about this:
-
Is the onControl callback the best place to put this script? I know from reading some of Christoph's posts, there are efficiency concerns with where to put scripts.
-
I also read on some post that the first value of the .setAttribute method should actually be an integer instead of a string? And that integer is an index of each modules parameter? Is there a way to to determine what index number pertains to what parameter?
-
Is this very simple code I thought would be easy, very wrong?
-