Hi all,
I load a folder full of samples as Buffers into a List:
var smpPath = PathName(thisProcess.nowExecutingPath.dirname +/+ "smp");
~smpBuffers = List();
smpPath.filesDo({ |smpfile,i|
~smpBuffers.add(Buffer.readChannel(s,
smpfile.fullPath, channels:[0]));
});
I end up with a List that contains Buffer objects. Something like
~smpBuffers.postln;
-> List[ Buffer(0, 600, 1, 44100.0, /path/to/bassdrum.wav),
Buffer(1, 600, 1, 44100.0, /path/to/fieldrecording.wav),
Buffer(2, 600, 1, 44100.0, /path/to/flute.wav) ]
I can access it in a synth with .at()
method:
y = Synth(\granulator, [\bufnum, ~smpBuffers.at(0)])
But if in the process of working on larger work, I add more samples in the folder (or remove them because they are not in use), indices in the list will get messed up.
Is there a way to ‘match’ a filename that Buffer objects in the list actually know about? So, in above context I would ideally love to do something like:
y = Synth(\granulator, [\bufnum, ~smpBuffers.match('*fieldrec*')])
I know how to create a separate parallel List with just filenames and then cross-match indices with a full filename, but I’m looking for specific way to match within that single list of Buffer objects.
Or is there a better way to work with big collections of samples?