This is great ! Now to wrap my head around it, thank you very much !
I think that there is a better way to introduce this to beginners, and expect someone to post a better response.
OK , but thank you for your time.
What you will want to do is append the ramp function on the ring given by the line function. This always return the last value when you’re ticking past the length of the ring, instead of wrapping it around. Use:
sample :bd_808, amp: (line 0,1,steps: 32, inclusive: true).ramp.tick
Instead of
sample :bd_808, amp: (line 0,1,steps: 32, inclusive: true).tick
and remove the entire if-block. You can use the .ramp
function for anything you want to “stay at the end” instead of wrap around.
@chris.krakou works like a charm, ty.
Take a look at the ramp
fn or calling .ramp
on a ring
Not answering the OP, but thinking about the general concept of fading in and out, it might be useful if the control statement could take an envelope. E.g.:
use_synth :dsaw
sn = play 60, sustain: 30
control sn, cutoff: [[ 30, 130, 30, 130 ], [10, 10, 10] ]
This would give cutoff a envelope that goes from 30 to 130 to 30 to 130, with 10 beats for each segment.
If this was possible, then it would allow a lot of very easy fading in and out, while not requiring a new command. Particularly if, as mentioned above, live_loops returned a controllable object.
Looks like a good idea to me. And since you can look at it as a helper function similar to play_pattern
, it shouldn’t be too hard to implement. (he said, knowing nothing about the code base). I’ll give it a shot a bit later.
I tried to implement it in Sonic Pi, but I had two problems.
1] I don’t know how to pass something like amp: to a function so that the same function can be used to control different synth params. Hence the more or less repeated code in the following. If anyone could show me how to solve this, it would be greatly appreciated.
2] My code doesn’t work, for some obscure reason I can’t yet figure out, the parameters don’t seem to follow my envelopes correctly.
Note that following on from previous discussions, I’ve added an effect chain to a single live loop using even cludgier code.
use_bpm 127
use_debug false
FILTER = 0
REVERB = 1
FLANGER = 2
components = []
with_fx :rlpf, amp: 0 do |filt|
components[ FILTER ] = filt
with_fx :reverb do |rev|
components[ REVERB ] = rev
with_fx :flanger do |flange|
components[ FLANGER ] = flange
live_loop :drums do
at [ 0, 2.5, 3 ] do
sample :bd_haus
end
at [ 1, 3 ] do
sample :sn_dolf
end
at [ 0.5, 1.5, 2.5, 3.5, 3.75 ] do
sample :drum_cymbal_closed
end
sleep 4
end
end
end
end
#
# Simulating the following non-existing version of 'control'
#
# control components[FILTER], amp: [[0, 1, 1, 0], [5, 20,5]]
#
ampenv = [[ 0, 1, 1, 0 ], [5, 20, 5] ]
control components[FILTER], amp_slide: 0
control components[FILTER], amp: ampenv[0][0]
total = 0
ampenv[1].length.times do |i|
at total do
control components[FILTER], amp_slide: ampenv[1][i]
control components[FILTER], amp: ampenv[0][i+1]
print "Level going to: ", ampenv[0][i+1], " over time: ", ampenv[1][i]
end
total = total + ampenv[1][i]
end
#
# control components[FILTER], cutoff: [[ 30, 130, 30, 130 ], [10, 10, 10] ]
#
#
filterenv = [[ 70, 130, 70, 130, 70 ], [8, 8, 8] ]
control components[FILTER], cutoff_slide: 0
control components[FILTER], cutoff: filterenv[0][0]
total = 0
filterenv[1].length.times do |i|
at total do
control components[FILTER], cutoff_slide: filterenv[1][i]
control components[FILTER], cutoff: filterenv[0][i+1]
print "Filter going to: ", filterenv[0][i+1],
" over time: ", filterenv[1][i]
end
total = total + filterenv[1][i]
end
at 40 do
stop
end
I’ve been recently thinking on how could this be made, but I haven’t found a good solution.
Would this provide a solution to what you’re looking for?
# :foo here is the name of a live loop
control :foo, amp_slide: 8, amp: 0
This would be great!
This is a fantastic idea!!!
I would love to see this – it’s a very elegant solution.