Scripted Knob breaks when changing Sub Presets

Post topics about HALion scripting.
Post Reply
rmjmusic
Junior Member
Posts: 51
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Scripted Knob breaks when changing Sub Presets

Post by rmjmusic »

I have a knob that controls the amount on a mod matrix row but I scripted it so that it's limited the range only to 0-100 on the knob. It works great and as expected.

But in this same instrument I have the ability to change between sub presets like you can in Skylab. When I change sub presets, the knob no longer works. If I attach the knob directly to the amount parameter in the mod matrix without limiting the range via script and then switch sub presets it does not break. It works fine. But when it is attached to the script, it no longer works. I've attached the code below...am I missing something in it?

Code: Select all

allZones=this.parent:getLayer(1):getLayer():getZone()

function onModAmountChange()
  allZones:getModulationMatrixRow(2):setParameter("Destination.Depth", ModAmount2)
end
defineParameter("ModAmount2", "ModAmount2", 50, 0, 100, 1, onModAmountChange)
Thanks!
Cubase Pro 10.5
Cubase Pro 10
HALioin 6
Windows 10 Pro 64bit
Mac OS 10.13.6

AposMus
Member
Posts: 230
Joined: Fri Nov 14, 2014 11:41 am
Contact:

Re: Scripted Knob breaks when changing Sub Presets

Post by AposMus »

Have you tried moving allZones inside the callback function.

The zones in the sub preset have different ids and are not the same objects as in the original allZones. So the function is trying to address non existent zones.

Code: Select all

function onModAmountChange()
	local allZones = this.parent:getLayer(1):getLayer():getZone()
	allZones:getModulationMatrixRow(2):setParameter("Destination.Depth", ModAmount2)
end

defineParameter("ModAmount2", "ModAmount2", 50, 0, 100, 1, onModAmountChange)
Cubase Pro 8.5.2
Halion 6
HSO
Padshop Pro
Dark Planet

rmjmusic
Junior Member
Posts: 51
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Re: Scripted Knob breaks when changing Sub Presets

Post by rmjmusic »

That did it!! Huge thanks to you!

I didn't realize they would have different ids when changing the subpresets. This is good to know.

Thanks again!
Cubase Pro 10.5
Cubase Pro 10
HALioin 6
Windows 10 Pro 64bit
Mac OS 10.13.6

Post Reply

Return to “Halion Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest