From 44c7170b3c85c43935e13fe051e1c0f85dfb0cb1 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Mon, 28 Oct 2019 15:45:55 +0000 Subject: [PATCH] the creative example of bufstats is now done --- .../HelpSource/Classes/FluidBufStats.schelp | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/release-packaging/HelpSource/Classes/FluidBufStats.schelp b/release-packaging/HelpSource/Classes/FluidBufStats.schelp index f7ce1c1..dbae2f0 100644 --- a/release-packaging/HelpSource/Classes/FluidBufStats.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufStats.schelp @@ -115,7 +115,43 @@ FluidBufStats.process(s, b, stats:c, numDerivs:1, action:{c.getn(0,c.numFrames,{ STRONG::A musical example:: CODE:: -// todo: port the Max one +// create some buffers +( +b = Buffer.read(s,File.realpath(FluidBufStats.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav"); +c = Buffer.new(s); +d = Buffer.new(s); +) + +//split in various chunks, collecting the indices in an array +FluidBufOnsetSlice.process(s,b, minSliceLength: 10, metric: 9, threshold: 0.4, filterSize: 7, indices: c, action:{c.loadToFloatArray(action: {|array| e = array.add(b.numFrames).addFirst(0);e.postln;})}); + +//describe the whole input too, here using pitch, and collecting the values in an array, dismissing the (interleaved) confidence. +FluidBufPitch.process(s,b,features:c, action:{c.loadToFloatArray(action: {|array| f = array.unlace(2)[0]; f.postln;})}); + +// iterate through each slice, taking the median of the first derivative of the pitch of each +( +g= Array.new; +Routine({ + e.doAdjacentPairs({ + arg start,end; + FluidBufStats.processBlocking(s,c,(start/512).asInt,((end-start)/512).max(2).asInt,0,1,d,1, action: {d.loadToFloatArray(action: { + arg array; + g = g.add(array[12]); + "% % %\n".postf((start/512).asInt,((end-start)/512).max(2).asInt, array[12]); + })}); +}); + "Done".postln; +}).play; +) + +//obtain the order of indices that would sort the stats +h = g.order; + +//play in loop the slice in order of pitch direction (the median of the slice's pitch variation) +( +var which = h[5]; +{BufRd.ar(1, b, Phasor.ar(0,1,e[which],e[which+1],e[which]))}.play; +) ::