FluidLoadFolder hack: setFilesArray method


This might also belong in the New-Ideas thread.

I wanted to load a bunch of sound files, but realized they were not in the same folder (or even on the same hard drive), but I like what FluidLoadFolder returns so much. So I hacked it a bit to allow for the user to provide the array of SoundFile instances, rather than have the class create it from the folder.

My FluidLoadFolder class now looks like this (just the first 23 lines or so as that’s where the changes are):

FluidLoadFolder {
	var  path, labelFunc,channelFunc;
	var < files;
	var < index;
	var < buffer;

	*new{ |path, labelFunc, channelFunc |
		^super.newCopyArgs(path, labelFunc,channelFunc);

	setFilesArray {
		arg files_array;
		files = files_array;

	play { |server, action|
		var sizes,channels,maxChan, startEnd,counter;
		server ?? server = Server.default;

		//"files: %".format(files).postln;
			files = SoundFile.collect(path +/+ '*');

and usage might look like this (~paths is an array of strings that are file paths):

~files = ~paths.collect({
	arg path;


~loader = FluidLoadFolder();


1 Like

Very nice! I was wanting this.

1 Like

Good thinking @tedmoore. I might be inclined to keep it as an argument but

  1. change the class to FluidLoadSounds to be more accurate
  2. accept either an array or a single element in path which can be either a string / symbol or a SoundFile. If strings / symbols point to folder(s) then we can load everything in them, otherwise they can point to single files instead (so yet another feature).
1 Like

Yeah, keeping some functionality like that would be excellent.

Also, something for selecting paths would be great (or people can just use this one).

It can take a string as a single folder path or an array of strings that are files or folders and recursively (or not) grab all the files in that purview, filter them for certain extensions, and then return an array of those file paths. I find myself using this all the time!


1 Like