Bypass Layers Using Keys

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

Bypass Layers Using Keys

Post by rmjmusic »

Hi all,

I've got an instrument that contains multiple layers. I was trying to script something where I can toggle each layer's bypass state with a key on the keyboard. The key would work like a switch. You hit press and release once and the corresponding layer goes into bypass. You do it again and the layer is enabled. Unfortunately, I'm not very experienced with the scripting side so I'm having quite a bit of difficulty. I've seen some posts on here trying to do something fairly similar but the code for it and my novice don't transfer well into what I'm trying to implement.

Thanks for any help you can extend.
Cubase Pro 10.5
Cubase Pro 10
HALioin 6
Windows 10 Pro 64bit
Mac OS 10.13.6

misohoza
Member
Posts: 952
Joined: Sun Oct 05, 2014 12:18 am
Contact:

Re: Bypass Layers Using Keys

Post by misohoza »

Hi rmjmusic,

You could try something like this:

Code: Select all

layers = this.parent:findLayers()

defaultSwitch = 36
keys = getKeyProperties()
for i = 1, #layers do
  keys[defaultSwitch + i - 1] = {color = 10, tooltip = layers[i].name}
end

function onNote(event)
  if event.note >= defaultSwitch and event.note < #layers + defaultSwitch then
    local layer = layers[event.note - defaultSwitch + 1]
    local layerMidiMute = layer:getParameter("LayerMidiMute")
    layer:setParameter("LayerMidiMute", not layerMidiMute)
  else
    postEvent(event)
  end
end
Win 10 Home, 64 bit, 8 gb ram,
Cubase Pro 10.5, Wavelab Pro 9.5, Halion 6, Dorico 3,
NI Komplete 10 Ultimate, Ozone 7,
UR 44

rmjmusic
New Member
Posts: 49
Joined: Thu Jan 04, 2018 3:22 am
Contact:

Re: Bypass Layers Using Keys

Post by rmjmusic »

As per usual, you rock! This works perfectly and exactly what I needed.

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