I’m trying to figure out a neat way of tweaking individual sample
/synth
parameters in patterns without making it a big mess of case
/if-then-else
blocks. Let’s say I have a melody:
at(line(0, 4), [:c, :e, :g, :b]) do |n|
play n
end
If I now want to add different velocities to the track I’d normally tweak the pattern:
at(line(0, 4), [[:c, 1], [:e, 0.5], [:g, 0.5], [:b, 1.0]]) do |(n, v)|
play n, amp: v
end
That’s already pretty messy, imagine if I want to control more parameters - each note description will get quite complicated.
An alternative I’ve tried is to change the play body instead - especially if I only need a small number of notes to have special behavior:
at(line(0, 4), [:c, :e, :g, :b]) do |t, n, i|
play n, amp: case i
when 0, 4
1
else
0.5
end
end
But you can see how this will also get complicated for multiple parameters. So I wanted to try separating these concerns by running a separate “track” on the side for each parameter, conceptually something like this:
at(line(0, 4), [:c, :e, :g, :b]) do |n|
play n, amp: get(:amp)
end
at(line(0, 4), [1, 0.5, 0.5, 1]) do |a|
set :amp, a
end
I was hoping having these as separate track/layers like this would make multiple parameters easier to manage.
This does not work as-is though, because the order of set
/get
triggered from the at
is not deterministic - the amplitudes will be all over the place for different runs. So I added a time_warp(-0.1)
around the control track which fixed that problem. But I really want to run these in synced live loops, like this:
live_loop :tock do
sleep 4
end
live_loop :hey do
sync :tock
at(line(0, 4), [:c, :e, :g, :b]) do |n|
play n, amp: get(:amp)
end
end
live_loop :control do
time_warp(-0.001) do
sync :tock
at(line(0, 4), [1, 0.25, 1, 0.25]) do |a|
set :amp, a
end
end
end
But however I sprinkle the time_warp
in the :control
loop, I can’t seem to get it to work correctly. Either it does not work on the parameter change at time 0 (due to the sync, I assume), it’s off-by one entirely or it causes threads to crash due to falling behind.
Does anyone know how to get something like the above to work?
Or alternatively, does anyone have a nice way of programming multiple parameter patterns to overlay the any note and time patterns?
Thanks!