Automatic Keyswitch script
--------------------------------------------------------------------------------
--! @example Keyswitch.lua
--! Automatic Keyswitch script
--------------------------------------------------------------------------------
local numLayers = #
Program.
layers -- number of layer in the program
local lastLayerActivated = 1 -- id of the last activated layer
local KSbaseNote = 36 -- MIDI note where keyswitch are located
if e.note >= KSbaseNote and e.note < KSbaseNote + numLayers then -- if the note is one of the keyswitch keys
lastLayerActivated = e.note - KSbaseNote + 1 -- update the activated layer id
else
playNote(e.note, e.velocity, -1, lastLayerActivated) -- not a keyswitch key so we play the note on the activated layer
end
end
-- eat event as release is done automatically by
playNote
end
for i=KSbaseNote, KSbaseNote+numLayers-1 do
end