Hey guys, I am a very beginner in music composition and as a seasoned programmer I find Sonic Pi absolutely wonderful, because I always wanted to compose music.
My ear tells me that most modern music is made of looping samples running in different layers. A track usually starts with a single sample, then others come into play overlaping each other and making the music more complex. That’s easy, I can already do that in Sonic Pi after a couple of hours in the tutorials.
What I am struggling with is that sometimes during a song you want to pause a looping sample for say 4/8/16 beats and then restart it. How do I pause a sample in a loop for a specific amount of beats? Or even better, is there a way to modify properties of a looping sample on the go?
I tried a few approaches, I would expect something like this:
in_thread do loop do amb = sample :ambi_choir, rate: 0.5, attack: 5, release: 5, amp: 0 sleep sample_duration(amb) end end in_thread do loop do beats = sample :loop_safari, rate: 1, amp: 0 sleep sample_duration(beats) end end # start the first sample / layer (ambient background) contol amb, amp: 1 sleep 8 # add the second sample / layer (beats) control beats, amp: 1 sleep 16 # pause the second sample for 8 beats control beats, amp: 0 sleep 8 # restart the second sample for 16 beats control beats, amp: 1 sleep 16 # end the beats control beats, amp: 0 sleep 8 # end the song control amb, amp: 0
At the moment, I get:
Runtime Error: [buffer 3, line 11] - RuntimeError
Unknown sample filter type: SonicPi::SynthNode - got: #<SonicPi::SynthNode @id=3399, @name=sonic-pi-basic_stereo_player @state=pending>
But overall I’ve got a feeling that I’m doing it completely wrong, something tells me this is something many people would get across in the past and that there has to be solution.
Any hints are welcome. Thank you.