A graph element that produces an integer sequence from zero until the number-of-channels of the input element.
A helper graph element that selects a particular range of output channel of another element.
A helper graph element that selects a particular range of
output channel of another element. The range is specified with
integers and thus cannot be determined at graph expansion time.
If this is desired, the Select
UGen can be used.
Usually the graph element operator \
(backlash) along with
a standard Scala Range
argument can be used
instead of explicitly writing ChannelRangeProxy
. Thus
elem \ (0 until 4)
selects the first four channels and is
equivalent to ChannelRangeProxy(elem, from = 0, until = 4, step = 1)
.
Behind the scene, ChannelProxy
instances are created, thus
ChannelRangeProxy(x, a, b)
is the same as
(a until b).map(ChannelProxy(x, _)): GE
.
Because ScalaCollider allows late-expanding graph elements, we have no direct way to get some array of a UGen's outputs.
a multi-channel element from which to select channels.
the first index (inclusive) of the channel range, counting from zero.
the end index (exclusive) of the channel range, counting from zero.
the increment from index to index in the range. A value of one
means all channels from from
until until
will be selected. A
value of two means, every second channel will be skipped. A negative
value can be used to count down from high to low indices.
ChannelProxy
Select
A graph element that flattens the channels from a nested multi-channel structure.
A graph element that flattens the channels from a nested multi-channel structure.
the element to flatten
A graph element which maps a linear range to another linear range.
A graph element which maps a linear range to another linear range.
The equivalent formula is (in - srcLo) / (srcHi - srcLo) * (dstHi - dstLo) + dstLo
.
Note: No clipping is performed. If the input signal exceeds the input range, the output will also exceed its range.
// oscillator to frequency range play { val mod = SinOsc.kr(Line.kr(1, 10, 10)) SinOsc.ar(LinLin(mod, -1, 1, 100, 900)) * 0.1 }
The input signal to convert.
The lower limit of input range.
The upper limit of input range.
The lower limit of output range.
The upper limit of output range.
MulAdd
Clip
LinExp
A graph element that mixes the channels of a signal together.
A graph element that mixes the channels of a signal together. It works like the sclang counterpart.
The Mix
companion object contains various useful mixing idioms:
- Mix.tabulate(n: Int)(fun: Int => GE)
: corresponds to Seq.tabulate
and to Array.fill
in sclang.
- Mix.fill(n: Int)(thunk: => GE)
: corresponds to Seq.fill
.
- Mix.seq(elems: GE*)
: A shortcut for Mix(GESeq(elems: _*))
.
A separate graph element is Mix.mono
.
Mix.mono(elem: GE)
flattens all channels of
the input element before summing them, guaranteeing that the result is monophonic.
Finally, Mix.fold
is an idiom that not actually adds elements,
but recursively folds them. Thus,
Mix.fold(elem: GE, n: Int)(fun: GE => GE)
is equivalent to
(1 to n).foldLeft(elem) { (res, _) => fun(res) }
Mix.fold
is often used in the SuperCollider examples to apply a filtering
process such as reverberation several times. For cases where the iteration
index is needed, the full form as shown above can be used instead.
the graph element whose channels to mix together
BinaryOpUGen
A graph element that produces an integer with number-of-channels of the input element.
A graph element that produces an integer with number-of-channels of the input element.
Because ScalaCollider allows late-expanding graph elements, we have no direct way to get an integer of some array-size of a UGen's outputs. On the other hand, there may be sound synthesis definitions that can abstract over the number of channels at definition time.
// amplitude compensation play { val sines: GE = Seq.fill(8)(SinOsc.ar(ExpRand(200, 2000))) val norm = Mix(sines) / NumChannels(sines) // guarantee that they don't clip norm * 0.2 }
the element whose number-of-channels to produce
A graph element that controls the multi-channel expansion of
its in
argument to match the to
argument by padding (extending
and wrapping) it.
A graph element that controls the multi-channel expansion of
its in
argument to match the to
argument by padding (extending
and wrapping) it.
the element to replicate
the reference element that controls the multi-channel expansion.
the signal itself is not used or output by Pad
.
A graph element which reads from a connected sound driver input.
A graph element which reads from a connected sound driver input. This is a convenience
element for accessing physical input signals, e.g. from a microphone connected to your
audio interface. It expands to a regular In
UGen offset by NumOutputBuses.ir
.
For example, consider an audio interface with channels 1 to 8 being analog line inputs, channels 9 and 10 being AES/EBU and channels 11 to 18 being ADAT inputs. To read a combination of the analog and ADAT inputs, either of the following statement can be used:
PhysicalIn(Seq(0, 8), Seq(8, 8)) PhysicalIn(Seq(0, 8), Seq(8)) // numChannels wraps!
If SuperCollider runs with less physical inputs than requested by this UGen, invalid channels are muted.
the physical index to read from (beginning at zero which corresponds to the first channel of the audio interface or sound driver). It may be a multichannel element to specify discrete indices.
the number of consecutive channels to read for each index. Wraps around if the sequence has less elements than indices has channels.
A graph element which writes to a connected sound driver output.
A graph element which writes to a connected sound driver output. This is a convenience
element for Out
with the ability to provide a set of discrete indices to which
corresponding channels of the input signal are mapped, whereas multichannel expansion
with respect to the index argument of Out
typically do not achieve what you expect.
If SuperCollider runs with less physical outputs than requested by this UGen, the output is muted.
the physical index to write to (beginning at zero which corresponds to
the first channel of the audio interface or sound driver). may be a
multichannel argument to specify discrete channels. In this case, any
remaining channels in in
are associated with the last bus index offset.
the signal to write
An auxiliary graph element that repeats the channels of an input signal, allowing for example for an exhaustive element-wise combination with another signal.
An auxiliary graph element that repeats the channels of an input signal, allowing for example for an exhaustive element-wise combination with another signal.
Normally, the way multi-channel expansion works is that when two signals are combined, the output signal has a number of channels that is the maximum of the individual number of channels, and channels will be automatically wrapped around.
For example, in x * y
if x
has three and
y
has five channels, the result expands to
Seq[GE]( x\0 * y\0, x\1 * y\1, x\2 * y\2, x\0 * y\3, x\1 * y\4 )
Using this element, we can enforce the appearance of all combinations of channels, resulting in a signal whose number of channels is the sum of the individual number of channels.
For example, RepeatChannels(x, 5)
expands to
Seq[GE]( x \ 0, x \ 0, x \ 0, x \ 0, x \ 0, x \ 1, x \ 1, x \ 1, x \ 1, x \ 1, x \ 2, x \ 2, x \ 2, x \ 2, x \ 2 )
And RepeatChannels(x, 5) * y
accordingly expands to
the fifteen-channels signal
Seq[GE]( (x\0) * (y\0), (x\0) * (y\1), (x\0) * (y\2), (x\0) * (y\3), (x\0) * (y\4), (x\1) * (y\0), (x\1) * (y\1), (x\1) * (y\2), (x\1) * (y\3), (x\1) * (y\4), (x\2) * (y\0), (x\2) * (y\1), (x\2) * (y\2), (x\2) * (y\3), (x\2) * (y\4) )
the signal whose channels to repeat
the number of repetitions for each input channel
A graph element that produces a constant silent (zero) audio-rate output signal.
A graph element that produces a constant silent (zero) audio-rate output signal.
the number of output channels
DC
A graph element that spreads a sequence of input channels across a ring of output channels.
A graph element that spreads a sequence of input channels across a ring of output channels.
This works by feeding each input channel through a dedicated PanAz
UGen, and mixing the
results together.
The panning position of each input channel with index ch
is calculated by the formula:
val pf = 2.0 / (num-in-channels - 1) * (num-out-channels - 1) / num-out-channels ch * pf + center
the number of output channels
the input signal
the spacing between input channels with respect to the output panning
the position of the first channel (see PanAz
)
a global gain factor (see PanAz
)
the width
parameter for each PanAz
the orient
parameter for each PanAz
PanAz
An element which writes an input signal to a bus, optionally applying a short fade-in.
An element which writes an input signal to a bus, optionally applying a short fade-in.
This is automatically added when using the play { ... }
syntax. If the fade time is
given, an envelope is added with a control named "gate"
which can be used to release
the synth. The bus is given by a control named "out"
and defaults to zero.
the signal to play to the default output
the fade in time; use a negative number for no fading
A graph element that interleaves a number of (multi-channel) input signals.
A graph element that interleaves a number of (multi-channel) input signals.
For example, if two stereo-signals a
and b
are zipped, the output will be a four-channel
signal corresponding to [ a \ 0, b \ 0, a \ 1, b \ 1 ]
. If the input signals
have different numbers of channels, the minimum number of channels is used.
// peak and RMS metering val x = play { val sig = PhysicalIn.ar(0 to 1) // stereo input val tr = Impulse.kr(5) val peak = Peak.kr(sig, tr) val rms = A2K.kr(Lag.ar(sig.squared, 0.1)) SendReply.kr(tr, Zip(peak, rms), "/meter") } val r = message.Responder.add(x.server) { case osc.Message("/meter", x.id, _, peakL: Float, rmsL: Float, peakR: Float, rmsR: Float) => println(f"peak-left $peakL%g, rms-left $rmsL%g, peak-right $peakR%g, rms-right $rmsR%g") x.free(); r.remove()
the signals to interleave in a multi-channel output signal
A graph element that mixes the channels of a signal together.
A graph element that mixes the channels of a signal together. It works like the sclang counterpart.
The Mix
companion object contains various useful mixing idioms:
- Mix.tabulate(n: Int)(fun: Int => GE)
: corresponds to Seq.tabulate
and to Array.fill
in sclang.
- Mix.fill(n: Int)(thunk: => GE)
: corresponds to Seq.fill
.
- Mix.seq(elems: GE*)
: A shortcut for Mix(GESeq(elems: _*))
.
A separate graph element is Mix.mono
.
Mix.mono(elem: GE)
flattens all channels of
the input element before summing them, guaranteeing that the result is monophonic.
Finally, Mix.fold
is an idiom that not actually adds elements,
but recursively folds them. Thus,
Mix.fold(elem: GE, n: Int)(fun: GE => GE)
is equivalent to
(1 to n).foldLeft(elem) { (res, _) => fun(res) }
Mix.fold
is often used in the SuperCollider examples to apply a filtering
process such as reverberation several times. For cases where the iteration
index is needed, the full form as shown above can be used instead.
// non-nested multi-channel signal reduced to mono (1) play { Mix(SinOsc.ar(440 :: 660 :: Nil)) * 0.2 // --> SinOsc.ar(440) + SinOsc.ar(660) }
// non-nested multi-channel signal reduced to mono (2) play { Mix(Pan2.ar(SinOsc.ar)) * 0.2 // --> left + right }
// mix inner channels play { // --> [left(440) + left(660), right(440) + right(660)] Mix(Pan2.ar(SinOsc.ar(440 :: 660 :: Nil))) * 0.2 }
// enforce monophonic mix play { // --> left(440) + left(660) + right(440) + right(660) Mix.mono(Pan2.ar(SinOsc.ar(440 :: 660 :: Nil))) * 0.2 }
// combine Mix(), Mix.fill(), Mix.fold() // from original SC examples: reverberated sine percussion play { val d = 6 // number of percolators val c = 5 // number of comb delays val a = 4 // number of allpass delays // sine percolation sound : val s = Mix.fill(d) { Resonz.ar(Dust.ar(2.0 / d) * 50, Rand(200, 3200), 0.003) } // reverb pre-delay time : val z = DelayN.ar(s, 0.048) // 'c' length modulated comb delays in parallel : val y = Mix(CombL.ar(z, 0.1, LFNoise1.kr(Seq.fill(c)(Rand(0, 0.1))).madd(0.04, 0.05), 15)) // chain of 'a' allpass delays on each of two channels (2 times 'a' total) : val x = Mix.fold(y, a) { in => AllpassN.ar(in, 0.050, Seq(Rand(0, 0.050), Rand(0, 0.050)), 1) } // add original sound to reverb and play it : s + 0.2 * x }
// Mix.tabulate usage // from original SC examples: harmonic swimming play { val f = 50 // fundamental frequency val p = 20 // number of partials per channel val offset = Line.kr(0, -0.02, 60, doneAction = freeSelf) // causes sound to separate and fade Mix.tabulate(p) { i => FSinOsc.ar(f * (i+1)) * // freq of partial LFNoise1.kr(Seq(Rand(2, 10), Rand(2, 10))) // amplitude rate .madd( 0.02, // amplitude scale offset // amplitude offset ).max(0) // clip negative amplitudes to zero } }
BinaryOpUGen
A graph element that controls the multi-channel expansion of
its in
argument to match the to
argument by padding (extending
and wrapping) it.
A graph element which reads from a connected sound driver input.
A graph element which reads from a connected sound driver input. This is a convenience
element for accessing physical input signals, e.g. from a microphone connected to your
audio interface. It expands to a regular In
UGen offset by NumOutputBuses.ir
.
For example, consider an audio interface with channels 1 to 8 being analog line inputs, channels 9 and 10 being AES/EBU and channels 11 to 18 being ADAT inputs. To read a combination of the analog and ADAT inputs, either of the following statement can be used:
PhysicalIn(Seq(0, 8), Seq(8, 8)) PhysicalIn(Seq(0, 8), Seq(8)) // numChannels wraps!
If SuperCollider runs with less physical inputs than requested by this UGen, invalid channels are muted.
A graph element which writes to a connected sound driver output.
A graph element which writes to a connected sound driver output. This is a convenience
element for Out
with the ability to provide a set of discrete indices to which
corresponding channels of the input signal are mapped, whereas multichannel expansion
with respect to the index argument of Out
typically do not achieve what you expect.
If SuperCollider runs with less physical outputs than requested by this UGen, the output is muted.
// flip left and right when writing a stereo signal play { val indices = Seq(1, 0) val in:GE = Seq(SinOsc.ar * LFPulse.ar(4), WhiteNoise.ar) // sine appears on the right channel, and noise on the left PhysicalOut(indices, in * 0.2) }
A graph element that produces a constant silent (zero) audio-rate output signal.
A graph element that produces a constant silent (zero) audio-rate output signal.
DC
A graph element that spreads a sequence of input channels across a ring of output channels.
A graph element that spreads a sequence of input channels across a ring of output channels.
This works by feeding each input channel through a dedicated PanAz
UGen, and mixing the
results together.
The panning position of each input channel with index ch
is calculated by the formula:
val pf = 2.0 / (num-in-channels - 1) * (num-out-channels - 1) / num-out-channels ch * pf + center
PanAz
An element which writes an input signal to a bus, optionally applying a short fade-in.
An element which writes an input signal to a bus, optionally applying a short fade-in.
This is automatically added when using the play { ... }
syntax. If the fade time is
given, an envelope is added with a control named "gate"
which can be used to release
the synth. The bus is given by a control named "out"
and defaults to zero.
A graph element that produces an integer sequence from zero until the number-of-channels of the input element.
Examples
the element whose indices to produce
NumChannels