Package

de.sciss.synth

ugen

Permalink

package ugen

Visibility
  1. Public
  2. All

Type Members

  1. final case class ChannelIndices(in: GE) extends SingleOut with ScalarRated with Product with Serializable

    Permalink

    A graph element that produces an integer sequence from zero until the number-of-channels of the input element.

    A graph element that produces an integer sequence from zero until the number-of-channels of the input element.

    Examples
    // cross-faded select
    play {
      val sines: GE = Seq.fill(4)(SinOsc.ar(ExpRand(200, 2000)))
      val index   = MouseX.kr(lo = 0, hi = NumChannels(sines) - 1)
      val indices = ChannelIndices(sines)
      indices.poll(0, "indices")
      val select  = 1 - (indices absdif index).min(1)
      val sig     = Mix(sines * select)
      sig * 0.2
    }
    in

    the element whose indices to produce

    See also

    NumChannels

  2. final case class ChannelRangeProxy(elem: GE, from: Int, until: Int, step: Int) extends GE.Lazy with Product with Serializable

    Permalink

    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 out along with a standard Scala Range argument can be used instead of explicitly writing ChannelRangeProxy. Thus elem out (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.

    elem

    a multi-channel element from which to select channels.

    from

    the first index (inclusive) of the channel range, counting from zero.

    until

    the end index (exclusive) of the channel range, counting from zero.

    step

    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.

    See also

    RepeatChannels

    ChannelProxy

    Select

    NumChannels

  3. final case class Env(startLevel: GE, segments: Seq[Segment], releaseNode: GE = 99, loopNode: GE = 99) extends EnvLike with Product with Serializable

    Permalink
  4. sealed trait EnvFactory[V] extends AnyRef

    Permalink
  5. sealed trait EnvLike extends GE

    Permalink
  6. final case class Flatten(elem: GE) extends GE.Lazy with Product with Serializable

    Permalink

    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.

    elem

    the element to flatten

  7. final case class IEnv(startLevel: GE, segments: Seq[Segment], offset: GE = 0) extends EnvLike with Product with Serializable

    Permalink
  8. final case class LinLin(in: GE, srcLo: GE = 0f, srcHi: GE = 1f, dstLo: GE = 0f, dstHi: GE = 1f) extends GE.Lazy with Product with Serializable

    Permalink

    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.

    Examples
    // oscillator to frequency range
    play {
      val mod = SinOsc.kr(Line.kr(1, 10, 10))
      SinOsc.ar(LinLin(mod, -1, 1, 100, 900)) * 0.1
    }
    in

    The input signal to convert.

    srcLo

    The lower limit of input range.

    srcHi

    The upper limit of input range.

    dstLo

    The lower limit of output range.

    dstHi

    The upper limit of output range.

    See also

    MulAdd

    Clip

    LinExp

  9. final case class Mix(elem: GE) extends SingleOut with Product with Serializable

    Permalink

    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.

    elem

    the graph element whose channels to mix together

    See also

    BinaryOpUGen

    Reduce

  10. final case class NumChannels(in: GE) extends SingleOut with ScalarRated with Product with Serializable

    Permalink

    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.

    Examples
    // 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
    }
    in

    the element whose number-of-channels to produce

    See also

    ChannelIndices

  11. final case class Pad(in: GE, to: GE) extends SingleOut with Product with Serializable

    Permalink

    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.

    in

    the element to replicate

    to

    the reference element that controls the multi-channel expansion. the signal itself is not used or output by Pad.

  12. final case class PhysicalIn(indices: GE, numChannels: Seq[Int]) extends GE.Lazy with AudioRated with Product with Serializable

    Permalink

    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.

    indices

    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.

    numChannels

    the number of consecutive channels to read for each index. Wraps around if the sequence has less elements than indices has channels.

  13. final case class PhysicalOut(indices: GE, in: GE) extends ZeroOut with AudioRated with Product with Serializable

    Permalink

    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.

    indices

    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.

    in

    the signal to write

  14. final case class Reduce(elem: GE, op: Op) extends SingleOut with Product with Serializable

    Permalink
  15. final case class RepeatChannels(a: GE, num: Int) extends GE.Lazy with Product with Serializable

    Permalink

    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.out(0) * y.out(0), x.out(1) * y.out(1),
      x.out(2) * y.out(2), x.out(0) * y.out(3),
      x.out(1) * y.out(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.out(0), x.out(0), x.out(0), x.out(0), x.out(0),
      x.out(1), x.out(1), x.out(1), x.out(1), x.out(1),
      x.out(2), x.out(2), x.out(2), x.out(2), x.out(2)
    )

    And RepeatChannels(x, 5) * y accordingly expands to the fifteen-channels signal

    Seq[GE](
      (x out 0) * (y out 0), (x out 0) * (y out 1), (x out 0) * (y out 2), (x out 0) * (y out 3), (x out 0) * (y out 4),
      (x out 1) * (y out 0), (x out 1) * (y out 1), (x out 1) * (y out 2), (x out 1) * (y out 3), (x out 1) * (y out 4),
      (x out 2) * (y out 0), (x out 2) * (y out 1), (x out 2) * (y out 2), (x out 2) * (y out 3), (x out 2) * (y out 4)
    )
    a

    the signal whose channels to repeat

    num

    the number of repetitions for each input channel

    See also

    ChannelRangeProxy

  16. final case class Silent(numChannels: Int) extends GE.Lazy with AudioRated with Product with Serializable

    Permalink

    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.

    numChannels

    the number of output channels

    See also

    DC

  17. final case class SplayAz(rate: Rate, numChannels: Int, in: GE, spread: GE, center: GE, level: GE, width: GE, orient: GE) extends GE.Lazy with Product with Serializable

    Permalink

    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
    numChannels

    the number of output channels

    in

    the input signal

    spread

    the spacing between input channels with respect to the output panning

    center

    the position of the first channel (see PanAz)

    level

    a global gain factor (see PanAz)

    width

    the width parameter for each PanAz

    orient

    the orient parameter for each PanAz

    See also

    PanAz

  18. final case class WrapOut(in: GE, fadeTime: Double = 0.02) extends ZeroOut with WritesBus with Product with Serializable

    Permalink

    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.

    in

    the signal to play to the default output

    fadeTime

    the fade in time; use a negative number for no fading

  19. final case class Zip(elems: GE*) extends GE.Lazy with Product with Serializable

    Permalink

    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 out 0, b out 0, a out 1, b out 1 ]. If the input signals have different numbers of channels, the minimum number of channels is used.

    Examples
    // 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()
    elems

    the signals to interleave in a multi-channel output signal

Value Members

  1. object Env extends EnvFactory[Env] with Serializable

    Permalink
  2. object IEnv extends EnvFactory[IEnv] with Serializable

    Permalink
  3. object Mix extends Serializable

    Permalink

    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.

    Examples
    // 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
      }
    }
    See also

    BinaryOpUGen

    Reduce

  4. object Pad extends Serializable

    Permalink

    A graph element that controls the multi-channel expansion of its in argument to match the to argument by padding (extending and wrapping) it.

  5. object PhysicalIn extends Serializable

    Permalink

    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.

  6. object PhysicalOut extends Serializable

    Permalink

    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.

    Examples
    // 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)
    }
  7. object Reduce extends Serializable

    Permalink
  8. object Silent extends Serializable

    Permalink

    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.

    See also

    DC

  9. object SplayAz extends Serializable

    Permalink

    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
    See also

    PanAz

  10. object WrapOut extends Serializable

    Permalink

    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.

Ungrouped