Args for index numbers in a proxy gives me an error

I am sure there is a really easy answer to this.

I am trying to replace an index number with an argument in a node proxy so that I can update the index number with .xset. But it keeps giving me an error. What am I doing wrong? Thanks for any help

t = TempoClock.new(120/60);
t.permanent_(true);

(
p = ProxySpace.new(s, clock: t);
p.push;
)

t.beats;

//Create a new pathway to the folder containing the sounds...

//e is a pathway to the folder with the sounds inside

e = PathName.new("/Users/mls1/Documents/Research 2019/Rethinking the Musical Instrument/SuperCollider Environment/guitar_samps/");

//For all the files in the path, add them to our empty array...

(
e.entries.do({
	arg path;
	d = d.add(Buffer.read(s, path.fullPath))});
)

//The folder is now filled with the buffers...
d;

//play a sound at a particular index...
d.at(2).play;

//This is the same thing (syntax shortcut)...

d[2].play;

~play;
~play.fadeTime_(4);

~play.play;

(
~play = {
	|index = 2|
	var sig;
	sig = PlayBuf.ar(1, d[index], loop:1); //this is where I get the error. An index number works, but an argument causes an error
	sig = Splay.ar(sig);
}
);

~play.release;
~play.send;
2 Likes

hey there,

you could use Select.kr like the following:

(
~play = {|index = 2|
	var sig, buf;
	buf = Select.kr(index, d);
	sig = PlayBuf.ar(1, buf, loop:1); 
	sig = Splay.ar(sig);
}
);

hope this helps :slight_smile:

That works! Genius! Thanks so much.