Support for din sync

I want to request some way to control Roland DIN sync hardware, ALM makes a din cable with two 3.5 jacks one for start stop messages and one for clock I believe, since supercollider is hard to sync externally, might be nice to sync outboard gear. I could send a trigger to the the Alm Pamela workout, but I’d rather keep it simple and just use expertsleepers for everything. I’m the only one asking so it probably won’t get support, but it would be cool

I guess you could record the output of the two jacks that deal with din sync on the Alm Pamela , and just send those signals , maybe it’s that simple.

SuperCollider is actually not too hard to sync, you can take a look at e.g. LinkClock | SuperCollider 3.13.0 Help

But if you are interested in using sclang/scsynth as a din sync clock source, you can simply generate the necessary signal on the server and use two outputs of your audio interface for it. I don’t have DIN Sync equipment, so I couldn’t test it, so maybe use it more as an inspiration?


(
SynthDef(\dinSync, {|out, t_gate=1|
	// use pinout from https://en.wikipedia.org/wiki/DIN_sync#Pinouts
	var tip = Env(
		levels: [0, 1, 0],
		// min gate times
		times: [0.001, 0.001],
		curve: \hold,
		releaseNode: 1,
	).ar(gate: t_gate);
	var sleeve = K2A.ar(\playing.kr(0.0));
	var sig = [
		// clock needs to be delayed by 9ms?
		// we also only output the clock if we are playing
		DelayN.ar(tip, maxdelaytime: 0.009, delaytime: 0.009) * sleeve,
		sleeve,
	];
	// adjust amp in such a way that your output matches 5v
	Out.ar(out, sig * \amp.kr(0.2));
}).add;
)

// lets create a bus so we can scope the signal it w/o blasting our speakers
~clockBus = Bus.audio(server: s, numChannels: 2);
~clockBus.scope;

// only start this once? I get problems when wrapping
// this into a Pdef :/
// if you want to modify while its running you could use pdefn
(
Pmono(\dinSync,
	// din sync uses 24ppq
	\dur, 1/24,
	\playing, 1.0,
	\out, ~clockBus,
	\legato, 0.01,
	\gate, 1.0,
	// taking account for the delay on the clock
	\lag, -0.009,
).clock_(TempoClock.default).play
)

// output the clockBus on your soundcard at output 3 and 4
// change accordingly
~clockBus.play(target: 2);

// playback something from scsynth based on the same clock

(
Pdef(\ref, Pbind(
	\dur, 1.0,
	\legato, 0.1,
)).clock_(TempoClock.default).play;
)

// change tempo - should be 90bpm
TempoClock.default.tempo = 1.5;

You could also use the DIN-Sync clock as your reference clock, I wrote something similar for eurorack based clocks once, see EuroClockIn in GitHub - capital-G/EuroCollider: SuperCollider extension for communcation with Eurorack modules

Din sync has start and stop messages, I’m
Not entirely sure what they are. I had a cable that output din sync pulse but it didn’t work cause i believe the messaging wasn’t transmitted , thank you for all that code, wow,
I’ll get back to you when I have it all hooked up.

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

2 Likes

According to wiki it is 5V on DIN pin 1 or the ring of of a TRS.

There are some things to keep in mind here:

a) You need to output a constant DC of 5V - many interfaces do not allow for such a thing, the interface needs to be DC-coupled, see the section Supported audio interfaces in EuroCollider | SuperCollider 3.13.0 Help
b) You need to adjust the volume so that your output matches 5V - as LineLevel is 1V your interface needs to be able to output beyond Line Level - again, not every interface can do this.

1 Like

Sounds very complicated. Might be better just to get a Pamela’s New workout and use its Din outs. It’s got trigger in for a master. I need to save money up, but I planned on using the ES-8 from expert sleepers with SC. I just have a 606 right now. Might get a 101 later. If I hit the lotto an 808 but one can dream, (ive heard the clones I don’t think they sound as good)