Supex.Ugen (supex v0.1.1)

View Source

For composing Oscillators and other SuperCollider's UGens (UnitGnerators).

examples

iex> import Supex.Ugen iex> osc() |> freq(690) |> phase(6) |> mul(0.9) |> add(0.69) |> name("y") %Supex.Ugen{add: 0.69, phase: 6, freq: 690, mul: 0.9, sc_command: "SinOsc.ar(freq: 690, phase: 6, mul: 0.9, add: 0.69);", sc_name: "y"}

iex> alias Supex.Ugen iex> Ugen.osc(%Supex.Ugen{add: 0.69, phase: 6, freq: 690, mul: 0.9}) %Supex.Ugen{add: 0.69, phase: 6, freq: 690, mul: 0.9, sc_command: "SinOsc.ar(freq: 690, phase: 6, mul: 0.9, add: 0.69);"}

Summary

Functions

Transforms a "normal" oscillator to a LFO.

Name the oscillator. SuperCollider only excepts single chars, like "y", "i"...

Adding play to the sc_command, and naming it for referencing.

Stop sc_command with name reference.

Functions

add(ugen, add)

(since 0.1.0)
@spec add(
  %Supex.Ugen{
    add: term(),
    freq: term(),
    lfo: term(),
    mul: term(),
    osc: term(),
    phase: term(),
    sc_command: term(),
    sc_name: term(),
    width: term()
  },
  integer() | float() | binary()
) :: struct()

freq(ugen, freq)

(since 0.1.0)
@spec freq(
  %Supex.Ugen{
    add: term(),
    freq: term(),
    lfo: term(),
    mul: term(),
    osc: term(),
    phase: term(),
    sc_command: term(),
    sc_name: term(),
    width: term()
  },
  integer() | float() | binary()
) :: struct()

lfo(ugen)

(since 0.1.0)
@spec lfo(%Supex.Ugen{
  add: term(),
  freq: term(),
  lfo: term(),
  mul: term(),
  osc: term(),
  phase: term(),
  sc_command: term(),
  sc_name: term(),
  width: term()
}) :: binary()

Transforms a "normal" oscillator to a LFO.

It uses kr (control rate) instead of ar(audio rate), cf. https://doc.sccode.org/Tutorials/Getting-Started/05-Functions-and-Sound.html

mul(ugen, mul)

(since 0.1.0)
@spec mul(
  %Supex.Ugen{
    add: term(),
    freq: term(),
    lfo: term(),
    mul: term(),
    osc: term(),
    phase: term(),
    sc_command: term(),
    sc_name: term(),
    width: term()
  },
  integer() | float() | binary()
) :: struct()

name(ugen, sc_name)

(since 0.1.0)

Name the oscillator. SuperCollider only excepts single chars, like "y", "i"...

osc(type \\ :sin)

(since 0.1.0)
@spec osc(
  :pulse
  | :saw
  | :sin
  | %Supex.Ugen{
      add: term(),
      freq: term(),
      lfo: term(),
      mul: term(),
      osc: term(),
      phase: term(),
      sc_command: term(),
      sc_name: term(),
      width: term()
    }
) :: struct()

phase(ugen, phase)

(since 0.1.0)
@spec phase(
  %Supex.Ugen{
    add: term(),
    freq: term(),
    lfo: term(),
    mul: term(),
    osc: term(),
    phase: term(),
    sc_command: term(),
    sc_name: term(),
    width: term()
  },
  integer() | float() | binary()
) :: struct()

play(ugen)

(since 0.1.0)
@spec play(
  binary()
  | %Supex.Ugen{
      add: term(),
      freq: term(),
      lfo: term(),
      mul: term(),
      osc: term(),
      phase: term(),
      sc_command: term(),
      sc_name: term(),
      width: term()
    }
) :: <<_::64, _::_*8>>

Adding play to the sc_command, and naming it for referencing.

You can pass a %Ugen{} struct or a SuperCollider's command.

Supex and raw SuperCollider's command will by default refrenced with the variable "x". For example, you can stop playing it with osc() |> name("x") |> stop()

stop(ugen)

(since 0.1.0)
@spec stop(%Supex.Ugen{
  add: term(),
  freq: term(),
  lfo: term(),
  mul: term(),
  osc: term(),
  phase: term(),
  sc_command: term(),
  sc_name: term(),
  width: term()
}) :: <<_::48, _::_*8>>

Stop sc_command with name reference.

width(ugen, width)

(since 0.1.0)
@spec width(
  %Supex.Ugen{
    add: term(),
    freq: term(),
    lfo: term(),
    mul: term(),
    osc: term(),
    phase: term(),
    sc_command: term(),
    sc_name: term(),
    width: term()
  },
  integer() | float() | binary()
) :: struct()