Use NDef with Tidal

I really should dig deeper into how SuperDirt makes use of environmental variables.
That part of SC has always seemed a bit esoteric..

Perhaps you could document it on the way :blush: ...

Hmm, how would I get the Ndef to work with global effects?

simple solution:


d1 $ s "myNdef bd"
   # hcutoff "<3000 700 900>"
   # hresonance "0.4"


Ndef(\x, { Decay.ar(Dust.ar(4000), 0.01) * PinkNoise.ar(0.5) * 0.1 });

~dirt.soundLibrary.addSynth(\myNdef, (instrument: \dirt_from, in: Ndef(\x).bus)); 

I'm running into some problems when trying to put both instrument: and play:
in the same Event. Any way around this?

Yes, play replaces any other functionality. I'll allow us to add a playInside function, but I have to ponder about how is the best interface.

For now a hack:


Ndef(\x, { Decay.kr(\trig.tr, 0.1) * PinkNoise.ar });
~dirt.soundLibrary.addSynth(\myNdef, (instrument: \dirt_from, in: Ndef(\x).bus, diversion: { Ndef(\x).set(\trig, 1); nil })); 



OK, here is a new feature. I've added the examples to hacks/function-hacks.scd

// the playInside function


// example: start a synth explicitly


(
SynthDef(\plick, { |out, freq = 220, amp = 0.1, sustain = 1|
	var sig, env;
	env = EnvGen.ar(Env([0, amp, 0], [0.001, sustain]), doneAction:2);
	sig = SinOsc.ar(freq, LFNoise2.ar(XLine.kr(39, 300, sustain), Line.kr(15, 0, sustain)));
	Out.ar(out, sig * env);
}).add;


~dirt.soundLibrary.addSynth(\plack,
	(playInside: { |e|
		// make sure that you play it in the group and to the out
		(instrument: \plick, out: ~out, freq: ~freq, amp: ~amp, group: ~group).play
	})
)

)

// in tidal
d1 $ s "plack bd"
   # freq "<677 1000 200 7000>"
   # hcutoff "<3000 700 900>"
   # hresonance "0.05"


// example: trigger and route an Ndef from tidal

(
Ndef(\x, { Decay.kr(\trig.tr(0), 0.1) * PinkNoise.ar });

~dirt.soundLibrary.addSynth(\myNdef, (playInside: { |e|
		Ndef(\x).set(\trig, 1);
	// make sure that you play it in the group and to the out
		(instrument: \dirt_from, in: Ndef(\x).bus, out: ~out, amp: ~amp, group: ~group).play;
})
)
)

// in tidal
d1 $ s "myNdef bd"
   # hcutoff "<3000 700 900>"
   # hresonance "0.4"

Nice! I replaced my core-modules.scd with the new one and it seems to be working.

Viewing s.plotTree shows that every event adds a new instance of \dirt_from.
The SynthDef doesn't seem to have a doneAction:
Would adding like a DetectSilence.ar in there break a bunch of stuff?

I realize now that a DetectSilence.ar probably wouldn't make a difference.
There is also some combing going on so seems to be duplicating the signal.

The synth should be ended by the gate-synth, you don't need any doneAction there. My mistake was that I sent it to ~group instead of ~synthGroup.

This should work:

(
Ndef(\x, { Decay.kr(\trig.tr(0), 0.1) * PinkNoise.ar });

~dirt.soundLibrary.addSynth(\myNdef, (playInside: { |e|
	Ndef(\x).set(\trig, 1); // trigger the \trig control
	Ndef(\x).wakeUp; // make sure the Ndef runs
	// make sure that you play it in the group and to the out
	(
		instrument: \dirt_from,
		in: Ndef(\x).bus,
		out: ~out,
		amp: ~amp,
		group: ~synthGroup
	).play;
})
)
)

Perfect! This opens up a bunch of possibilities I think. Having a "static" node to interact with
is gonna be great for more complex sound design. I always hit the server cap when handling heavier SynthDefs.

1 Like

Yes, continuous sound generation also sounds differently overall.

Hey! sorry for reviving this thread xD

I was testing this code but i can still hear a click every time i send frequency data from tidal.

Is there a way to have this be trully continuous and get rid of the click?

This is the example i am using:

(
Ndef(\x, { SinOsc.ar(110) });

~dirt.soundLibrary.addSynth(\myNdef, (playInside: { |e|
	Ndef(\x).set(\trig, 1);
	Ndef(\x).wakeUp;
	(
		instrument: \dirt_from,
		in: Ndef(\x).bus,
		out: ~out,
		group: ~synthGroup
	).play;
})
)
)

also it also seems that the output for this is set to mono. Not sure how to make it stereo.

Thanks :slight_smile:

Why are you setting a trigger argument? Ndef(\x).set(\trig, 1);
Also the Ndef is mono, because the source is mono:

Ndef(\x, { SinOsc.ar(110) }); // <-- single channel SinOsc

make it stereo:

Ndef(\x).clear; // if you have run the above already, make sure it is reset neutral (otherwise, you can leave this out)
Ndef(\x, { SinOsc.ar(110 ! 2) }); // <-- stereo SinOsc
2 Likes