updated class def for new bufstats outliers and weighting

nix
Pierre Alexandre Tremblay 5 years ago
parent d0f618ea9a
commit f8915303fa

@ -1,33 +1,35 @@
FluidBufStats : UGen{ 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; source = source.asUGenInput;
stats = stats.asUGenInput; stats = stats.asUGenInput;
weights = weights.asUGenInput;
source.isNil.if {"FluidBufStats: Invalid source buffer".throw}; source.isNil.if {"FluidBufStats: Invalid source buffer".throw};
stats.isNil.if {"FluidBufStats: Invalid stats 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); ^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( ^FluidNRTProcess.new(
server, this, action, [stats] server, this, action, [stats]
).process( ).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( ^FluidNRTProcess.new(
server, this, action, [stats], blocking: 1 server, this, action, [stats], blocking: 1
).process( ).process(
source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high source, startFrame, numFrames, startChan, numChans, stats,numDerivs, low, middle, high, outliersCutoff, weights, weightsThreshold
); );
} }

@ -51,6 +51,15 @@ ARGUMENT:: middle
ARGUMENT:: high 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. 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 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. 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 //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; 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})});
::

Loading…
Cancel
Save