Contents

Variables & Assignment

Variables store values for reuse throughout your patch.

Basic assignment

Use = to bind a value to a name:

// Store a frequency
freq = 440

// Use it in oscillators
sine(freq) |> out(@)

Signal variables

Variables can store entire signal chains:

// Store an oscillator
osc = saw(110) |> lp(@, 800)

// Use it multiple times
osc |> out(@)

Modular patching

Variables make larger patches readable:

// Define components
lfo_mod = sine(0.5) * 500
base_freq = 110
filter_cutoff = 400 + lfo_mod

// Build the patch
saw(base_freq) |> lp(@, filter_cutoff) |> out(@)

Naming rules

  • Names must start with a letter or underscore
  • Can contain letters, numbers, and underscores
  • Case-sensitive (Freq and freq are different)
  • Cannot use reserved keywords
// Valid names
freq = 440
my_osc = sine(220)
bass1 = saw(55)
_internal = 0.5

// Invalid names
// 1freq = 440     // Can't start with number
// my-osc = sin()  // No hyphens

Scope

Variables are visible from their definition point to the end of the program:

a = 100
b = a * 2      // a is visible here
c = a + b      // both a and b visible

Related: Operators, Pipes & Holes, Records