1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
CLASS:: MeanTriggered
summary:: Mean of recent values, triggered
categories:: UGens>Filters
DESCRIPTION::
Calculates the mean of the most recent length values, but only paying attention to values input while the trigger is greater than zero. One application of this is to calculate a running mean of values coming from FFT analysis.
While trig<=0, the last-measured mean is held constant.
The length argument is set at initialisation, and cannot be modulated. The length is directly reflected in the amount of real-time memory taken by this UGen, so please think carefully before using large values of length. Values in the low single- or double-figures are expected.
EXAMPLES::
code::
s.boot;
// Simple polling of mean values - you could do this without a UGen!
x = {|val=1, t_trig=0| MeanTriggered.kr(val, t_trig, 3).poll(t_trig, "Mean of recent 3 values"); }.play;
x.set(\val, 10.rand.postln, \t_trig, 1); // Execute this repeatedly
x.free;
// Using it as an audio filter - compare the sounds of these:
x = {WhiteNoise.ar(0.1)}.play;
x.free;
x = {MeanTriggered.ar(WhiteNoise.ar(0.1), 1, 3)}.play; // Note that ".sum" would be more efficient here...
x.free;
x = {MeanTriggered.ar(WhiteNoise.ar(0.1), 1, 11)}.play; // Note that ".sum" would be more efficient here...
x.free;
::
|