# How to send MIDI CLOCK

**URL:** <https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003>\
**Category:** General\
**Created:** [February 13, 2019, 9:52pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003 "2019-02-13T21:52:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 13, 2019, 9:52pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/1 "2019-02-13T21:52:31Z")

</div>

HI!! how can i send MIDI CLOCK to my midi toys set?

---

<div class="post-metadata">

**Author:** ![Bubo](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bubo/32/786_2.png) [@Bubo](https://in-thread.sonic-pi.net/u/Bubo)\
**Post date:** [February 16, 2019, 10:19pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/2 "2019-02-16T22:19:48Z")

</div>

Check out the `midi_clock_tick` and `midi_clock_beat` commands in the documentation.

---

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 21, 2019, 9:41pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/3 "2019-02-21T21:41:12Z")

</div>

did you use it? im trying to sync sonic pi with my volca sample, but with that commands SEND midi clock but is not exactly , may be i have to sync with bpm? i did midi start and midi clock but it not in sync

---

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 21, 2019, 11:30pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/4 "2019-02-21T23:30:26Z")

</div>

I DID THIS:  
live\_loop :clock do  
midi\_clock\_beat  
sleep 1  
end

but its dont sync sonic pi live\_loop with the midi clock thts it send, may be i need to put something like SYNC\_BPM? thanx

---

<div class="post-metadata">

**Author:** ![Bubo](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/bubo/32/786_2.png) [@Bubo](https://in-thread.sonic-pi.net/u/Bubo)\
**Post date:** [February 22, 2019, 2:21am UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/5 "2019-02-22T02:21:24Z")

</div>

What you are trying to do is much more complicated that what I was first thinking. Volcas can be sometimes tricky to synchronize with everything else, and still, you have to deal with Sonic-Pi to synchronize. I would suggest you to try something different to achieve what you want.

For instance, you could benefit from using the `live_audio` type of loop, as suggested by Sam Aaron in [another topic](http://in-thread.sonic-pi.net/t/syncing-with-an-external-midi-clock/1048). You could also try syncing your Volca with a DAW and then try to send MIDI or OSC messages from your DAW to Sonic-Pi. These are tricky solutions to setup, but they might be the most efficient.

---

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 22, 2019, 12:24pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/6 "2019-02-22T12:24:35Z")

</div>

but i dont have problems sendind midi clock, the problem at the moment is that my midi clock sends is not sync with live loops. volca start and stop with midi strat an midi stop and receive the tempo but passing same betas y can see that they are not sync ( i mean live loop is not sync with the bpm tha sonic pi is sending) i have a midi trhue box so if the problem were Volca i can change my setup but i think the problem is the sync, do you think i have to sync my live loops with bpm? im not sure if is nessesary, im new on coding, thanx 4 your time and sorry about my tarzan english

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [February 25, 2019, 10:33am UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/7 "2019-02-25T10:33:53Z")

</div>

Hi @atrip,

the MIDI messages you send should be in sync with the live loop that generates them:

```ruby
live_loop :foo do
  midi_clock_beat
  sleep 1
end

```

If you have other live loops, then you will need to ensure that they are in sync (as usual). This is typically via two things:

1. Make sure they have the same BPM (this is true if you don’t change the BPM at all, but if you do, make sure you change the BPM for each live loop in the same way, or declare the BPM change prior to triggering any live loops so they inherit this change)
2. Make sure they have the same phase offset. This is true if you start all the code at the same time by pressing the Run button. However, if you’re live coding and start one live loop, write another and then start it, they will be out of phase unless you explicitly sync them. This can be done either with the `sync` function or using the `sync:` option to `live_loop` (typically preferred).

Additionally, depending on your setup, your system may also have audio latency that is different from the MIDI messages. For example, even if Sonic Pi triggers a sound and a MIDI message at the same time, the sound event has to go through your OS, to the audio drivers, then to the DAC before coming out of the speakers. On some systems this can take quite a long time if it hasn’t been tuned up. Whereas the MIDI event goes through a totally different path to get out of the computer.

To account for different audio latencies, you can use `set_audio_latency!` which will adjust the timing of the sound events _independently_ of the MIDI events, so you can fine tune your specific system if necessary.

Hope that this helps 🙂

---

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 25, 2019, 2:42pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/8 "2019-02-25T14:42:15Z")

</div>

Thanks for your message! thats whats im doing, but something is going wrong because the clock that receive mi midi thrue box is slower than the bpm of sonic pi, ill try to write again my syncs .

---

<div class="post-metadata">

**Author:** ![atrip](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/atrip/32/869_2.png) [@atrip](https://in-thread.sonic-pi.net/u/atrip)\
**Post date:** [February 25, 2019, 10:36pm UTC](https://in-thread.sonic-pi.net/t/how-to-send-midi-clock/2003/9 "2019-02-25T22:36:40Z")

</div>

POST DATA: writting use\_bpm 90 at the first of the code and inside the live\_loop it works better, is not ecxactly but is usable
