Web search “din sync” → wikipedia → image of the usage of the 5 pins: DIN sync - Wikipedia
That is… there are no “messages.” There are pulses (low vs high voltage). The pulses acquire meaning based on which pin/cable they are going through. High voltage on pin 1 = running; low voltage on pin 1 = stopped. Pulses on pin 3 are the clock, etc.
For external sync to hardware, I wrote a sclang commandline utility to run MIDI clock. Using MIDI clock, the time between clock messages is rather short – 24 ppq at 120 bpm = 48 pulses per second = 20.83333 ms per pulse – less than that at a faster tempo. If everything is running in the same sclang instance, one long-running calculation could cause outgoing clock messages to be delayed. So I split it into two sclang processes, and sync clocks between the two.
midiclockout.scd (3.5 KB)
cd ~/path/to/scd/scripts
sclang -u 57130 midiclockout.scd 'midi-out-device-partial-match' 135 0.2 LinkClock
- MIDI out device (partial string match is okay)
- bpm
- server latency
- clock class (LinkClock by default)
LinkClock should be fine if the two sclangs are running on the same machine. Then, on your performance sclang, TempoClock.default = LinkClock.new.latency_(0.2 - (64 / s.sampleRate))
and done. (If there are other Link peers on other machines, this might introduce some jitter – never tried both Link + MIDI sync at the same time, though.)
I’ve done a couple of shows with SC + Digitakt this way – solid, trouble-free.
This summer, I made a second version that outputs Eurorack style clock pulses with barline sync too.
audioclockout.scd (4.6 KB)
- audio out channel (default = 2)
- bpm
- latency
- clock class
- ppq
- beatsPerBar (I should add this to the MIDI clock one!)
sclang -u 57130 audioclockout.scd 2 135 0.2 LinkClock 16 4
So hardware out 2 gets 64th-note pulses (use a clock divider to get 16ths), and hw out 3 gets 4-beat pulses (“reset” input). For DIN sync, you’d need to change the barline signal into a steady high voltage.
For analog-style clock pulses, the second sclang may be overkill because server messaging latency should absorb jitter. But it’s not a bad utility to have.
hjh