Skip to content

Instantly share code, notes, and snippets.

@justmat
Last active October 2, 2019 17:38
Show Gist options
  • Save justmat/08f18e6fdc6ae30d4c9defe9f54a09f6 to your computer and use it in GitHub Desktop.
Save justmat/08f18e6fdc6ae30d4c9defe9f54a09f6 to your computer and use it in GitHub Desktop.
-- use hnds.lua to modulate softcut rate
-- assumes number_of_outputs is set to 2 in hnds.lua
local lfo = include("lib/hnds")
local lfo_targets = {
"none",
"1speed",
"2speed"
}
function lfo.process()
for i = 1, 2 do
local offset = params:get(i .. "offset")
local target = params:get(i .. "lfo_target")
if params:get(i .. "lfo") == 2 then
if target == 2 or target == 3 then
params:set(lfo_targets[target], lfo.scale(lfo[i].slope, -1.0, 1.0, params:get(i .. "lfo_min") + offset, params:get(i .. "lfo_max") + offset) * 0.01)
end
end
end
end
function init()
-- add rate params
for i = 1, 2 do
params:add_control(i .. "speed", i .. " speed", controlspec.new(-4, 4, "lin", 0.01, 1, ""))
params:set_action(i .. "speed", function(x) softcut.rate(i, x) end)
end
-- overwrite lfo_targets from hnds.lua
for i = 1, 2 do
lfo[i].lfo_targets = lfo_targets
end
-- init hnds.lua
lfo.init()
-- bang those params
params:bang()
-- clear buffers
softcut.buffer_clear()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment