vibrato.lua

This is an example of how to apply a custom vibrato to a single voice.

--------------------------------------------------------------------------------
--! @example vibrato.lua
--! This is an example of how to apply a custom vibrato to a single voice.
--------------------------------------------------------------------------------
Freq = Knob("Freq", 4.0, 0, 10) -- 4 Hz
Depth = Knob("Depth", 0.5, 0, 1)
local step = 5 -- ms
function onNote(e)
local id = postEvent(e) -- duration is omitted
local phase = 0
while isNoteHeld() do
local depth = Depth.value
local freq = Freq.value
local modulation = depth * math.sin(2 * math.pi * phase)
changeTune(id, modulation)
wait(step)
phase = phase + (step/1000.0) * freq
end
end