Sync Oscillators in Ndef

I have a rhythmic Ndef with a LFO (LFTri, LFSaw) as reference for the beat. Obviously when I relaunch the Ndef the LFO in the new Ndef isn’t in Phase with the old Ndef.

Has anyone a good strategy to sync this?

Is there a convienent way to sync oscillators from Outside a Ndef, Synthdef etc. to global time, a masterclock or something similar.

cheers, Bernhard

Usually, I’ll do one of two things:

  • Use one Ndef with a universal time, and drive the other oscillators with it. You’ll end up re-creating LFSaw and friends yourself, but those ones at least are relatively easy…
Ndef(\time, { Phasor.ar(1, SampleDur.ir, 0, inf).poll });
Ndef(\lfsaw, { 
	((\time.ar / \freq.kr.reciprocal) % 1.0).poll
}).play;

Ndef(\lfsaw).set(
	\freq, 10.1,
	\time, Ndef(\time).asMap
);
  • Stick all my “synced” oscillators in a single Ndef, so that they’re all restarted together:
Ndef(\oscs, { 
	[
		LFSaw.ar(10),
		LFTri.ar(10),
		LFCub.ar(10),
	]
});

Ndef(\sound, {
	var freq = 400;
	SinOsc.ar(
		freq * (1 + \mod.ar.linlin(0, 1, -0.1, 0.1)) 
	)
}).play;

Ndef(\sound) <<>.mod Ndef(\oscs).asMap[1]