Skip to content

Instantly share code, notes, and snippets.

@dndrks
Created August 21, 2022 16:39
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/489c8497f9f85cfd4980b51d73308943 to your computer and use it in GitHub Desktop.
Save dndrks/489c8497f9f85cfd4980b51d73308943 to your computer and use it in GitHub Desktop.
(4b) lfos
-- nc03 snippet: quantized pitch lfos + expanded jumble
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('verb-short')
-- just a random jumble:
clock.run(
function()
while true do
clock.sync(1/4)
if math.random() > 0.5 then
-- let's expand our jumble a bit:
local voice = math.random(6)
sc_fn.play_slice(voice,1)
if voice ~= 1 then -- keep the kick untouched
params:set('reverse_'..voice,math.random(0,1))
end
end
end
end
)
-- lets add lfos for panning and post_filter_fc!
-- build LFO containers:
lfos = {pan = {}, post_filter_fc = {}, semitone_offset = {}}
-- 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
}
-- lets quantize a semitone offset:
lfos.semitone_offset[i] = lfo:add{
min = -7,
max = 12,
action = function(scaled,raw)
if util.round(scaled) < 0 then
scaled = -7
elseif util.round(scaled) >= 0 and util.round(scaled) < 7 then
scaled = 0
else
scaled = 12
end
params:set('semitone_offset_'..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:
if i ~= 1 then -- keep the kick unfiltered
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
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment