I need help with a Complex Buffer.read task

Dear Community,
I need up to 18 different Sound Files in a Super-collider Script.
All this Files are handled equal. They are a Set of Sounds which
are probably will get played.
So my Question is, is there any other nice Way to load this Files
rather then do it manually File by File.

A Thomas Lahme from CreCo will thanks in advance

It is simply not possible to answer this question well, we need more domain knowledge… are the sound files related, are they stored in a directory, do they need to be consecutive, are they the only files etc…

Also, do you actually mean SoundFile or Buffer, in supercollider we capitalise classes. I’m assuming you mean Buffer as SoundFile shouldn’t really be used by a user.

That being said, here is, what I would consider a pretty powerful generic approach…

~load_sound_files = { |...specification|
	// errors & warnings
	if( specification.collect({|ev| ev[\name] }).asSet.size != specification.size, 
		{ "specification's names must be unique".throw });
	if( specification.collect({|ev| ev[\path] }).asSet.size != specification.size, 
		{ "some files are loaded twice".warn });
	
	specification.collect({ |ev|
		(ev[\name].asSymbol : Buffer.read(s, ev[\path]) )
	}).reduce('++');
};


~sounds = ~load_sound_files.(
	(name: \fileA, path: 'path/to/file/a'),
	(name: \fileB, path: 'path/to/file/B'),
	(name: \fileC, path: 'path/to/file/C'),
	(name: \fileD, path: 'path/to/file/D'),
	(name: \fileE, path: 'path/to/file/E')
);

// as an example of usage
~sounds[\fileE].plot;

{ PlayBuf.ar( ~sounds[\fileA].numChannels, ~sounds[\fileE], doneAction: 2) }.play;

Excuse me for my little stupidity.
But ~load_sound_files
seems to me like a User defined Function.
So I would need the Code for this Function.
But at first, yes it is like this thing what I need

Ok I’m very stupid at the moment.
You have give me the whole Function.
A last Question how can I random chose one of this Bufers.

My old Routine to do it is:

Routine.run({
// Stream for chose one Buffer of Sound to Chose
a = Prand([~b1, ~b2, ~b3], inf).asStream;
c = Synth(\help_PlayBuf, [\bufnum, a.next, \temp, 1 ]);
// Loop for ever to change Play Rate and Bufer to play
loop({
c.set(\temp, -4.4.rand2.round(1), \bufnum, a.next);
// Litle wait to next Change
1.wait;
})
})

Many ways, ~sounds is just an event.

~sounds.choose;

Prand(~sounds.asArray, inf).asStream

So I would have just used an array if that is your only use case. That is why more context was needed to be able to answer your question properly. If you don’t care about the names of the buffers and and viewing them as a collection of variations, I’d do this…

~sounds = [ 
	'path/a', 
	'path/b', 
	'path/c'
].collect( Buffer.read(s, _) )

Jordan thanks for your grateful help.
Just my little Script runs as aspected.

A wonderful happy Thomas Lahme from CreCo