Hey! I am working on building a long form generative ambient piece that will be a 24/7 live stream. So far I have built 2 samplers that select random clips from a folder and loop them a few times, and then pick another random sample from their respective folder.
What I am trying to figure out is what would be the most elegant way to crossfade between the incoming clips so that it isn’t as jarring. The elegant approach would be to figure out how to have sonic pi recognize that the live_loop was nearing the end of its playback of x amount of repititions, and then fade the amplitude out over 20 seconds or so while triggering and fading in the next sample simultaneously. Not sure if that’s possible within a single live_loop, or if it would need to be 2 instances.
The less elegant approach would be to have 4 samplers instead of 2, and sampler 1A and 1B fade in and out of each other, so that no crossfade has to be built just a fade in and out. same for 2A and 2B
Another way would be that each looper would just be looping indefinitely and then there was a global time which would trigger the fade in and fade out of the 2 loopers over a 20 second period at the same time.
Any ideas for how to achieve these long fades in and out between loopers? Would love some help figuring this out!
Here is the code so far:
f1 = Dir.glob(“C:/Users/…/f1/.wav")
f2 = Dir.glob("C:/Users/…/f2/.wav”)
in_thread do
live_loop :f1 do
use_random_seed dice(244)
sample_file = choose(f1)
with_fx :reverb, room: 1, mix: rand do
repetitions = rand_i(1..4)
repetitions.times do
sample sample_file, amp: 1
sleep sample_duration sample_file
puts "f1 repetitions: #{repetitions}"
end
end
end
end
in_thread do
live_loop :f2 do
use_random_seed dice(244)
sample_file = choose(f2)
with_fx :reverb, room: 1, mix: rand do
# with_fx :echo, phase: 0.5, decay: 8 do
repetitions = rand_i(1..4)
repetitions.times do
sample sample_file, amp: 1
sleep sample_duration sample_file
puts "f2 repetitions: #{repetitions}"
end
end
end
end