Ndefs & Patterns (Pdefs)

Hello dear Forum,

I am struggling with Ndefs and Patterns. I would like to use a Pattern to update values of an Ndef, while also being able to change the Ndef if I want to. I found this way using the \filter-method to do it (Ex.1), but it seems quite bulky and I am not 100 percent happy as it also doesn’t produce reliable results e.g. when I set the \freq-key on the Ndef (Ex. 2)

Ex.1 :

Ndef(\jojo, {SinOsc.ar(\freq.kr(200))}).quant_(4).play;
(
Ndef(\jojo) [1] = \set -> Pbindef(\jojopattern, \freq, Pseq([200,300],inf))
  )
Pbindef(\jojopattern, \freq, Pseq([300,400], inf));
Pbindef(\jojopattern, \freq, 400);

Ex.2:
Setting the \freq via the Ndef doesn’t allow me set it again via Pbindef.

Ndef(\jojo, {SinOsc.ar(\freq.kr(200))}).play;
(
Ndef(\jojo) [1] = \set -> Pbindef(\jojopattern, \freq, Pseq([200,300],inf));
  )
Pbindef(\jojopattern, \freq, Pseq([300,400], inf));

Ndef(\jojo).xset(\freq, 100);

Pbindef(\jojopattern, \freq, Pseq([300,400], inf)); —> NO RESULT ANYMORE 

:disappointed:

Does anyone know of any better way how to flexibly interact with both Patterns and Ndefs?
I would be very happy about any leads, thank you :heart:

2 Likes

i think if you set \freq to nil the value in the pattern will work

Ndef(\jojo).xset(\freq, nil);

Oh thank you for this, that works now :slightly_smiling_face:

However I am still a bit stuck with my previous question – is there any better way to use Pbinds on Ndefs than via the \filter-method?

Ndef(\jojo, {SinOsc.ar(\freq.kr(200))}).play;
(
Ndef(\jojo) [1] = \set -> Pbindef(\jojopattern, \freq, Pseq([200,300],inf))
  )

Maybe using pset NodeProxy role helps?

// make sure the environment is clean
Ndef.clear

// declare an ndef so we can overwrite it later
Ndef.ar(\jojo, numChannels: 2);
// and play it - it will be silent
Ndef(\jojo).play;

// add something to the nodeproxy
Ndef(\jojo)[0] = {SinOscFB.ar(\freq.kr(200.0), feedback: \fb.kr(0.0))!2 * \amp.kr(0.2)}

// add a pset
(
Ndef(\jojo)[1] = \pset -> Pbind(
	\dur, Pseg([0.1, 0.5], durs: 10, curves: \exp, repeats: inf),
	\freq, Pseq([100, 400], inf),
	\fb, Pseq([0.1, 0.5, 1.2], inf),
)
)

// change the base nodeproxy - pattern will still continue
Ndef(\jojo)[0] = {SinOscFB.ar(\freq.kr(200.0), feedback: \fb.kr(0.0))!2 * \amp.kr(0.2) * SinOsc.ar(40.0)}

// update the pset
(
Ndef(\jojo)[1] = \pset -> Pbind(
	\dur, Pseg([0.1, 0.5], durs: 10, curves: \exp, repeats: inf),
	\freq, Pseq([3000, 400, 100, 200, 500], inf),
	\fb, Pseq([0.1, 0.5, 1.2], inf),
)
)

// if you do this, it will replace the whole stack of node proxies,
// so the \pset would be gone.
Ndef(\jojo, {SinOscFB.ar(\freq.kr(200.0), feedback: \fb.kr(0.0))!2 * \amp.kr(0.2) * SinOsc.ar(40.0)})

Ndef.clear

2 Likes