From f8915303fa4f3184cee4cfb0445a630ab619b2fa Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Tue, 8 Sep 2020 17:48:09 +0100 Subject: [PATCH] updated class def for new bufstats outliers and weighting --- release-packaging/Classes/FluidBufStats.sc | 16 ++++++----- .../HelpSource/Classes/FluidBufStats.schelp | 28 +++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/release-packaging/Classes/FluidBufStats.sc b/release-packaging/Classes/FluidBufStats.sc index 01cc7ed..6957e50 100644 --- a/release-packaging/Classes/FluidBufStats.sc +++ b/release-packaging/Classes/FluidBufStats.sc @@ -1,33 +1,35 @@ FluidBufStats : UGen{ - *new1 { |rate, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, trig = 1, blocking = 0| + *new1 { |rate, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, outliersCutoff = -1, weights, weightsThreshold = 0, trig = 1, blocking = 0| source = source.asUGenInput; stats = stats.asUGenInput; + weights = weights.asUGenInput; source.isNil.if {"FluidBufStats: Invalid source buffer".throw}; stats.isNil.if {"FluidBufStats: Invalid stats buffer".throw}; + weights = weights ? -1; - ^super.new1(rate, source, startFrame, numFrames, startChan, numChans, stats, numDerivs, low, middle, high,trig, blocking); + ^super.new1(rate, source, startFrame, numFrames, startChan, numChans, stats, numDerivs, low, middle, high, outliersCutoff, weights, weightsThreshold, trig, blocking); } - *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, trig = 1, blocking = 0| + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, outliersCutoff = -1, weights, weightsThreshold = 0, trig = 1, blocking = 0| ^this.multiNew(\control, source, startFrame, numFrames, startChan, numChans, stats, numDerivs, low, middle, high,trig, blocking); } - *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, action| + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, outliersCutoff = -1, weights, weightsThreshold = 0, action| ^FluidNRTProcess.new( server, this, action, [stats] ).process( - source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high + source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high, outliersCutoff, weights, weightsThreshold ); } - *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, action| + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, stats, numDerivs = 0, low = 0, middle = 50, high = 100, outliersCutoff = -1, weights, weightsThreshold = 0, action| ^FluidNRTProcess.new( server, this, action, [stats], blocking: 1 ).process( - source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high + source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high, outliersCutoff, weights, weightsThreshold ); } diff --git a/release-packaging/HelpSource/Classes/FluidBufStats.schelp b/release-packaging/HelpSource/Classes/FluidBufStats.schelp index 02ab8c8..d6341fd 100644 --- a/release-packaging/HelpSource/Classes/FluidBufStats.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufStats.schelp @@ -51,6 +51,15 @@ ARGUMENT:: middle ARGUMENT:: high The rank requested for the third percentile value. By default, it is percentile 100.0, which is the maximum of the given channel of the source buffer. +ARGUMENT:: outliersCutoff +Some blab + +ARGUMENT:: weights +Some blab + +ARGUMENT:: weightsThreshold +Some blab + ARGUMENT:: action A Function to be evaluated once the offline process has finished and indices instance variables have been updated on the client side. The function will be passed stats as an argument. @@ -177,3 +186,22 @@ FluidBufStats.process(s, b, stats:c, numDerivs:1, action:{c.getn(0,c.numFrames * //this will make it tidier - the first value of each line is Left, the second is Right d.reshape(14,2).do({|x,i|["mean\t\t","stddev\t\t","skew\t\t\t", "kurtosis\t", "min\t\t\t", "median\t\t", "max\t\t\t","d-mean\t","d-stddev\t","d-skew\t\t", "d-kurtosis", "d-min\t\t", "d-median\t", "d-max\t\t"].at(i).post;x.round(0.01).postln});"".postln; :: + +STRONG::Outliers and Weights:: + +CODE:: +//example 1a +// make a buffer of known qualities +b = Buffer.loadCollection(s,[1, 8, 9, 10, 11, 12, 99]); + +// plot to confirm +b.plot//check the mode here so it print better + +// create a new buffer as destinations +c = Buffer.new(s); + +// run the stats and send back the values +FluidBufStats.process(s, b, stats:c, numDerivs:1, action:{c.getn(0,c.numFrames * c.numChannels,{|item|d = item; d.postln})}); +// run the same array with outliers rejected if outside of k=1.5 +FluidBufStats.process(s, b, stats:c, numDerivs:1,outliersCutoff: 1.5, action:{c.getn(0,c.numFrames * c.numChannels,{|item|d = item; d.postln})}); +::