UGens represent calculations with signals. They are the basic building blocks of synth definitions on the server, and are used to generate or process both audio and control signals. The many subclasses of UGen are the client-side representations of unit generators, and are used to specify their parameters when constructing synth definitions (see SynthDef).
All UGens respond to one or more of the following class methods:
ar(arg1, arg2, ... )
kr(arg1, arg2, ... )
ir(arg1, arg2, ... )
They return a new instance of UGen that calculates at audio/control rate or at initialization only (ir). Some UGens, like Rand, use the *new
method instead. These methods are implemented in subclasses, where argument names and their meaning depend on the case.
If any argument is an array, they return an array of UGens ( see: Multichannel Expansion ). If the combination of rates between arguments and ugen are not allowed, calling the methods will throw an error. This method adds the UGen to the current SynthDef, so it only fully works inside a UGen function.
A great number of UGens take arguments for mul
and add
in their *ar
and *kr
methods. Because these arguments are so ubiquitous, they are not general documented in the individual help files. Mul and add simply refer to a constant or signal by which to multiply the output of the UGen, and a constant or signal to add to the output of the UGen. (mul happens before add.) They thus correspond in many cases to scaling the amplitude of the UGen signal in the case of mul, and adding a constant or DC offset in the case of add. In most cases the defaults for mul and add are 1 and 0 respectively, and they are commonly implemented using a automatically generated MulAdd UGen for efficiency. See also the range
and madd
methods below.
the SynthDef in which the UGen is situated.
These methods are responsible for multichannel expansion. They call *new1(rate, ...args)
for each parallel combination. Most *ar/*kr
methods delegate to *multiNewList.
... args |
The first argument is rate, then the rest of the arguments. |
See *multiNew.
args |
An array where the first argument is rate, then the rest of the arguments. |
This method returns a single instance of the UGen, not multichannel expanded. It is called inside multiNewList, whenever a new single instance is needed.
rate |
A Symbol, |
An appropriate message selector ( Symbol like \ar, \kr, \ir
) for the given rate.
Displays the output of this UGen in an individual Stethoscope window.
name |
The name of the window |
bufsize |
Buffer size |
zoom |
Zoom factor |
Polls the output of this UGen every interval seconds, and posts the result.
trig |
Trig frequency |
label |
A symbol to label the output |
trigid |
Numerical ID |
The default trig is 10, which converts to 10 triggers per second (or every 0.1 seconds). See Poll for more info on polling.
Like poll
, only that dpoll
is used for Demand ugens. See Poll for more info on polling.
Scales the output of this UGen to be within the range of lo
and hi
.
Note that range
expects the default output range, and thus should not be used in conjunction with mul and add arguments.
Maps the output of this UGen exponentially to be within the range of lo
and hi
using a LinExp UGen.
lo
and hi
should both be non-zero and have the same sign. Note that exprange
expects the default output range, and thus should not be used in conjunction with mul and add arguments.
Scales the output of this UGen to be within the range of lo
and hi
using a curve factor of curve
.
Note that curverange
expects the default output range, and thus should not be used in conjunction with mul and add arguments.
Scales the output of this UGen to be between (0..mul)
range (default 1).
Note that unipolar
expects the default output range, and thus should not be used in conjunction with mul and add arguments.
Scales the output of this UGen to be between (-mul..mul)
range (default 1).
Note that bipolar
expects the default output range, and thus should not be used in conjunction with mul and add arguments.
Converts degrees to radians. This method multiplies the receiver's output by pi/180
.
Converts radians to degrees. This method multiplies the receiver's output by 180/pi
.
Wraps the receiver in a Clip UGen, clipping its output at lo
and hi
.
Wraps the receiver in a Fold UGen, folding its output at lo
and hi
.
Wraps the receiver in a Wrap UGen, wrapping its output at lo
and hi
.
Blends this
with that
by wrapping the receiver in an XFade2 (if this
or that
are audio-rate UGens) or LinXFade2 UGen.
blendFrac
argument is between 0 and 1Wraps the receiver in a Lag UGen, smoothing its output by t1
seconds lagtime. If a second argument is given, it wraps it in a LagUD UGen.
Wraps the receiver in a Lag2 UGen, smoothing its output by t1
seconds lagtime. If a second argument is given, it wraps it in a Lag2UD UGen.
Wraps the receiver in a Lag3 UGen, smoothing its output by t1
seconds lagtime. If a second argument is given, it wraps it in a Lag3UD UGen.
Wraps the receiver in a LagUD UGen, smoothing its output by lagtimeU
and lagtimeD
.
Wraps the receiver in a Lag2UD UGen, smoothing its output by lagtimeU
and lagtimeD
.
Wraps the receiver in a Lag3UD UGen, smoothing its output by lagtimeU
and lagtimeD
.
Wraps the receiver in a VarLag UGen, smoothing its output by time
seconds.
Wraps the receiver in a Slew UGen, limiting the slope of its output.
Wraps the receiver in a DegreeToKey UGen.
Wraps the receiver in a min
BinaryOpUGen, such that the lesser of the receiver's output and the Nyquist frequency is output. This can be useful to prevent aliasing.
Wraps the receiver so that its values are rounded within margin
distance from a multiple of resolution
to a multiple of resolution. By using margin
and strength
you can control when values will be rounded, and by how much. See SimpleNumber: -snap for more details.
This can be used to make control signals (e.g. from sensors) "snap" to defined resolution. Example:
Wraps the receiver so that its values are rounded outside of margin
distance from a multiple of resolution
to a multiple of resolution. By using margin
and strength
you can control when values will be rounded, and by how much. See SimpleNumber: -softRound for more details.
Wraps the receiver so that a linear input range is mapped to a linear output range.
The clip argument can be one of the four:
nil | do not clip at outMin or outMax |
\minmax | clip at outMin or outMax |
\min | clip at outMin |
\max | clip at outMax |
Example:
Wraps the receiver so that a linear inputrange is mapped to an exponential output range.
outMin and outMax must be nonzero and of the same sign. For clip argument, see linlin
above.
Wraps the receiver so that an exponential inputrange is mapped to a linear output range.
inMin and inMax must be nonzero and of the same sign. For clip argument, see linlin
above.
Wraps the receiver so that an exponential inputrange is mapped to an exponential output range.
outMin, outMax, inMin and inMax must be nonzero and of the same sign. For clip argument, see linlin
above.
Wraps the receiver so that a linear inputrange is mapped to a curve-like exponential output range.
outMin and outMax may be zero and of the different sign. For clip argument, see linlin
above.
Wraps the receiver so that a curve-like exponential inputrange is mapped to a linear output range.
inMin and inMax may be zero and of the different sign. For clip argument, see linlin
above.
Map the receiver from two assumed linear input ranges (inMin..inCenter) and (inCenter..inMax) to two linear output ranges (outMin..outCenter) and (outCenter..outMax). If the input exceeds the input range, the following behaviours are specified by the clip argument.
inCenter | |
inMin |
assumed input minimum |
inMax |
assumed input maximum |
outCenter | |
outMin |
output minimum |
outMax |
output maximum |
clip |
nil (don't clip) \max (clip ceiling) \min (clip floor) \minmax (clip both - this is default). |
Limits the receiver range to one of the four clip modes, see linlin
above.
Wraps the receiver in a CheckBadValues UGen with the corresponding id
and post
flag.
Outputs trueUGen when the receiver outputs 1, falseUGen when the receiver outputs 0. If the receiver outputs a value between 0 and 1, a mixture of both will be played.
This is implemented as: (this * (trueUGen - falseUGen)) + falseUGen)
Note that both trueUGen and falseUGen will be calculated regardless of whether they are output, so this may not be the most efficient approach.
Dynamic geometry support. Returns Point(this, y)
.
Complex math support. Returns Complex(this, 0.0)
.
Posts a list of the arguments for this UGen and their values.
The following methods and instance variables are largely used in the construction of synth definitions, synth descriptions (see SynthDesc), UGen class definitions, etc., and are usually not needed for general use. Users should not attempt to set any of these values in general code.
The SynthDef which contains the UGen.
The array of inputs to the UGen.
The output rate of the UGen which is one of the Symbols \audio
, or \control
.
A symbol indicating the signal range of the receiver. Either \bipolar
or \unipolar
.
The number of output channels.
For a UGen, this will always be 1, but Array also implements this method, so multichannel expansion is supported. See Multichannel Expansion.
The number of inputs for this UGen.
The number of outputs for this UGen.
The Class name of the receiver as a String.
Wraps the receiver in a MulAdd UGen.
This is for the most part only used in UGen class definitions in order to allow efficient implementation of mul
and add
arguments.
true
the receiver
This method is implemented in a number of classes in order to allow objects like Nodes, Busses, and Buffers to be passed directly as UGen inputs and Synth args.
the receiver.
Thus UGen-dup effectively returns a reference to the original and is a convenient way to copy a mono signal to multiple channels.
Function-dup evaluates that function multiple times, thus potentially returning distinct UGens.
By default, this method stores the inputs (e.g. the arguments to *ar
and *kr
) in the UGen.
This may be overridden to do other initialisations, as long as the inputs are set correctly.
Send this UGen's output to Bela's Oscilloscope (see BelaScope for required setup)
channelOffset |
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts. |
(server) |
The server on which BelaScope is running. If not specified, it looks for the first server for which BelaScope was already initialized. If none is found, it attempts to initialize a BelaScope instance on Server: *default. |
This UGen.