FluidBufOnsetSlice: Writing indices to a file?

Hello all,

im trying to write onset indices to a file to be read later by a Buffer UGen.
In the following example the file gets written but its empty. Theres probably something obvious in the file writing im missing?
(Im also unsure whether audio would be the right format for the onset data…)

(
//prep some buffers
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
c = Buffer.new(s);
)

(
// with basic params
Routine{
    t = Main.elapsedTime;
    FluidBufOnsetSlice.process(s,b, indices: c,metric:7, threshold:0.1).wait;
    (Main.elapsedTime - t).postln;
}.play)

c.query
c.plot

c.write(Platform.resourceDir +/+ "sounds/onsets.aif")

d=Buffer.read(s, Platform.resourceDir +/+ "sounds/onsets.aif")
d.query
d.plot

Thank you,
Jan

apparently the data gets written if the buffer is normalized:

c.normalize
c.write(Platform.resourceDir +/+ "sounds/onsets.aif")
d=Buffer.read(s, Platform.resourceDir +/+ "sounds/onsets.aif")
d.plot

but then the indices would have to be converted back from the normalized range to be useful as onsets.
there surely must be a way to write the original buffer as such without range conversion?

Hi @jan,

You’ll need to write out as floats, otherwise the values, which will all be > 1 in all likelihood, will be clipped.

c.write(Platform.resourceDir +/+ "sounds/onsets.aif", sampleFormat:"float32") 

Hi Owen,
so that was it, simple matter really!
Thank you for getting back!
Jan

2 Likes