Closed pwqw closed 6 years ago
Hmm. There's a little bit in the ProxySpace docs here about it under 'nodeproxy with numbers as input', but it doesn't seem to do what the document suggests it does...
What will using an array of proxies give you, just so I have an idea? e.g. why not just this:
(
~s0 = Pbind(\instrument,\default,\dur,Pseq([0.5,Pseq([1],inf)],inf),\amp,1);
~s0.play;
~s1 = { Pulse.ar(130, Saw.kr(0.3)) * 0.1 };
~s1.play;
// Then be able to change:
~s0 = Pbind(\instrument,\default,\dur,Pseq([0.5,Pseq([0.25],inf)],inf),\amp,1);
)
Yes, nodeproxy with numbers as input isn't clear.. Array of proxies is more dynamically for control the volume with midi knobs, for example. Or iterate with a Task and changing randomly each node
// The initial solution is
p = ProxySpace.push(s.boot);
(
m = Dictionary.new;
m.add(\assign -> { |i, val| switch( i,
0, { ~s0 = val },
1, { ~s1 = val },
2, { ~s2 = val },
3, { ~s3 = val })
});
m.add(\play -> { |i| switch( i,
0, { ~s0.play },
1, { ~s1.play },
2, { ~s2.play },
3, { ~s3.play })
});
m.add(\set -> { |i, name, val| switch( i,
0, { ~s0.set(name, val) },
1, { ~s1.set(name, val) },
2, { ~s2.set(name, val) },
3, { ~s3.set(name, val) })
});
)
// Then..
m[\assign].value(0, { |freq=500, ffreq=120| SinOsc.ar(freq*[1,1.1], SinOsc.ar(ffreq, 0, pi), 0.2) });
m[\play].value(0);
m[\set].value(0, \freq, 400+100.rand2 );
Okay, finally getting back to this. The reason Proxies don't work in an array is because of this.
http://doc.sccode.org/Reference/NodeProxy_roles.html
You use the array indexes for performing various roles upon NodeProxies. Got tipped off about this recently by @datamads and @lvm
So, for example, if you wanted to add a effects to ~s
you would use \filterIn
~s[0] = Pbind(\instrument,\default,\amp,0.3);
~s.play;
//add reverb
~s[1] = \filterIn -> {|in| FreeVerb.ar(in,0.6,0.9,0.2)};
//add delay to that
~s[2] = \filterIn -> {|in| CombC.ar(in,0.3,0.2,10)};
//change the wet/dry of `~s[2]` as CombC doesn't pass the original signal
~s.set(\wet2,0.5)
I'll be adding a section about this because it really changes how i've been using effects.
It is a good feature anyway!! :smiley:
For my part, I solved it using a ProxySpace in a variable, then building the Symbol, for ejample:
var func;
p = ProxySpace.new(s);
func = { |index|
var node = ("s" ++ index).asSymbol; // basically
p[node] = { Pulse.ar(130, Saw.kr(0.3)) * 0.1 };
p[node].play;
};
func.value(1);
Thanks a lot!
Do you know any way to apply proxies more dinamically in arrays, list or something?