# Sync'ing to bars

**URL:** <https://in-thread.sonic-pi.net/t/syncing-to-bars/1160>\
**Category:** \[P\] Patreon Support\
**Created:** [May 22, 2018, 10:51am UTC](https://in-thread.sonic-pi.net/t/syncing-to-bars/1160 "2018-05-22T10:51:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aen1gma](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/aen1gma/32/661_2.png) [@aen1gma](https://in-thread.sonic-pi.net/u/aen1gma)\
**Post date:** [May 22, 2018, 10:51am UTC](https://in-thread.sonic-pi.net/t/syncing-to-bars/1160/1 "2018-05-22T10:51:54Z")

</div>

Hello again. I’ve wrapped a bunch of live\_loops in “on” blocks so I can easily toggle them on and off. However, I would like to set it up in a way that after I toggle and hit run, it waits for the next bar (e.g. every 4 beats) before playing. I thought sync’ing to a live loop with cue followed by sleep 4 would work, however, this changes the timing of the loop. Is there some way I can achieve this?

---

<div class="post-metadata">

**Author:** ![Davids-Music-Lab](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/davids-music-lab/32/512_2.png) [@Davids-Music-Lab](https://in-thread.sonic-pi.net/u/Davids-Music-Lab)\
**Post date:** [May 22, 2018, 11:43am UTC](https://in-thread.sonic-pi.net/t/syncing-to-bars/1160/2 "2018-05-22T11:43:20Z")

</div>

Can you post the code you have do far?

Does the loop you want to sync have sleep commands in it?  
I usually make a ‘metronome’ loop that cues its own tick value, so all other loops can sync to that without needing any sleep.

Edit:  
You can also set up the metronome loop to send individual triggers to loops.

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [May 22, 2018, 12:15pm UTC](https://in-thread.sonic-pi.net/t/syncing-to-bars/1160/3 "2018-05-22T12:15:47Z")

</div>

Hi @aen1gma,

have a look if this helps in your situation:

> <https://github.com/mbutz/sonicpi-leuphana-ws1718/blob/master/session-04/synchronisation-of-live-loops.rb>

---

<div class="post-metadata">

**Author:** ![aen1gma](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/aen1gma/32/661_2.png) [@aen1gma](https://in-thread.sonic-pi.net/u/aen1gma)\
**Post date:** [May 23, 2018, 10:53am UTC](https://in-thread.sonic-pi.net/t/syncing-to-bars/1160/4 "2018-05-23T10:53:20Z")

</div>

Cheers guys. This worked by simply sync’ing to a live\_loop that contained nothing but a sleep 4. I’m not even sure what I did wrong the first time… I must’ve been overthinking it 🙃

@Martin I also found the following in your code snippet which worked better than my approach for toggling loops on and off

```
stop if run_hiht == 0
```
