Connecting two MIDI modules to another script to allow enable/disable

This is a very easy one however it’s still causing me issues due to the mutual exclusivity issue I had the other day. In that scenario the trick was to use “getzones” and “in ipairs(zones)” function but I’m failing to see how to apply that in this scenario.

To provide some background, I have two MIDI modules: a) MIDI Randomizer; and b) VelocityRemapper (LuaScript).

I would like the default to be with the VelocityRemapper enabled and the MIDI Randomizer disabled. A switch will then be connected to another script (draft below) to swap over and enable the Randomizer while disabling the Remapper.

So far I have:

zone = this.parent:getMidiModule("MIDI Randomizer")

function bypassChanged()
        zone:setParameter("Bypass", RandomOn)
end

defineParameter("RandomOn", nil, false, function() bypassChanged() end)


zone = this.parent:getMidiModule("VelocityRemapper")

function bypassChanged()
        zone:setParameter("Bypass", RandomOn)
end

defineParameter("RandomOn", nil, false, function() bypassChanged() end)

As expected this is only activating the second module. Or potentially activating both but the second one is reversing the first.

Is the “in ipairs” function where I should be investigating or am I completely off track?

If you try like this?

m1 = this.parent:getMidiModule("MIDI Randomizer")
m2 = this.parent:getMidiModule("VelocityRemapper")

function bypassChanged()
        m1:setParameter("Bypass", RandomOn)
        m2:setParameter("Bypass", not RandomOn)
end

defineParameter("RandomOn", nil, false, bypassChanged)
1 Like

Yes perfect, thanks.

With any luck this could actually be the last script needed for the project. I’m almost done :partying_face: