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.

~b =;
	arg subfolder;
		subfolder.folderName.asSymbol ->
				arg i;, 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:

	{arg amp = 1, bRS = 1, pan = 0, whichBuffer = 0;
					bRS  *,
				amp * 0.75

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

~pwPlay = Task({
	~pwPlayInner = Task({
					\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,
			x = 11.rand;
			if (
				x < 7,
				{(rrand(0.05, 0.9)).wait},
				{(rrand(1, 1.15)).wait}

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;

~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

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