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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
CLASS:: ArrayMin
summary:: detect the smallest value (and its position) in an array of UGens
categories:: UGens>Multichannel, UGens>Analysis
related:: Classes/ArrayMax, Classes/BufMin
DESCRIPTION::
Finds the minimum value in an Array of UGens, and outputs the value and the index.
This is for use in a SynthDef. If you simply need to find out which is the minimum in an array of numbers, use the link::Overviews/Methods#minIndex#minIndex:: and/or link::Overviews/Methods#minItem#minItem:: methods defined for any Collection.
CLASSMETHODS::
METHOD:: ar
argument:: array
returns:: # val, index
METHOD:: kr
argument:: array
returns:: # val, index
EXAMPLES::
Here we generate a three-channel signal containing some simple test curves, and analyse it to generate a plot:
code::
s.boot;
(
{
var son, val, index;
son = [
Line.ar(10, 1, 0.5), // a linear descent in half a second
XLine.ar(1, 10, 1), // an exponential ascent in one second
DC.ar(3) // a constant
];
# val, index = ArrayMin.ar(son);
[val, index]
}.plot(1, minval: nil, maxval: nil);
)
::
Here we use the operation as an audio effect:
code::
(
x = {
// A collection of different tones:
var son = SinOsc.ar((100, 100.3 .. 110));
var val = ArrayMin.ar(son).at(0);
val = LeakDC.ar(val); // the operation tends to induce DC offset
Pan2.ar(val)
}.play
)
x.free
::
|