Syncing one live_loop to multiple cue messages

Hello forum, first time poster here! Is it possible to do this? I can see many instances where it would useful to sync one live_loop to multiple incoming cue messages that occur at different moments in time. This would make my code a good bit cleaner to navigate, as I end up duplicating live_loops just to sync to different cues. I find myself wishing I could stack sync messages on top of one another so each could listen for an incoming cue to trigger variations in my live_loop.

I’m learning Sonic Pi to teach some classes over the summer. I am so thankful for this incredible piece of software!

Hi,

If you check the ‘cue’ and ‘sync’ examples in SP’s help/lang section (bottom left of SP screen),
it gives examples of both multiple cue’s, multiple sync’s, and passing variables using cue/sync…

Adapt those to your needs.

Eli…

#This is the patch I’ve been working on. I most likely am making some large conceptual #mistakes with how I am organizing a moving data around. I have read the tutorials and #looked at the examples for cue and sync. I’ll take a look again this evening! Thanks!
"
live_loop :boom do
use_bpm 60
cue :tick

6.times do
3.times do
cue :zoom
sample :bd_haus
sleep 0.5

end

12.times do
  cue :loom
  sample :bd_haus
  sleep 0.25
end

end

12.times do
cue :room
sample :bd_haus
sleep 0.35
end

end

live_loop :droh do
sync “/cue/zoom”

with_fx :gverb, mix: 0.9 do
sample :bd_boom, rate: (ring, 2, 0.5).tick, amp: (ring, 0.11, 0.12, 0.23, 0.3, 0.25, 0.4, 0.3, 0.29, 0.4).look
end

use_synth :blade
play (ring, :e3, :fs3, :b3).tick amp: 0.75, attack: 0.25, release: 0.25
with_fx :gverb, mix: 0.15, damp: 0.5, room: 3 do
with_fx :echo, phase: 0.25, decay: 8 do
use_synth :chipbass
play (ring, :e3, :fs3, :b3).look, amp: 0.4
sleep 0.25
end
end
end

live_loop :droh2 do
sync "/cue/loom"
use_synth :blade
play :ab3

with_fx :gverb, mix: (ring, 0.2, 0.9).look do
sample :bd_boom, rate: (ring, 2, 2).tick, amp: (ring, 0.2, 0.4).look
end

sleep 0.25
end

live_loop :droh3 do
sync "/cue/room"
use_synth :blade
play (ring, :cs3, :cs3, :cs3, :cs3, :cs3, :cs3, :ds3, :ds3, :ds3, :ds3, :ds3, :ds3).tick
use_synth :chipbass
play (ring, :cs3, :cs3, :cs3, :cs3, :cs3, :cs3, :ds3, :ds3, :ds3, :ds3, :ds3, :ds3).look, amp: 0.5, release: (ring, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6).look
sleep 0.25
end

live_loop :basic3 do
with_fx :gverb, mix: 0.5, release: 3, room: 2 do
with_fx :bitcrusher do
sync :zoom
use_synth :dsaw
play (ring, :e1, :e1, :e1).tick , release: 0.5, amp: 0.12
sleep (ring, 0.25).look
end
end
end

live_loop :basic do
with_fx :gverb, mix: 0.1 do
with_fx :bitcrusher do
sync :loom
use_synth :dsaw
play (ring, :eb1, :db2, :b1).tick , release: 0.5, amp: 0.5
sleep (ring, 0.12, 0.12, 0.12).look
end
end
end

live_loop :basic2 do
with_fx :gverb, mix: 0.2 do
with_fx :bitcrusher do
sync :room
use_synth :dsaw
play (ring, :db2, :b1, :e1, :a1).tick , release: 0.5, amp: 0.5
sleep (ring, 0.75).look
end
end

end
"

I cant see much ‘wrong’ with your code… I’ve moved some of the
’with_fx’ outside the live_loops, as this apparently reduces processor
cost by only using one fx, rather than spawning a new one every loop.

I don’t see any instance where you are using multiple sync’s anywhere
though…

Also, when you want to post code, if you precede it with ``` on the line
previous, it will put it in a nice scrollable block…

Disclaimer: I am no Guru… my way isn’t always the ‘right’ way. It’s just one
way of doing things. Your way may be better. :wink:

Eli…

use_bpm 60

live_loop :boom do
  cue :tick
  6.times do
    3.times do
      cue :zoom
      sample :bd_haus
      sleep 0.5
    end
    12.times do
      cue :loom
      sample :bd_haus
      sleep 0.25
    end
  end
  12.times do
    cue :room
    sample :bd_haus
    sleep 0.35
  end
end

with_fx :gverb, mix: 0.9 do
  live_loop :droh do
    sync :loom
    sample :bd_boom, rate: (ring, 2, 0.5).tick, amp: (ring, 0.11, 0.12, 0.23, 0.3, 0.25, 0.4, 0.3, 0.29, 0.4).look
    use_synth :blade
    play (ring, :e3, :fs3, :b3).tick amp: 0.75, attack: 0.25, release: 0.25
    with_fx :gverb, mix: 0.15, damp: 0.5, room: 3 do
      with_fx :echo, phase: 0.25, decay: 8 do
        use_synth :chipbass
        play (ring, :e3, :fs3, :b3).look, amp: 0.4
        sleep 0.25
      end
    end
  end
end

with_fx :gverb, mix: (ring, 0.2, 0.9).look do
  live_loop :droh2 do
    sync :loom
    use_synth :blade
    play :ab3
    sample :bd_boom, rate: (ring, 2, 2).tick, amp: (ring, 0.2, 0.4).look
  end
  sleep 0.25
end

live_loop :droh3 do
  sync :room
  use_synth :blade
  play (ring, :cs3, :cs3, :cs3, :cs3, :cs3, :cs3, :ds3, :ds3, :ds3, :ds3, :ds3, :ds3).tick
  use_synth :chipbass
  play (ring, :cs3, :cs3, :cs3, :cs3, :cs3, :cs3, :ds3, :ds3, :ds3, :ds3, :ds3, :ds3).look, amp: 0.5, release: (ring, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6).look
  sleep 0.25
end

with_fx :gverb, mix: 0.5, release: 3, room: 2 do
  with_fx :bitcrusher do
    live_loop :basic3 do
      sync :zoom
      use_synth :dsaw
      play (ring, :e1, :e1, :e1).tick , release: 0.5, amp: 0.12
      sleep (ring, 0.25).look
    end
  end
end

with_fx :gverb, mix: 0.1 do
  with_fx :bitcrusher do
    live_loop :basic do
      sync :loom
      use_synth :dsaw
      play (ring, :eb1, :db2, :b1).tick , release: 0.5, amp: 0.5
      sleep (ring, 0.12, 0.12, 0.12).look
    end
  end
end

with_fx :gverb, mix: 0.2 do
  with_fx :bitcrusher do
    live_loop :basic2 do
      sync :room
      use_synth :dsaw
      play (ring, :db2, :b1, :e1, :a1).tick , release: 0.5, amp: 0.5
      sleep (ring, 0.75).look
    end
  end
end