I have, for example, a kick and two synth sounds, each playing back in its own rhythm because each gets its own live_loop containing its own sleep pattern that comes from each instrument’s own array of sleep times. I want to modulate the rhythms live, so you’d normally be using functions so that you can change the function’s code while leaving the code inside the loop alone so that reloading doesn’t mess things up. I can’t figure out how to achieve that behavior here because functions would play sequentially, yet I need these loops to continue to play concurrently before, during, and after altering their sleep functions. I guess the problem is that I need multiple sleep times within the same loop to apply to multiple blocks of code within that loop, which doesn’t sound possible to me. Is there some way to achieve the desired behavior? Here’s my toy example:
ToneRhythm = [1.0, 0.333, 0.333, 0.333] ToneRhythmLength = ToneRhythm.length bdRhythm = [1, 1, 1, 1] bdRhythmLength = bdRhythm.length SynRhythm = [0.5, 0.5, 0.5, 0.5] SynRhythmLength = SynRhythm.length live_loop :tone_loop, sync: :metronome do use_synth (ring :tb303, :blade).tick(:timbre) play :e2, attack: 0, release: 0.5, cutoff: 100 sleep ToneRhythm[tick(:tone_tick) % ToneRhythmLength] end live_loop :bd_loop, sync: :metronome do sample :bd_haus sleep bdRhythm[tick(:bd_tick) % bdRhythmLength] end live_loop :syn_loop, sync: :metronome do play (ring :d3, :e3).tick, attack: 0, release: 0.5, cutoff: 100 sleep SynRhythm[tick(:syn_tick) % SynRhythmLength] end in_thread do sleep 1 cue :metronome end
This plays the kick in quarter notes, one synth in quarter then triplet eighths, and the other synth in eighth notes. I’d like to be able to do complicated algorithmic changes to both the length and cell content of the three rhythm arrays and then reload to achieve interesting (to me) n-tuplet based rhythmic patterns.