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)
// 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