is there a way to set a path to load files from a directory not by their names, just by their index?
trying to be able to load files from folders that have unspecified names in a Pproto setup ( i know its shortcomings but still need it;)).
this way it’ll presuppose the numbers in the names’ characters to find it. im rather looking to load the 1st, 5th, 7th file in the folder into buffers.
this way it’ll presuppose the numbers in the names’ characters to find it. im rather looking to load the 1st, 5th, 7th file in the folder into buffers.
although this way it’s a bit inefficient (multiple calls to pathMatch). so perhaps like this instead…
(
var paths= "~/Documents/soundfiles/*.wav".pathMatch; //edit path
~buffers.do{|b| b.free}; //make sure to free any previous buffers
~buffers= List.new;
[1, 5, 7].do{|i| //select which files to load by index
if(i<paths.size, {
~buffers.add(Buffer.read(s, paths[i]));
}, {
"index % out of range".format(i).warn;
});
};
)
~buffers.do{|b| b.postln}
now pathMatch is only called once and there’s also a check if you try to pick an index that’s larger than then number of found soundfiles.
_f