Saving parameter state when moving a script

Post topics about HALion scripting.
Post Reply
New Member
Posts: 1
Joined: Wed Jun 14, 2017 7:51 am

Saving parameter state when moving a script

Post by teknojunque » Wed Jun 14, 2017 8:06 am

Suppose that I have a simple script that processes midi, in this case, a transpose function that has a single parameter which I define in onLoadIntoSlot as follows:

Code: Select all

function onLoadIntoSlot()
    defineParameter("Transpose", "Transpose Amount", 12, -96, 96, 1, onTransposeChange)
Now, when I move this around the program tree, e.g., above or below another copy of the same script. The value of the parameter is reset as the move is viewed as a new "load into slot." The built in midi tools, of course, don't have this issue, if you change a parameter and them move them around, the parameter remains as set.

So, is there some way to preserve state here such that, it defaults to 12 on load, but will remain unchanged when moved around? Are there best practices documented somewhere that I missed? I know that the state is correct immediately on call to onRemoveFromSlot so that seems like the place to preserve the state, but I can't help but feel like I'm missing something fundamental here.

It would be great to see a good example of a full midi processor written in HalionScript from Steinberg.


BTW: I'm new to this forum, not new to Cubase, new to Halion, not new to programming.

Junior Member
Posts: 179
Joined: Fri Nov 14, 2014 11:41 am

Re: Saving parameter state when moving a script

Post by AposMus » Wed Jun 14, 2017 12:29 pm

Parameters usually aren't defined inside an Initialisation function like onLoadIntoSlot.

The function call is likely causing the reset, so moving it outside the function will solve this. To apply the state to the new layer/zones you will need a function that uses setParameter. The normal parameter callback is only triggered when a value is physically changed on the UI or parameter list.

The "Transpose" parameter value can also be assigned to another variable for storage.

To have a look at one of Steinberg's scripts you can load the Mono Step Modulator midi module, select it and open the script editor at the bottom. They left it open so we can have a look inside.
Cubase Pro 8.5.2
Halion 6
Padshop Pro
Dark Planet
Windows 7 64bit, AMD Phenom IIx6 1055t, 8GB Ram, Gigabyte GA-880G-UD3H F2, Nvidia GeForce GTS450

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest