Take the modulus of the signal.
Take the modulus of the signal. Negative input values are
wrapped to positive ones, e.g. (DC.kr(-4) % 5) sig_== DC.kr(1)
.
If the second operand is zero, the output is zero.
An alias for mod.
Treats the signals as integer numbers and combines their bit representations through AND
.
Multiplies two signals.
Adds two signals.
Subtracts a signal from the receiver.
Divides the receiver by another signal.
Compares two signals and outputs one if the receiver is less than the argument.
Treats the signals as integer numbers and bit-shifts the receiver by the argument to the left.
Compares two signals and outputs one if the receiver is less than or equal to the argument.
Compares two signals and outputs one if the receiver is less than or equal to the argument.
Note that this can be surprising if the signals are not integer, because due to floating point noise two signals may be "almost identical" but not quite.
Compares two signals and outputs one if the receiver is greater than the argument.
Compares two signals and outputs one if the receiver is greater than the argument.
// trigger an envelope play { val trig = SinOsc.ar(1) > 0 val env = EnvGen.kr(Env.perc, gate = trig, doneAction = doNothing) * SinOsc.ar(440) * env * 0.1 }
Compares two signals and outputs one if the receiver is greater than or equal to the argument.
Compares two signals and outputs one if the receiver is greater than or equal to the argument.
Note that this can be surprising if the signals are not integer, because due to floating point noise two signals may be "almost identical" but not quite.
Treats the signals as integer numbers and bit-shifts the receiver by the argument to the right.
Treats the signals as integer numbers and combines their bit representations through XOR
.
Takes the absolute values or magnitudes of the signal (negative numbers become positive).
Takes the absolute values or magnitudes of the signal (negative numbers become positive).
Calculates the absolute difference of the two arguments, equivalent to the formula abs(a - b)
.
Calculates the absolute difference of the two arguments, equivalent to the formula abs(a - b)
.
play { // creates a pulsation val mul = (SinOsc.ar(2) * 0.5) absDif 0.2 SinOsc.ar(440) * mul }
Uses the input signal as argument to the arc cosine (trigonometric) function.
Uses the input signal as argument to the arc cosine (trigonometric) function.
Warning: produces NaN
if the input is less than -1
or greater than +1
Multiplies the input signal with the argument, while the argument is positive, otherwise outputs zero.
Multiplies the input signal with the argument, while the argument
is positive, otherwise outputs zero. Thus equivalent to a * b.max(0)
.
play { // a sine envelope WhiteNoise.ar.amClip(SinOsc.kr(1) * 0.2) }
Converts the input signal from a linear (amplitude) factor to a level in decibels (dB).
Converts the input signal from a linear (amplitude) factor to a level in decibels (dB). A unit amplitude of 1.0 corresponds with 0 dB. A factor or amplitude of 2.0 corresponds to c. +6 dB. A factor or amplitude of 0.5 corresponds wot c. -6 dB.
The inverse function is dbAmp
.
Uses the input signal as argument to the arc sine (trigonometric) function.
Uses the input signal as argument to the arc sine (trigonometric) function.
Warning: produces NaN
if the input is less than -1
or greater than +1
Uses the input signal as argument to the arc tangent (trigonometric) function.
Uses the input signal as argument to the arc tangent (trigonometric) function. It is also useful for "compressing" the range of an input signal.
There is also a binary operator atan2
for a greater (disambiguated) value range.
Uses the input signal and the argument to calculate the arc tangent (trigonometric) function.
Uses the input signal and the argument to calculate the arc tangent (trigonometric) function.
The input signal is the numerator ("x") and the argument b
is the denominator ("y") of the parameter
to arg tangent.
There is also a unary operator atan
.
Produces a random signal linearly distributed between -a
and +a
for input signal a
.
Produces a random signal linearly distributed between -a
and +a
for input signal a
.
Rounds the signal up to the next higher integer number.
Rounds the signal up to the next higher integer number.
Clips the receiver to a range defined by low
and high
.
Clips the input signal to the range given by +/- the argument.
Clips the input signal to the range given by +/- the argument.
If the input falls below -b
, it is held at -b
.
If the input rises above +b
, it is held at +b
.
play { // fade in amplitude, fade out distortion SinOsc.ar(500).clip2(Line.kr(0, 1, 8)) * 0.5 }
Produces a random signal taking the values zero or one, using the input signal as probability.
Produces a random signal taking the values zero or one, using the input
signal as probability. If the input is 0.5
, there is a 50:50 chance of the output
sample becoming zero or one. If the input is 0.1
, the chance of an output sample
becoming zero is 90% and the chance of it becoming one is 10%.
If the input is zero or less than zero, the output is constantly zero. If the input is one or greater than one, the output is constantly one.
Uses the input signal as argument to the cosine (trigonometric) function.
Uses the input signal as argument to the hyperbolic cosine (trigonometric) function.
Converts the input signal from a frequency in cycles per second (Hertz) to a midi pitch number.
Converts the input signal from a frequency in cycles per second (Hertz) to a midi pitch number.
A frequency of 440 cps corresponds to the midi pitch of 69
or note A4.
The inverse function is midiCps
.
Converts the input signal from a frequency in cycles per second (Hertz) to a "decimal octave".
Converts the input signal from a frequency in cycles per second (Hertz) to a "decimal octave". A frequency of 261.626 cps corresponds to the note C4 or "decimal octave" 4.0.
The inverse function is cpsOct
.
Takes the signal to the power of three, equivalent to a * a * a
.
Takes the signal to the power of three, equivalent to a * a * a
.
Converts the input signal from a level in decibels (dB) to a linear factor.
Converts the input signal from a level in decibels (dB) to a linear factor. A level of 0 dB corresponds to a factor of 1.0. A level of +6 dB corresponds to a factor of c. 2.0 (double amplitude). A level of -6 dB corresponds to a factor of c. 0.5 (half amplitude).
The inverse function is ampDb
.
Calculates the difference of the squared arguments, equivalent to the formula (a*a) - (b*b)
.
Calculates the difference of the squared arguments, equivalent to the formula (a*a) - (b*b)
.
play { (SinOsc.ar(800) difSqr SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
Produces a non-linear distortion using the formula a / (1 + abs(a))
.
Produces a non-linear distortion using the formula a / (1 + abs(a))
.
// gradually increasing amount of distortion play { (SinOsc.ar(500) * XLine.kr(0.1, 10, 10)).distort * 0.25 }
Produces the difference of the input signal and it being clipped to the argument.
Produces the difference of the input signal and it being clipped to the argument.
Thus equivalent to a - a.clip2(b)
.
play { SinOsc.ar(500).excess(Line.kr(0, 1, 8)) * 0.5 }
Exponentiates the signal (with base e).
Exponentiates the signal (with base e).
The inverse function is log
.
Scales the input signal a
from an exponential source range to an exponential target range.
Scales the input signal a
from an exponential source range to an exponential target range.
The formula is (outHigh / outLow).pow((a / inLow).log / (inHigh / inLow).log) * outLow
.
Scales the input signal a
from an exponential source range to a linear target range.
Scales the input signal a
from an exponential source range to a linear target range.
The formula is (a / inLow).log / (inHigh / inLow).log * (outHigh - outLow) + outLow
.
Outputs random values exponentially distributed between the two signals.
A dummy operation that ensures the topological order of the receiver UGen and the argument UGen.
A dummy operation that ensures the topological order of the receiver UGen and the argument UGen. It ensures that the receiver is placed before the argument. Rarely used.
// useful when two UGens need to be called, but only one of their outputs is used play { val a = Dpoll(Dseq(Seq(1, 2, 3, 4), inf), label = "a") val b = Dpoll(Dseq(Seq(1955, 1952, 1823, 1452), inf), label = "b") val c = Dpoll(a firstArg b, label = "a firstArg b ") // c = a Duty.kr(0.4, 0, c) () }
Creates a Flatten
graph element that "flattens" the channels from a nested multi-channel structure,
into a one-dimensional multi-channel structure.
Creates a Flatten
graph element that "flattens" the channels from a nested multi-channel structure,
into a one-dimensional multi-channel structure.
For example Pan.ar(SinOsc.ar(Seq(400, 600)))
is a nested multi-channel structure, which appears
as two channels (nested) during expansion. Instead, Pan.ar(SinOsc.ar(Seq(400, 600))).flatten
appears
as a flat four-channel signal.
Flatten
Rounds the signal down to the next lower integer number.
Rounds the signal down to the next lower integer number.
Folds or "reflects" the input signal at the boundaries given by the arguments.
Folds or "reflects" the input signal at the boundaries given by the arguments.
For example, with low = -2
and high = +3
if the input falls below -2, it is reflected such that input -2.1 becomes output -1.9.
If the input rises above +3, it is reflected such that input +3.1 becomes output +2.9.
Folds or "reflects" the input signal at the boundaries given by +/- the argument.
Folds or "reflects" the input signal at the boundaries given by +/- the argument. For example, with boundaries of +/- 2, if the input falls below -2, it is reflected such that input -2.1 becomes output -1.9. If the input rises above +2, it is reflected such that input +2.1 becomes output +1.9.
play { SinOsc.ar(500).fold2(Line.kr(0, 1, 8)) * 0.5 }
Takes the fractional part of the signal, equivalent to modulus 1.0
.
Takes the fractional part of the signal, equivalent to modulus 1.0
.
Treats the signals as integer numbers and outputs the greatest common divisor of both.
Treats the signals as integer numbers and outputs the greatest common divisor of both.
This extends the usual definition by returning a negative number if both operands are negative.
"greater" means "divisible by" in this interpretation, so -1 gcd -1
returns a negative number.
// rhythmic pitch patterns with mouse control play { val mx = MouseX.kr(-200, 200) val my = MouseY.kr(-200, 200) val freq = (SinOsc.kr(0.3) * 20).gcd(GESeq(mx, my)) * 30 + 500 SinOsc.ar(freq) * 0.1 }
Scans the von Hann window function between the input signal's range of 0 and 1.
Scans the von Hann window function between the input signal's range of 0 and 1.
The Hann window is a raised cosine starting and ending at zero at the interval
boundaries, and going to 1.0 at the center (input 0.5).
Outside of the interval [0, 1]
, the output will be zero.
Calculates the hypotenuse of both signals, or the square root of the sum of the squares of both.
Calculates the hypotenuse of both signals, or the square root of the sum of the squares of both.
// hypot used to calculate a Doppler shift pitch and amplitude based on distance. play { // object travels 200 meters in 6 secs (= 120 km/h) passing 10 meters // from the listener val x = 10 val y = LFSaw.kr(1.0/6) * 100 val distance = x hypot y val velocity = Slope.kr(distance) val pitchRatio = (344 - velocity) / 344 // speed of sound is around 344 m/s val amplitude = 20 / distance.squared SinOsc.ar(500 * pitchRatio) * amplitude }
An approximate and thus faster version of hypot
to calculate the hypotenuse of both signals,
or the square root of the sum of the squares of both.
An approximate and thus faster version of hypot
to calculate the hypotenuse of both signals,
or the square root of the sum of the squares of both.
Treats the signals as integer numbers and outputs the least common multiple of both.
Treats the signals as integer numbers and outputs the least common multiple of both. This extends the usual definition by returning a negative number if any of the operands is negative.
// rhythmic pitch patterns with mouse control play { val mx = MouseX.kr(-20, 20) val my = MouseY.kr(-20, 20) SinOsc.ar((SinOsc.kr(0.3) * 20) lcm (GESeq(mx, my) * 30 + 500)) * 0.1 }
Scales the input signal a
from a linear source range to an exponential target range.
Scales the input signal a
from a linear source range to an exponential target range.
The formula is (outHigh / outLow).pow((a - inLow) / (inHigh - inLow)) * outLow
.
Scales the input signal a
from a linear source range to a linear target range.
Scales the input signal a
from a linear source range to a linear target range.
The formula is (a - inLow) / (inHigh - inLow) * (outHigh - outLow) + outLow
.
Produces a random signal linearly distributed between zero and the input signal.
Produces a random signal linearly distributed between zero and the input signal.
Takes the natural logarithm of the input signal.
Takes the logarithm of the input signal, using base 10.
Takes the logarithm of the input signal, using base 2.
Outputs the larger of two signals.
Outputs the larger of two signals.
// LFO distorts and envelopes z play { val z = SinOsc.ar(500) z max SinOsc.ar(0.1) }
Converts the input signal from midi pitch to a frequency in cycles per second (Hertz).
Converts the input signal from midi pitch to a frequency in cycles per second (Hertz).
A midi pitch of 69
corresponds to A4 or 440 cps. A pitch of 69 + 12 = 81
is one
octave up, i.e. A5 or 880 cps.
The inverse function is cpsMidi
.
// midi pitch from 24 to 108 to oscillator frequency play { Saw.ar(Line.kr(24, 108, dur = 10).midiCps) * 0.2 }
Converts the input signal from midi pitch interval to a frequency ratio.
Converts the input signal from midi pitch interval to a frequency ratio.
An interval of zero corresponds to unison and thus a frequency ratio of 1.0
.
An interval of +12
corresponds to an octave up or ratio of 2.0
.
An interval of -12
corresponds to an octave down or ratio of (1.0/2.0) = 0.5
.
The inverse function is ratioMidi
.
Outputs the smaller of two signals.
Outputs the smaller of two signals.
// LFO distorts and envelopes z play { val z = SinOsc.ar(500) z min SinOsc.ar(0.1) }
Take the modulus of the signal.
Take the modulus of the signal. Negative input values are
wrapped to positive ones, e.g. DC.kr(-4).mod(5) sig_== DC.kr(1)
If the second operand is zero, the output is zero.
Creates a MulAdd
UGen, by first multiplying the receiver with mul
, then adding the add
parameter.
Creates a MulAdd
UGen, by first multiplying the receiver with mul
, then adding the add
parameter.
It can be used to change the value range of the receiver. For example,
SinOsc
has a nominal range of -1
to +1
. Using SinOsc.ar.mulAdd(3, 4)
that
range would become (-1 * 3) + 4 = 1
to (+1 * 3) + 4 = 7
.
MulAdd
Converts the input signal from "decimal octaves" to a frequency in cycles per second (Hertz).
Converts the input signal from "decimal octaves" to a frequency in cycles per second (Hertz). For example, octave 4 begins with 4.0 or note C4, corresponding to 261.626 cps. The tritone above that (plus 6 semitones or half an octave), is "decimal octave" 4.5, corresponding with note F♯4 or 369.994 cps.
The inverse function is cpsOct
.
Creates a proxy that represents a specific range of output channels of the element.
Creates a proxy that represents a specific range of output channels of the element.
a range of channels, zero-based. Indices which are greater than or equal to the number of outputs are wrapped around.
a new element that represents the given channels of the receiver
ChannelRangeProxy
Creates a proxy that represents a specific output channel of the element.
Creates a proxy that represents a specific output channel of the element.
channel-index, zero-based. Indices which are greater than or equal to the number of outputs are wrapped around.
a monophonic element that represents the given channel of the receiver
ChannelProxy
Polls the output values of this graph element, and prints the result to the console.
Polls the output values of this graph element, and prints the result to the console.
This is a convenient method for wrapping this graph element in a Poll
UGen.
a signal to trigger the printing. If this is a constant, it is
interpreted as a frequency value and an Impulse
generator of that frequency
is used instead.
a string to print along with the values, in order to identify
different polls. Using the special label "$auto"
(default) will generated
automatic useful labels using information from the polled graph element
if greater then 0, a "/tr"
OSC message is sent back to the client
(similar to SendTrig
)
de.sciss.synth.ugen.Poll
Creates a Poll
UGen, printing the receiver's values to the console, ten times a second.
Creates a Poll
UGen, printing the receiver's values to the console, ten times a second.
Poll
Takes the power of the signal.
Takes the power of the signal.
Warning: Unlike a normal power operation, the signum of the
left operand is always preserved. I.e. DC.kr(-0.5).pow(2)
will
not output 0.25
but -0.25
. This is to avoid problems with
floating point noise and negative input numbers, so
DC.kr(-0.5).pow(2.001)
does not result in a NaN
, for example.
Scans a ramp function rising from zero to one across the input signals' range of 0 and 1.
Scans a ramp function rising from zero to one across the input signals' range of 0 and 1. The function moves linearly from the zero at the interval start to 1.0 at the interval end. When the input is smaller than zero, the output is zero, and when the input is larger than one, the output is one.
Produces a random signal evenly distributed between zero and the input signal.
Produces a random signal evenly distributed between zero and the input signal.
Produces a random signal evenly distributed between -a
and +a
for input signal a
.
Produces a random signal evenly distributed between -a
and +a
for input signal a
.
Outputs random values evenly distributed between the two signals.
Converts the input signal from a frequency ratio to a midi pitch interval.
Converts the input signal from a frequency ratio to a midi pitch interval.
A frequency ratio of 1.0 corresponds to the unison or midi interval 0.
A ratio of 2.0 corresponds to an octave up or the midi pitch interval +12
.
A ratio of 0.5 corresponds to an octave down or the midi pitch interval -12
.
The inverse function is midiRatio
.
Takes the reciprocal value of the input signal, equivalent to 1.0 / a
.
Takes the reciprocal value of the input signal, equivalent to 1.0 / a
.
Warning: Outputs NaN
if the input is zero ("division by zero").
Scans the rectangular window function between the input signal's range of 0 and 1.
Scans the rectangular window function between the input signal's range of 0 and 1.
A rectangular window has value 1.0 at every point in the interval [0, 1]
.
Outside of that range, the output will be zero.
An optimized operation on the signals corresponding to the formula a * b + a
.
An optimized operation on the signals corresponding to the formula a * b + a
.
play { (SinOsc.ar(800) ring1 SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
An optimized operation on the signals corresponding to the formula a * b + a + b
.
An optimized operation on the signals corresponding to the formula a * b + a + b
.
play { (SinOsc.ar(800) ring2 SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
An optimized operation on the signals corresponding to the formula a * a * b
.
An optimized operation on the signals corresponding to the formula a * a * b
.
play { (SinOsc.ar(800) ring3 SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
An optimized operation on the signals corresponding to the formula a * a * b - b * b * a
.
An optimized operation on the signals corresponding to the formula a * a * b - b * b * a
.
play { (SinOsc.ar(800) ring4 SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
Rounds the input signal up or down to a given degree of coarseness.
Rounds the input signal up or down to a given degree of coarseness. For example,
roundTo(1.0)
rounds to the closest integer, roundTo(0.1)
rounds to the closest
number for which modulus 0.1 is zero.
Rounds the input signal up to a given degree of coarseness.
Rounds the input signal up to a given degree of coarseness. For example,
roundUpTo(1.0)
rounds up to the closest integer, roundTo(0.1)
rounds up to the closest
number for which modulus 0.1 is zero.
Scans a sinusoidal S-shaped function ("easy in, easy out") rising from zero to one across the input signals' range of 0 and 1.
Scans a sinusoidal S-shaped function ("easy in, easy out") rising from zero to one across the input signals' range of 0 and 1. The function begins to rise from the zero at the interval start to 0.5 at the center to 1.0 at the interval end. When the input is smaller than zero, the output is zero, and when the input is larger than one, the output is one.
Scales the negative part of the input by the argument, outputs positive input unaltered.
Scales the negative part of the input by the argument, outputs positive input unaltered.
Thus equivalent to a.min(0) * b + a.max(0)
.
play { // increasing half-wave asymmetry (SinOsc.ar(500) * 0.25).scaleNeg(Line.ar(1, -1, 4)) }
Compares two signals and outputs one if they are different, otherwise zero.
Compares two signals and outputs one if they are different, otherwise zero.
Note that this can be surprising if the signals are not integer, because due to floating point noise two signals may be "almost identical" but not quite, thus resulting in an output of one.
Compares two signals and outputs one if they are identical, otherwise zero.
Compares two signals and outputs one if they are identical, otherwise zero.
Note that this can be surprising if the signals are not integer, because due to floating point noise two signals may be "almost identical" but not quite, thus resulting in an output of zero.
Takes the signum of the signal, being 1
for positive signals, -1
for negative signals,
and zero for a zero input.
Takes the signum of the signal, being 1
for positive signals, -1
for negative signals,
and zero for a zero input.
Uses the input signal as argument to the sine (trigonometric) function.
Uses the input signal as argument to the hyperbolic sine (trigonometric) function.
Produces a non-linear distortion, wherein the input range of -0.5
to +0.5
is linear.
Produces a non-linear distortion, wherein the input range of -0.5
to +0.5
is linear.
// gradually increasing amount of distortion play { (SinOsc.ar(500) * XLine.kr(0.1, 10, 10)).softClip * 0.25 }
Squares the difference of the two arguments, equivalent to the formula (a - b) * (a - b)
.
Squares the difference of the two arguments, equivalent to the formula (a - b) * (a - b)
.
play { (SinOsc.ar(800) sqrDif SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
Squares the sum of the two arguments, equivalent to the formula (a + b) * (a + b)
.
Squares the sum of the two arguments, equivalent to the formula (a + b) * (a + b)
.
play { (SinOsc.ar(800) sqrSum SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
Takes the square root of the signal.
Takes the square root of the signal. If the input is negative, it returns
the negative of the square root of the absolute value, i.e. sqrt(-2) == -sqrt(2)
,
so the output is valid for any input.
Takes the square of the signal, equivalent to a * a
.
Takes the square of the signal, equivalent to a * a
.
Produces a random signal following an approximated Gaussian distribution between zero and the input signal.
Produces a random signal following an approximated Gaussian distribution between zero and the input signal.
It follows the formula Mix.fill(3)(Rand(0.0, 1.0)) - 1.5 * (2.0/3)
,
thus summing three evenly distributed signals
Calculates the sum of the squared arguments, equivalent to the formula (a*a) + (b*b)
.
Calculates the sum of the squared arguments, equivalent to the formula (a*a) + (b*b)
.
play { (SinOsc.ar(800) sumSqr SinOsc.ar(XLine.kr(200, 500, 5))) * 0.125 }
Uses the input signal as argument to the tangent (trigonometric) function.
Uses the input signal as argument to the hyperbolic tangent (trigonometric) function.
A threshold comparison where the output is zero when input signal is less than the argument, otherwise the input signal is passed.
A threshold comparison where the output is zero when input signal is less than the argument, otherwise the input signal is passed.
play { // a low-rent gate (LFNoise0.ar(50) * 0.5) thresh 0.45 }
de.sciss.synth.ugen.Gate
Scans the triangular window function between the input signal's range of 0 and 1.
Scans the triangular window function between the input signal's range of 0 and 1.
The triangular window moves from linearly from the zero at the interval start to
1.0 at the center (input 0.5) back to 0.0 at the interval end.
Outside of the interval [0, 1]
, the output will be zero.
Removes the fractional part of the input signal.
Removes the fractional part of the input signal.
Logically negates the signal.
Logically negates the signal. Outputs 1
if the signal is greater than zero, otherwise outputs 0
.
Negatives the signal.
Negatives the signal. As if multiplying the signal by -1
.
// pseudo-stereo by phase inversion play { val a = LFNoise1.ar(1500) * 0.5 Seq(a, -a) }
Treats the signal as integer numbers and inverts its bits.
Scans the Welch window function between the input signal's range of 0 and 1.
Scans the Welch window function between the input signal's range of 0 and 1.
The Welch window is a parabolic curve starting and ending at zero at the interval
boundaries, and going to 1.0 at the center (input 0.5).
Outside of the interval [0, 1]
, the output will be zero.
Wraps the input signal at the boundaries given by the arguments.
Wraps the input signal at the boundaries given by +/- the argument.
Treats the signals as integer numbers and combines their bit representations through OR
.
GEOps
are operations for graph elements (GE
). Instead of having these operations directly defined in each UGen, which is a huge list, they appear here as extension methods. Therefore, you can writeSinOsc.ar.linLin ...
as iflinLin
was defined forGE
orSinOsc
.Many of these operations are defined for constant numbers, as well, for example you can write
0.5.linLin ...
. These operations are defined separately.GE