# Ndef and Tdef syncing problem

Hello!

I am trying to sync a Ndef and a Tdef in order to make them start at exactly the same time when triggering.
For some reason, the Ndef.set starts before the Tdef. How can I make them start at exactly the same time? I guess it is a clock issue, but after several attempts, I couldn’t get any results. Here is a simplified version, where you can hear the Ndef.set hit first and then the Tdef following it with a delay when playing between 2 and 3:

//1
(
Ndef(\a).play;

Ndef(\a, { |freq,mult,amp,ampmult,pan|
Pan2.ar(SinOsc.ar(freqmult, 0, ampampmult),pan) });

Ndef(\a).set(\freq,100,\mult,2,\amp,0.5,\ampmult,2,\pan,1);
)

//2
//run this

(
~k=[Pseq([1,5,2,1,5]),Pseq([0.1,0.5,0.2,0.1,0.5])];

Ndef(\a).set(\freq,100,\mult,2,\amp,0.5,\ampmult,2,\pan,1);

Tdef(\x, {
var pattern;
pattern = ~k.size.collect{|i|
~k[i].loop.asStream};
inf.do({
Ndef(\a).set(
\mult, pattern[0].next,
\ampmult, pattern[1].next);
0.02.wait;
})};).play;
)

//3
//then this
(
~k=[Pseq([1,5,2,1,5]/2),Pseq([0.1,0.5,0.2,0.1,0.5])];

Ndef(\a).set(\freq,1000,\mult,2,\amp,0.5,\ampmult,2,\pan,1);

Tdef(\x, {
var pattern;
pattern = ~k.size.collect{|i|
~k[i].loop.asStream};
inf.do({
Ndef(\a).set(
\mult, pattern[0].next,
\ampmult, pattern[1].next);
0.02.wait;
})};).play;
)

Thank you!