Filling many buffers from a list of onsets

Hi,

I know this should be a simple task but I’m stuck. I’m basically using FluidBufOnsetSlice from FluCoMa for chopping up a fairly long sample and trying to fill a series of buffers with all the chunks. What I have is a list of onsets, in another buffer (~indices). I’ve been trying differents ways but none worked, I can’t seem to extract the values correctly from the indices buffer. Latest try:

(
~srcPath = xxxxxxxxxx.wav;
~source = Buffer.read(s, ~srcPath);
~indices = Buffer(s);
)

(
~slicing = {
	FluidBufOnsetSlice.processBlocking(
		s,
		~source,
		startChan: 0,
		numChans: -1,
		indices: ~indices,
		metric: 0,
		threshold: 0.5,
		minSliceLength: 2,
		filterSize: 10,
		frameDelta: 0,
		windowSize: 512, 
		hopSize: -1,
		fftSize: -1,
		action: {
			"found % slice points".format(~indices.numFrames).postln;
			"with an average length of % seconds per slice".format(~source.duration / ~indices.numFrames).postln;
		}
	)
}.play;
)

// display
FluidWaveform(~source, ~indices);

// creating buffers for every slice
(
~slices = Array.newClear(2000);

(~indices.numFrames - 1).do {
	|i, start, dur|
	~indices.get(i, {|val| start = val});
	~indices.get(i + 1, {|val2| dur = val2});
	~slices.put(i, Buffer.read(s, ~srcPath, start, dur));
}
)

in this case it actually works but it’s broken: monitoring the values I get the cycle indices for the start argument (0 to 254 in this case) and for the dur argument I get all nils. This results in the buffers actually getting filled but with the sample only sliced from the start all the way to 254 samples, basically buffers containing the whole sample. Probably this has to do with the fact that I’m using start and dur in the get functions which are separate from the do function in which I declared them, but anyway all other approaches I tried have failed too. Haven’t coded in months and I’m getting rusty lol

Thanks in advance!

Hi,
Could you be more specific? What is the point of storing slices in the separate buffers when you can access directly with the indices, which is the purpose of FluidBufOnsetSlice.

I just wanted different buffers for easy use with patterns and the like but I’ll give it a try using BufRd to index through the slices, shouldn’t be much more complicated

For the record, here is one way to get your indices into an array:

~slices=[]; 
~slicing.loadToFloatArray(action: { arg array; ~slices = array.asInteger});

Then to get the duration you divide the difference of the adjacent indices by the sample rate.