Hi,
I’d like to move params, like a cutoff, using a sine wave or other, like an LFO. Can I do that with Sonic PI easily?
Hi,
I’d like to move params, like a cutoff, using a sine wave or other, like an LFO. Can I do that with Sonic PI easily?
There are lots of ways to do LFO type things, a simple one is like this. Each time round the loop a LPF filter is created with the cutoff being a function of time. There’s other ways where you can control an exist fx. Is that any help?
live_loop :a do
use_synth :saw
with_fx :lpf, cutoff: 80.0+30*Math::sin(vt/3) do
play :C4, amp: 0.2, sustain: 0.5
end
sleep 0.5
end
I should add that some FX are expensive, so it’s better if you can to create them less frequently and use control
to animate them, e.g. like this where there’s one FX created every 16 notes. Depends on what you’re doing.
live_loop :a do
use_synth :saw
with_fx :lpf do |fx|
16.times do
control fx, cutoff: 80.0+30*Math::sin(vt/3)
play :C4, amp: 0.2, sustain: 0.4
sleep 0.5
end
end
end
I use the line function to generate a triangle or saw lfo. It’s the simplest solution I’ve found so far. The number of steps determine the frequency of the lfo.
use_bpm 120
live_loop :main do
# triangle lfo
triLFO = line(0,1,steps: 32,inclusive: true).mirror
#sawtooth lfo. Invert to make it ramp down instead of up
sawLFO = line(0,1,steps: 32,inclusive: true)
# do a tick to keep things from running away
tick
# do some acid bass with lfo-controlled cutoff
synth :tb303, note: octs(:c1,3).look, cutoff: line(60,90,steps: 32, inclusive: true).mirror.look
# fade in and out
synth :fm, note: :c1, amp: triLFO.look
sleep 0.25
end
Cool tricks! Thank you.
Just a little change can make so much fun.
Eli…
use_bpm 120
tune = [:c1, :c1, :c2, :c3, :r, :f3, :g4, :r].ring
live_loop :main do
# triangle lfo
triLFO = line(0,1,steps: 32,inclusive: true).mirror
#sawtooth lfo. Invert to make it ramp down instead of up
sawLFO = line(0,1,steps: 32,inclusive: true)
# do a tick to keep things from running away
tick
# do some acid bass with lfo-controlled cutoff
synth :tb303, note: octs(tune.look,3).look, cutoff: line(60,90,steps: 32, inclusive: true).mirror.look
# fade in and out
synth :fm, note: :c1, amp: triLFO.look
sleep 0.25
end