How to send MIDI CLOCK


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


Check out the midi_clock_tick and midi_clock_beat commands in the documentation.


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


live_loop :clock do
sleep 1

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


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. 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.


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


Hi @atrip,

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

live_loop :foo do
  sleep 1

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 :slight_smile:


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 .


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