# Sync live loop only once?

**URL:** <https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291>\
**Category:** Support, Help & Resources\
**Created:** [November 12, 2024, 1:35am UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291 "2024-11-12T01:35:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [November 12, 2024, 1:35am UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291/1 "2024-11-12T01:35:41Z")

</div>

Is there a way to code a live loop so it syncs to another loop only on the first time through?  
I’m thinking of doing some experiments in polymeters – different numbers of beats in each loop, but the duration of a single beat is the same across the board.  
So I want them to start together, but not resync after the first time through.  
Thanks!

---

<div class="post-metadata">

**Author:** ![boda](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@boda](https://in-thread.sonic-pi.net/u/boda)\
**Post date:** [November 12, 2024, 5:04am UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291/2 "2024-11-12T05:04:16Z")

</div>

Hello!  
quite not understand what are you trying to achieve, but to answer:

Is there a way to code a live loop so it syncs to another loop only on the first time through?

R// yes, example:

```ruby
counter = 0

live_loop :loop_one do
  play 60
  if counter == 1 then
    cue :test
  end
  counter+= 1
  print counter
  
  sleep 1
end

live_loop :loop_two, sync: :test do
  play 80
  sleep 0.9
end

```

to make them sound “out of sync” you will need to play with the sleep time.

does that answer what are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [November 12, 2024, 1:37pm UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291/3 "2024-11-12T13:37:51Z")

</div>

Yes, that would do it. Thanks!

---

<div class="post-metadata">

**Author:** ![emlyn](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/emlyn/32/1460_2.png) [@emlyn](https://in-thread.sonic-pi.net/u/emlyn)\
**Post date:** [November 12, 2024, 2:11pm UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291/4 "2024-11-12T14:11:10Z")

</div>

No need for the counter and the cue, this will do the same (sync as a live\_loop argument only syncs once at startup):

```ruby
live_loop :loop_one do
  play 60  
  sleep 1
end

live_loop :loop_two, sync: :loop_one do
  play 80
  sleep 0.9
end

```

---

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [November 13, 2024, 2:56am UTC](https://in-thread.sonic-pi.net/t/sync-live-loop-only-once/9291/5 "2024-11-13T02:56:41Z")

</div>

I did not realize that. That’s exactly what I need.  
Thanks!
