Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dndrks
Created August 21, 2022 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dndrks/4d1f32b6213963146fd34f93b989a08e to your computer and use it in GitHub Desktop.
Save dndrks/4d1f32b6213963146fd34f93b989a08e to your computer and use it in GitHub Desktop.
(4a) lfos
-- nc03 snippet: lfos
sc_fn = include 'lib/sc_helpers'
sc_prm = include 'lib/sc_params' -- param-based controls over softcut
lfo = require 'lfo' -- parameter-based lfo library
function init()
-- always keep this in the init, just in case the files haven't been migrated:
sc_fn.move_samples_into_audio()
sc_prm.init() -- build the PARAMETERS UI entries for all 6 softcut voices
-- kits: 'default-1', 'default-2', 'fltr-amod-eq', 'fm-lite', 'heavy', 'mods-1', 'mods-2', 'verb-long', 'verb-short'
sc_fn.load_kit('mods-2')
-- just a random jumble:
clock.run(
function()
while true do
clock.sync(1/4)
if math.random() > 0.5 then
sc_fn.play_slice(math.random(6),1)
end
end
end
)
-- lets add lfos for panning and post_filter_fc!
-- build LFO containers:
lfos = {pan = {}, post_filter_fc = {}}
-- softcut.VOICE_COUNT equals 6, so we can just use that variable:
for i = 1,softcut.VOICE_COUNT do
-- for each voice, we'll build a panning LFO:
lfos.pan[i] = lfo:add{
min = -1,
max = 1,
action = function(scaled,raw)
params:set('pan_'..i,scaled)
end
}
-- for each voice, we'll build a filter cutoff LFO:
lfos.post_filter_fc[i] = lfo:add{
min = 20,
max = 12000,
action = function(scaled,raw)
params:set('post_filter_fc_'..i, scaled)
end
}
-- for all the voice LFOs, let's do the following:
for k,v in pairs(lfos) do
lfos[k][i]:set('ppqn', 16) -- reduce resolution (no need for 96ppqn here)
lfos[k][i]:set('period', math.random(15)) -- set clock periods to random values
lfos[k][i]:start() -- start each LFO
end
-- let's adjust some additional parameters:
params:set('post_filter_dry_'..i,0) -- no dry signal
local filters = {'lp','hp','bp'} -- index our filter types
-- we'll turn a random filter type up to 1 (== 100%) with each script load:
params:set('post_filter_'..filters[math.random(3)]..'_'..i,1)
-- let's randomly set the filter q:
params:set('post_filter_rq_'..i,math.random(90))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment