Syntax shortcut for multiple Buffer.read?

Hi!

Is there any syntax shortcut for reading a couple of buffer paths stored into an array (copy + pasted from the desktop environment) ?

Something like multichannel expansion:

(
# a, b, c, d = Buffer.read(s, 
	[
		"C:/Users/username/Documents/drum.wav",
		"C:/Users/username/Documents/perc.wav",
		"C:/Users/username/Documents/funk.wav",
		"C:/Users/username/Documents/piano.wav"
	]
);
)

In the case of working with environment variables, the most compact alternative would be this?

(
currentEnvironment.putEach([\edrum, \perc, \adrum, \piano], 
[
"C:/Users/username/Documents/drum.wav",
"C:/Users/username/Documents/perc.wav",
"C:/Users/username/Documents/funk.wav",
"C:/Users/username/Documents/piano.wav"
].collect(Buffer.read(s,_))
)
)

I don’t think so.

It is probably better to store them in an event within the environment.

~snds = (
   \funk : "path",
   ...
).collect( Buffer.read(s,_) )

Nevertheless, there is this option… I’m on mobile so can’t test, but this should work…

currentEnvironment = currentEnvironment ++ ~snds;
1 Like

I’d store the Buffers in an Array. If you want to use the names, an Event, as @jordan said, is a good solution. You could employ PathName, e.g.:

~path = PathName(/* path to folder with audio files */);

// array storage
~bufs = ~path.files.collect { |p| Buffer.read(s, p.fullPath) };

// event storage
~bufs = ();
~path.files.do { |p| ~bufs.put(p.fileNameWithoutExtension.asSymbol, Buffer.read(s, p.fullPath)) }


1 Like