From 2b92864757a1fc0df275a156e440f801a7d96b3d Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Mon, 2 Nov 2020 15:28:55 +0000 Subject: [PATCH] this condition trick is genius --- .../12-windowed-clustered-segmentation.scd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd b/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd index 22adc7d..b29e3d1 100644 --- a/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd +++ b/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd @@ -70,6 +70,7 @@ Routine{ { var step = ~winSize - 1; var nbass = []; + var cond = Condition.new; ~assignments = []; //run a process on ~winSize items from ~head (with an overlap of 1) //copy the items to a subdataset @@ -85,7 +86,16 @@ Routine{ nbass = x; "% - fitted1: ".postf(~head); nbass.postln; - // if (nbass.includes(0.0), { Routine{~kmeans.fitPredict(~windowDS, ~windowLS, {|x| nbass = x; "% - fitted2: ".postf(~head); nbass.postln; s.sync;});}.play; }); + if (nbass.includes(0.0), { + ~kmeans.fitPredict(~windowDS, ~windowLS, {|x| + nbass = x; "% - fitted2: ".postf(~head); nbass.postln; + if (nbass.includes(0.0), { + ~kmeans.fitPredict(~windowDS, ~windowLS, {|x| + nbass = x; "% - fitted3: ".postf(~head); nbass.postln; + }); + }); + }); + }); ~windowLS.dump{|x| ~assignments = x.at("data").asSortedArray.flop[1].flatten; @@ -95,11 +105,13 @@ Routine{ step.do{|i| if (~assignments[i+1] != ~assignments[i], {~indices= ~indices ++ (~originalslicesarray[~head+i+1])}); + }; + cond.unhang; }; }); }); - s.sync; + cond.hang; ~head = ~head + step; "-----------------".postln; });