SynthMaker Manual Open SynthMaker (opens in a new tab)
Code

Code modules

A Code module is a module you write yourself: a few lines of maths that run for every sample of every note. Read it as code, as a graph of the maths, or both.

New words

A Code module is a module you write yourself: a few lines of maths, run for every sample of every note.

Smooth's inside: its code beside its graph of primitives, and a keyboard below.
Play the keys, then change the maths and play again. Open the example sound: Smooth Pluck ↗ (opens in a new tab)

1Start from code

  1. In the Code view choose + Start from code, or find Start from code under Custom modules in + Add a module.
  2. It goes into the wire to the Output, so you hear it at once: Smooth, a one-pole low-pass.
  3. Open it to read and change its code.
The Patch: the Filter into Smooth, a Code module showing its first lines, into the VCA.
Smooth, in the wire after the Filter.
  1. The Code module, with its first lines.

2What the lines mean

  • in x, out y and setting cutoff: 800 Hz, from 20 Hz to 20 kHz are its ports and its knob, as the Patch shows them.
  • The rest run in order, every sample: name = expression.
  • y' is y one sample ago. That's what makes a filter remember.
  • pi, rate (samples per second) and the voice's freq, gate, velocity and note are there to use.
  • Functions such as sin, exp, log, sqrt, abs, min, max, clamp, wrap and noise(), and if c then a else b for a choice.
Smooth · its code
module Smooth  in x  out y  setting cutoff: 800 Hz, from 20 Hz to 20 kHz  a = exp(-2 * pi * cutoff / rate)  y = x + (y' - x) * aend
Smooth's code beside its graph.
Its lines, and the maths they make.

3Code, Graph or Both

Graph draws the maths as boxes: every operator, number, input, setting and output, and y' as a one-sample delay with its feedback wire dashed back. It follows the code as you type. In SynthMaker, choose a box and its code lights; put the cursor in the code and its box is chosen.

The graph of Smooth: -2, π, the cutoff setting and rate multiplied and divided into exp, x and y' into a subtraction and a multiplication, and a dashed orange wire, y → y': one sample later.
The same lines, as a graph.

4Mistakes

A line that can't run turns red, with what's wrong, and the sound keeps its last good version. A Code module with a problem plays silence; the rest of the patch plays on.

The code with the line y = x + (y' - x) * b in red and under it: Line 6: I don't know "b" here (this module has x, y, cutoff, rate); the graph beside it dimmed.
A name the module doesn't have.

Try it

  1. Open Smooth Pluck, then Smooth.
  2. Change the last line to y = x + (y'' - x) * a: two samples ago, a different filter.
  3. Turn its Cutoff knob on Smooth's card and listen.
Open the example sound: Smooth Pluck ↗ (opens in a new tab)

On the Mac, a Code module opens the same way, as Code, Graph or Both.

Remember