I’ve created this code that loads a bunch of samples/buffers from your samples folder into a Dictionary. This borrows heavily from what I’ve seen Eli Fieldsteel do in his streams.
What I modified was being able to also load samples from nested folders within the subfolders.
s.waitForBoot({
var subfolderstemp, subfolders1, subfolders2,path, dictionary;
d = Dictionary.new;
path = PathName(thisProcess.nowExecutingPath).parentPath;
subfolderstemp = PathName(path ++ "mainsamplefolder/").folders;
subfolders1= [];
subfolderstemp.do{arg n, i;
case { n.entries[i].isFile} {subfolders1=subfolders1.add(n)}
};
subfolders2=[];
subfolderstemp.do{arg n, i;
case { n.entries[i].isFolder} {subfolders2=subfolders2.add(n)};
};
subfolders2= subfolders2.collect{arg n,i; n.folders}.flat;
subfolders1.do{
arg dir;
d.add(
dir.folderName.asSymbol ->
Array.fill(
dir.entries.size,
{
arg idx;
Buffer.read(s, dir.entries[idx].fullPath);
}
)
);
};
subfolders2.do{
arg dir;
d.add(
dir.folderName.asSymbol ->
Array.fill(
dir.entries.size,
{
arg idx;
Buffer.read(s, dir.entries[idx].fullPath);
}
)
);
};
});
//test:
d[\nested][0].play
d[\subfoldersound][0].play
- the .scd document must be saved in a folder (projectfolder) together with the samples folder
ProjectFolder
- document.scd
- samplefolder
→ subfolder1 that contains soundfiles
→ subfolder2
-nestedfolder1 that contains soundfiles
-nestedfolder2 that contains soundfiles
I’ve got it to work a day or two but now it doesn’t really work and I am not sure if it is something with my windows system. I can no longer get it to respond to isFile and isFolder.
Maybe there is an altogether (more) clever way of loading nested folders but am curious of people have similar problems with isFile and isFolder (on a windows system)