Unison.lua

Unison script trigger multiple voices

--------------------------------------------------------------------------------
--! @example Unison.lua
--! Unison script
--! trigger multiple voices
--------------------------------------------------------------------------------
Voices = Knob("numVoices", 5, 2, 10, true)
Detune = Knob("Detune", 10.0, 0, 40) -- cents
function onNote(e)
local nVoices = Voices.value
local detune = Detune.value
for i=1,nVoices do
local note = e.note
local i2 = math.floor(i/2)
local rest = i%2
local tune = detune * i2 / 100.0
if rest == 1 then
tune = tune * -1.0
end
local id = playNote{e.note, e.velocity, vol=1/math.sqrt(nVoices), tune=tune}
end
end
function onRelease()
-- eat event release is automatic in playNote
end