[SuperCollider] Build a dataset without onset analysis and with recursive search

Hi!

I’ve been trying out the examples of Flucoma but I am a little bit lost about how to execute small modifications. As far as I have read, most of the code assumes that you either slice a long soundfile with an onset detector or load short soundfiles locates in a single folder (which will also be segmeted using something like FluidBufOnsetSlice).

So, first, how to build a dataset when you have a folder with already sliced audio (e.g. a sample library)?

Second, is there a built in way to recursive load all the audio files from folder and subfolders? Any Flucoma or Sc native implementation?

What I have found so far is this proposition on the list:
https://listarc.cal.bham.ac.uk/lists/sc-users/msg69330.html

This is the example I am trying to modify:

I am trying this without success:

(
~concatBuffers = {

  ~bigBuff = Buffer.alloc(s, 5*60 * s.sampleRate);
	PathName(~path).entries.do{
		arg subfolder;
		var counter = 0;
		subfolder.entries.do{
					arg item, i;
					var tempBuf;
					tempBuf = Buffer.read(s, subfolder.entries[i].fullPath);
       // FluidBufCompose.processBlocking(s, tempBuf, startFrame:counter,numFrames:tempBuf.numFrames,destination: ~bigBuff);
        FluidBufCompose.process(s, tempBuf, startFrame:counter,numFrames:tempBuf.numFrames,destination: ~bigBuff).wait;

					tempBuf.free;
					counter = counter + tempBuf.numFrames;
		}
	};
};

)

~concatBuffers.()

When using the .processBlocking I am getting the error:

ERROR: binary operator '+' failed.

When using the .process together with .wait I am getting the error:

ERROR: yield was called outside of a Routine.
ERROR: Primitive '_RoutineYield' failed.

Hi @John_C n=and welcome,

I don’t think you really need FluidBufCompose for this – just preallocating a Buffer after using SoundFile.collect should let you load up a set of files one after another

Some unpretty code:

s.boot
(
~files=SoundFile.collect("/Users/owen/dev/flucoma-core/Resources/AudioFiles/*");
~frames = ~files.collect{|f| f.numFrames}; 
~totalFrames = ~frames.sum; 
~buf = Buffer.alloc(s, ~totalFrames);
~frameCount = 0; 
~files.do{|f|
	~buf.readChannel(f.path, bufStartFrame:~frameCount, channels:[0]);
	~frameCount = ~frameCount + f.numFrames; 
};
)
2 Likes

Thanks! I didn’t know this SoundFile.collect("/*") trick!

I also have to load the indices of each “onset” (start frame of each sample) into a buffer for later usage with Flucoma algorithms. What is the way to do so? I am lost with that signal and wavetable buffer loading format…

It depends on how you want to access them later. If you just need an array of where each of the samples starts, you could allocate a new array with Array.newclear() passing in the number of samples you’re loading, and enter into the array at the sample’s index each starting index in the concatenated buffer as you load it from disk.

If you need to associate them with the file path or something, then a Dictionary might be better.