Help with a script please

I would appreciate any help with this scripting task please, I did try to search the forums but still at a complete loss since I totally suck at scripting and from what I understand the task isn’t that trivial in Halion. The task as follows:
There are several layers with their own sub-layers inside like on the attached image.
Is it possible to easily make macro page drop down menus for each of the topmost layer (kicks, snares) where one could select from one of the respective layers inside (i.e. snare 1 or snare 2) so only this chosen layer will sound and the rest of sub-layers are muted? It’s for a drum kit where I’d like to choose from different type of snares, kicks, toms which are all mapped on the same keys.

I would probably add a lua script module inside each of the main layers. Then you can choose which sublayer should play like this:

local layers = this.parent:findLayers()
local layerNames = {}

for i = 1, #layers do
	layerNames[i] = layers[i].name

defineParameter("activeLayer", nil, 1, layerNames)

function onNote(e)
	playNote(e.note, e.velocity, -1, layers[activeLayer])

1 Like

Thank so much for your help, Misohoza! Would you mind to attach your example as vstsound preset so I could understand how to embed this script into the menus?

I think I have figured this one out, thanks again for your help!

This is awesome! Thanks a lot misohoza! :smiling_face_with_three_hearts:
I was just about to post exactly the same question as savinoff but then I found this thread and your solution is exactly what I needed.

Now I have one more question: is it possible to have an image (displayed above that menu for example) and when you select a layer from the dropdown menu not only to send midi data only to that layer (like your script above does) but to change that image as well? So for example: let’s say I have three layers (Layer 1, 2 and 3) and for each layer I create a suggestive image. When I select the Layer 1 from the menu I want to have the first image displayed above the menu; when I select Layer 2 I want to have the second image above the menu, and so on. Something like this:


Is there a script that does that?

You can do that by creating a single animation that contains all the images and connect the animation to the activeLayer script parameter.

Or create a stack on macro page. Add required number of groups. Put one image in each group. In this case connect the stack to the activeLayer parameter.

1 Like

Yes, I tried this method and it works perfectly! And it’s much more easy than I thought it would be. Great! Thanks a lot misohoza! :hugs: