--------------------------------------------------------------------------------
--! @example portamento.lua
--------------------------------------------------------------------------------
local numNotes = 0
local lastid = -1
local lastnote = 0
Fade =
Knob(
"fade", 100, 1, 500)
function glide(id, from, to, duration, period)
duration = duration or 100 -- 100 ms
period = period or 10 -- 5 ms
local doglide = function()
local value = from
local increment = (to - from) * period / duration
local t = 0
local immediate = true
while t < duration do
immediate = false
value = value + increment
t = t + period
end
end
_spawn(doglide)
end
if numNotes > 0 then
local fadetime = Fade.value
glide(lastid, 0, (e.note-lastnote), fadetime)
fadein(lastid, fadetime, true)
glide(lastid, (lastnote-e.note), 0, fadetime)
lastnote = e.note
else
lastnote = e.note
end
numNotes = numNotes + 1
end
numNotes = math.max(0, numNotes - 1)
end