clamped thresholds in nb_of_slices

nix
Pierre Alexandre Tremblay 6 years ago
parent 6e7ebed876
commit 2dc791906e

@ -8,7 +8,7 @@ c = Buffer.new(s);
Routine{ Routine{
var startTime, goal, startThresh, prevThresh, curThresh, curVal, prevVal, iters, maxIters, dVal, dThresh; var startTime, goal, startThresh, prevThresh, curThresh, curVal, prevVal, iters, maxIters, dVal, dThresh;
startTime = Main.elapsedTime; startTime = Main.elapsedTime;
prevThresh = 0.1; //initial threshold prevThresh = 0.1; //initial threshold (between 0.00001 and 0.99999
goal = 10; //number of slices desired goal = 10; //number of slices desired
maxIters = 100; //max number of iterations acceptable maxIters = 100; //max number of iterations acceptable
@ -17,9 +17,9 @@ Routine{
s.sync; s.sync;
//makes a second iteration //makes a second iteration
if ( (prevVal < goal), { if ( (prevVal < goal), {
curThresh = prevThresh * 0.5; curThresh = (prevThresh * 0.5).max(0.000001);
}, { }, {
curThresh = prevThresh * 2; curThresh = (prevThresh * 2).min(0.999999);
}); });
FluidBufNoveltySlice.process(s,b, indices: c, threshold:curThresh,action:{|x|curVal = x.numFrames}); FluidBufNoveltySlice.process(s,b, indices: c, threshold:curThresh,action:{|x|curVal = x.numFrames});
s.sync; s.sync;
@ -38,10 +38,10 @@ Routine{
if ( (dVal == 0), { if ( (dVal == 0), {
//if we have not change results between the last 2 passes, make the variation of threshold bigger //if we have not change results between the last 2 passes, make the variation of threshold bigger
curThresh = dThresh + curThresh; curThresh = (dThresh + curThresh).min(0.999999).max(0.000001);
},{ },{
//if we have //if we have
curThresh = ((dThresh / dVal) * (goal - curVal)) + curThresh; curThresh = (((dThresh / dVal) * (goal - curVal)) + curThresh).min(0.999999).max(0.000001);
}); });
FluidBufNoveltySlice.process(s,b, indices: c, threshold:curThresh,action:{|x|curVal = x.numFrames}); FluidBufNoveltySlice.process(s,b, indices: c, threshold:curThresh,action:{|x|curVal = x.numFrames});
s.sync; s.sync;

Loading…
Cancel
Save