I’m using sonic pi for live playing with midi controllers. What a joy to have a fully programmable thing rather than just learning what you can/can’t do with some (expensive) hardware device
I have some long samples, multi-bar and wanted to be able to change the volume in mid-flight. Maybe other things too. I share here in case anyone wants to do that too, or for comments. Maybe there’s other ways to do it.
Needs a bit of explanation. I have some custom functions that pick up values from midi knobs e.g.
isknob() is true if a knob is just above zero.
knobnormalised() returns a value between 0 and 1.
The sample ‘bandoneon.ogg’ is 16 bars long, so the loop is sync’d to play once every 16 bars.
I’ve encased the sample in a
with_fx :level block, and included a 2nd loop that runs concurrently and picks up the knob volume every beat, then applies the volume to the Level FX.
It works! Hopefully helpful to someone - or any alt ideas gratefully received.
live_loop :bandeon do sync :bar16 if isknob(5) then with_fx :level do |level| sample d, "bandoneon.ogg", amp: 1.0, release: 0.3 in_thread do 64.times do control level, amp: knobnormalised(5) sleep 1 end end end end end