I’m using this code to sync Ableton Live to Sonic Pi :
live_loop :clock do
use_bpm 135
midi_start if tick == 0
midi_clock beat
sleep 1
end
When stopping the code Ableton looses sync, as it should.
But this causes some troubles.
I would like to send a midi_stop command when (or slightly before) stopping the code to run.
Is there a solution for that ?
When stopping the code to run, Ableton sends a notice that it has lost its sync, and that it is turning it’s external sync option off. So when working on code in Sonic Pi, and stopping the code to run, for some reason, you have to check the external sync button again in Ableton, after clicking the warning message, etc. A lot of actions just to be able to start/stop your loops in Sonic Pi and not have to start up the whole sync setting procedure each time. I assume, that if a midi_clock_stop message was send, before the midi_clock message drops out, Ableton would stop running and would not bother about the sync message not longer being present on the midi stream. When using midi_clock with external hardware sequencers, I even do not need the midi_start function for them to be in sync. But Ableton needs some more midi info than those machines to get start/stop/external-sync working properly.
It should be just before the midi-clock drops out because of stopping to run the code. So, it should be sending the midi-stop message just before M-s gets effective
When hitting M-s, Sonic Pi will stop all running threads and also cancel all unsent MIDI messages. It doesn’t explicitly send any other messages out.
As an experiment, if you were to free up an empty buffer and put a MIDI stop call in it. Would it be a (very rough and ready) ‘solution’ to hit M-s, switch to your MIDI stop buffer and hit run? Is that the ordering of messages you’re looking to have happen?
This is another thing I’ve thought to ask for. The MIDI Transport Stop command and midi_all_notes_off when you stop SP. I have to turn off a microsequencer and stop stuck notes unless I hit stop at just the right time. The way I had thought about resolving it was to create a structure in a script that allows any arbitrary thing to happen as a one-shot when you hit stop, you could even code an outro into it or make it sleep 10 seconds so you can catch a long reverb or echo to the end.
I am at ADE Amsterdam, so not much time atm, sorry for delay in testing. Yes, that works. That’s exactly the ordering of messages I’m looking for to happen.