Ndef with GUI and some weired questions about control spec

I have some simple questions about regulating the preset values of Ndef.

My Idea is to set a preset, in GUI, like 0 to 1, to control the several parameters in the Ndef.

  1. when I run the Ndef, It seems preset values keep changing is there any method to set the range of the “preset” value?

  2. while I test with gui with parameters and when I like the specific position, Is there any method to write or send code SC Ide like Ndef(\test).set(\freq, #specific value, \amp, #specific value)?

  3. It is a bit weird question. For example, in GUI, start with freq 440, amp 0, and then move the freq slider to 220 and amp 1. After that, change the preset values with a specific amount. In this case, I move slider 0 to 1, then store both values bound in the preset, and the next time, when I move to a slider from 0 to 1, it changes the whole range, and 0 to 0.5 it applies the half amount of values in both parameters (\freq, \amp). What I am curious about, is dynamically saving both parameters at once, with recent movements in preset arguments. Is that possible in SC?

Ndef('test', {
	arg preset;
	var snd;
	//preset.linlin(0, 10, 0,1);
	snd = SinOsc.ar(\freq.kr(440), mul:\amp.kr(0.5));
	//Out.ar(0, snd);



Ndef(\test).set(\freq, 220, \amp, 0).gui;

Yes, take a look at ControlSpec which would translate to

Ndef(\foo, {
	var param = \param.kr(
		val: 0.0,
		spec: ControlSpec(
			minval: 1.0,
			maxval: 10.0,
			warp: \lin,
			step: 1.0,
			default: 1.0,
	SinOsc.ar(\freq.kr(200) * param) * \amp.kr(0.2);

Just a reminder - do not use Out within an Ndef directly - it will screw up their routing as Ndefs handle Out interally :slight_smile:

Maybe it is worth to take a look at the JITLib extionsions Quark and its source code which also provides a setup for morphing between presets, see ProxyPreset | SuperCollider 3.13.0 Help

Also consider taking a look at the Influx quark, which introduce meta-presets by entangling parameters, see Influx | SuperCollider 3.13.0 Help and Ndef.xset - NodeProxy | SuperCollider 3.13.0 Help

1 Like

thanks I will look on in :slight_smile:
I’ve posted because Idk where I could find the solution what I have

and for the Ndef Out,
how do I set a specific speaker to set an Ndef?
For instance, 4 or 8 speakers to send a specific speaker set up?

The .play method of an Ndef allows to set an out argument which will be used for playback, so

Ndef(\foo, {
	SinOsc.ar(\freq.kr(200.0)) * \amp.kr(0.2);
}).play(out: 1);

will be played back on the right channel.

If you want to do something more advanced there are multiple ways of doing so, but I found one good pattern is to use mixer Ndefs, for example

Ndef.ar(\evenSig, numChannels: 1);

Ndef(\evenChannels, {|in=0|
	[Ndef.ar(\evenSig, numChannels: 1), Silent.ar].dup(4).flatten;

Ndef.ar(\unevenSig, numChannels: 1);
Ndef(\unevenChannels, {
	[Silent.ar, Ndef.ar(\unevenSig, numChannels: 1)].dup(4).flatten;

Ndef(\main, {
	Ndef.ar(\evenChannels, numChannels: 8) + Ndef.ar(\unevenChannels, numChannels: 8);
}).play(out: 0);

// set some signal on uneven sigs
Ndef(\unevenSig, {Ringz.ar(Dust.ar(4.0), LFDNoise0.kr(1.0).exprange(100, 1200), 1.0)*0.2});


// and some other on all even sigs
Ndef(\evenSig, {SinOsc.ar(SinOsc.ar(SinOsc.ar(0.5, phase: SinOsc.kr(0.5))).exprange(100, 200)) * 0.2});

// fadeout
Ndef(\main).stop(fadeTime: 10.0);