Switching between samples in a Zone

Hi, I’m a beginner at this sound design stuff, so apologies if this is an obvious question.

I want to know, is there a way of flicking a switch on your instrument in the Macro builder and having it switch between samples in a zone?

I’ve got an instrument that plays 3 different guitar instrument samples at once (or individually if you solo / mute.)
Screenshot 2017-12-06 17.24.54.jpg
So Zone 1 is the electric gtr, Zone 2 the bass and Zone 3 the acoustic.

What I’d like to achieve is have different chord samples loaded up and waiting in the guitar zones (1 & 2) and with a flick of a switch change the guitars from Major chord samples to minor chord samples. (If that’s possible, I’d also like to then go on to add 7th’s, 6ths, 5ths etc etc)

Is this even possible? I can’t find a way of switching between samples in a zone. I’m a complete novice at this stuff, so if the answer is code, I’m probably in even bigger trouble. :laughing:

Hi Steve,

What you are trying to achieve is possible.

I would suggest to create layers for each of your chords. One for major chords samples, one for minor chords samples…
If you’re happy with using keyswitches to change which chords are being played then all you need to do is add and set up a MegaTrig module.

If you want to use a macro page knob or menu then some scripting might be necessary.
Have a look at the attached preset. I’ve used synth zones but you can apply the same logic to sample zones.
Layer Selector.zip (5.88 KB)

1 Like

Hi Misohoza,

Wow! Thank you so much.

Your preset and the attached code worked perfectly. I just adapted it for my audio samples and zone names and I can now switch from major to minor to sus 4 etc samples. Genius!

Im so grateful. Thanks again mate.

Im going to bed relieved. Cheers.

I’m glad it worked.

There are several ways how to deal with situation like this.

When you wrote you want to automate the layer switching it made me think whether this is the right approach. The preset attached in my previous post works by changing the “LayerMidiMute” parameter. When you turn the knob it mutes everything and unmutes the selected layer. So if you play a note and turn the macro page knob while the note is still held the note will be cut off.

So I tried to change the script slightly to make it work on per note basis and avoid cutting off notes when turning the knob:

layers = this.parent:findLayers()

function getLayerNames()
  layerNames = {}
  for i, layer in ipairs(layers) do
    layerNames[i] = layer.name
  end
end

getLayerNames()

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


function onNote(event)
  playNote(event.note, event.velocity, -1, layers[LayerSelect])
end

Layer Selector 2.zip (5.59 KB)

If you find you prefer this behaviour try it on a dummy program first.

When I tried to fix the original preset by changing and reloading the script it looked like it doesn’t work. This happened to me several times before and usually it’s enough to reload the program and/or restart Halion to fix this. But this time it doesn’t.


Here’s the same script saved as a midi module preset with a simple macro page:
Layer Selector Midi Module.zip (1.76 KB)

Hi Misohoza,

Thanks again for all your help, can’t tell you how much I appreciate it.

It’s almost certainly something I’m doing wrong, but I can’t get your new code to work with my program. I’ve attached a pic of my layer tree, so you can see what I’m up to.


Below I’ve attached a pic of your first code that DOES work with my instrument (ie: it plays sounds and changes the chords when the knob is turned), but you’re absolutely right that I’m getting some issues with sounds not playing when changing chords in automation in cubase, probably because of the mute feature you mentioned.

And finally, below I’ve attached a pic of your latest code in my program. I can’t seem get any sounds out of it with my program (I can see it works great on your 'Layer Selector 2), even when making a dummy program. Again, I’m probably doing something stupid and need to rename something ?

For my final embarrassment, I couldn’t get your Midi Module to load up either? I can’t seem to find in HAlion where you’re meant to load Midi modules and not scripts? Apologies again for my ignorance.

If you could offer any more advice or help I’d be eternally grateful. :slight_smile:

And finally, below I’ve attached a pic of your latest code in my program. I can’t seem get any sounds out of it with my program (I can see it works great on your 'Layer Selector 2), even when making a dummy program. Again, I’m probably doing something stupid and need to rename something ?

:slight_smile: This one had me puzzled for a while too. What happens is that when you change the script it loads the new script but doesn’t automatically undo whatever the old script did. The old script changed the “LayerMidiMute” parameter of all layers except for the selected one to “On” which effectively mutes them.

To fix this open parameter list, check each layer has the “LayerMidiMute” parameter set to “Off”.

You could use a script to do this for you. Add Lua Script module, paste the following and press ok.

layers = this.parent:findLayers()

for i, layer in ipairs(layers) do
  layer:setParameter("LayerMidiMute", false)
end

Once the script has done its job you can safely delete this Lua script module from the program tree.


I couldn’t get your Midi Module to load up either? I can’t seem to find in HAlion where you’re meant to load Midi modules and not scripts?

You can save a midi module preset the same way as you can save presets for effects, envelopes…
This is a midi module preset. This file needs to be placed in:

C:\Users\Username\Documents\Steinberg\HALion\Sub Presets\MIDI Modules

This path is created by Halion when you save a preset but you can create the required folders manually if they don’t exist.

Then when you click “Create New Midi Module” all presets in that folder should appear in the list.

Thanks again for all your help!

I’m sorry to say, that didn’t seem to do it.

The muteMIDILayers were already all set to ‘off’, I ran the code anyway just to be sure, but I’m still getting no sound from my samples with the 2nd code.

As an experiment I added your Sine / Triangle / Saw etc sounds to my layer 1 (Along side my guitar chord samples. Your synth sounds played perfectly, but when I switch the knob to my chords i just get silence. (I get sound finewith the first code, but I get the midi mute problem with automation)

So it’s playing the synths, but not the samples . I’m very puzzled!

Update!

I’ve no idea what I’ve done differently, but I’ve just got it working. Your 2nd code!

Maybe halion was messing up before, but I’ve just tested it in cubase and it works great.

No idea what happened, but I’m very pleased. Thank you again for all your help :relaxed::+1:

Good to hear it’s working.

I was going to post a variation of the 2nd code that should fix the LayerMidiMute problem of the first script. In case there were still some layers left with the LayerMidiMute turned on by mistake.

layers = this.parent:findLayers()

function getLayerNames()
  layerNames = {}
  for i, layer in ipairs(layers) do
    layer:setParameter("LayerMidiMute", false) --fix the LayerMidiMute from previous script
    layerNames[i] = layer.name
  end
end

getLayerNames()

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


function onNote(event)
  playNote(event.note, event.velocity, -1, layers[LayerSelect])
end

But if it’s working then don’t bother.

Good luck with your instrument.