Merging multiple subfolders in Dictionary - is it possible?

Dear all,

Taking the opportunity to wish everyone a Happy New Year here, I would like to ask you for help in using multiple audio sample subfolders.

I’m using a script based on Fieldsteel’s work to store samples.

//Sounds
~b = Dictionary.new;
PathName("D:/superCollider/evoeExpeSC/soundScapes/").entries.do{
	arg subfolder;
	~b.add(
		subfolder.folderName.asSymbol ->
		Array.fill(
			subfolder.entries.size,
			{
				arg i;
				Buffer.read(s, subfolder.entries[i].fullPath);
			}
		)
	)
};
)

there are four subfolders in /soundScapes: ‘arousalL/’, ‘arousalH/’, ‘valenceL/’, and ‘valenceH/’ (each of them with 13 audio samples).

To call samples I am using, for example, the SynthDef:

(
SynthDef(
	"someDef",
	{arg amp = 1, bRS = 1, pan = 0, whichBuffer = 0;
		Out.ar(
			0,
			Pan2.ar(
				PlayBuf.ar(
					1,
					whichBuffer,
					bRS  * BufRateScale.kr(whichBuffer),
					doneAction:2),
				pan,
				amp * 0.75
			);
		);
	}
).send(s);
)

and I have created global ~soundChoose object to specify the sample folder

(
~pwPlay = Task({
	~pwPlayInner = Task({
		{
			Synth.new(
				"someDef",[
					\pan, [rrand(-1.0, 1.0), -1, 1, 0].wchoose([0.71, 0.08,
						0.08, 0.13]),
					\amp, rrand(0.91, 0.99),
					\whichBuffer, ~soundChoose[(0,1..(~soundChoose.size-1))].choose.postln,
					\bRS , (rrand(0.013, 1.25))], s,
				\addBefore
			);
			x = 11.rand;
			if (
				x < 7,
				{(rrand(0.05, 0.9)).wait},
				{(rrand(1, 1.15)).wait}
			);
		}.loop
	}.play);
});
)

to play Task:

~soundChoose = ~b['arousalL']; ~pwPlay.start;

When trying to specify at least two subfolders at the same time, I can only get the first sample of each subfolder with this line for example:

~soundChoose = [~b['arousalL'], ~b['valenceH']]; ~pwPlay.start;

Running:
~b[‘arousalL’].size; I get all the ‘13’ samples
[ ~b[‘arousalL’], ~b[‘valenceH’] ].size; I get the results ‘2’

Is it possible to use multiple subfolders specifically in this Dictionary (to get, for examples 26 audio samples using these two subfolders)?

Thank you so much for the attention!

You can merge two collections using the ++ operator:

(~b['arousalL'] ++ ~b['valenceH'])

This should let you pick from the union of both directories of files.

1 Like

@scztt
It worked!
wrongly, I was using ‘[ ]’ and ‘,’
very simple indeed!
Thank you so much!