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.
Pro: anyone can open any module and read its code, parts list or patch. Writing your own, or changing one, needs SynthMaker Pro. Turning its knobs is free.
New words

A Code module is a module you write yourself: a few lines of maths, run for every sample of every note.
1Start from code
- In the Code view choose + Start from code, or find Start from code under Custom modules in + Add a module.
- It goes into the wire to the Output, so you hear it at once: Smooth, a one-pole low-pass.
- Open it (or double-click its box) to read and change its code: Code, Graph or Both at the top.
- Play and turn Smooth's Cutoff knob down: the sound gets darker. Up: brighter.

- The Code module, with its first lines.
2What the lines mean
in x,out yandsetting cutoff: 800 Hz, from 20 Hz to 20 kHzare its ports and its knob, as the Patch shows them.setting mode: Low-pass, one of Low-pass, Band-pass, High-passis a knob that picks one of its names, as a Filter's Mode does. In the maths it's a number: 0 for the first name, 1 for the next. Put a name with a space in quotes:"1 bar".- The rest run in order, every sample:
name = expression. y'isyone sample ago. That's what makes a filter remember.pi,rate(samples per second) and the voice'sfreq,gate,velocityandnoteare there to use.- Functions such as
sin,exp,log,sqrt,abs,min,max,clamp,wrapandnoise(), andif c then a else bfor a choice.
Read the last line as: each sample, start from the new input x and keep a share a of the gap back to where y was. Near 1, y hardly moves, so fast changes (high frequencies) are smoothed away: dark. Near 0, y follows x closely: bright. Take y' away (y = x) and the module just passes the sound through: remembering is what makes a filter.
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

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.

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.
| You'll see | Because |
|---|---|
| I don't know “b” here | A name that isn't an input, a setting, or set by a line. |
| out y is never set | Every output needs a line that sets it. |
| y is set twice | Each name is set once per sample: give the second one a new name. |
| tanh isn't a function SMPL knows | Only the functions in the maths are there; the message lists them. |

Try it
- Open Smooth Pluck, then Smooth.
- Change the last line to
y = x + (y'' - x) * a: two samples ago, a different filter. - Turn its Cutoff knob on Smooth's card and listen.
On the Mac, a Code module opens the same way, as Code, Graph or Both.
Remember
- A Code module is
module Name … end: its ports, its knobs, and lines run every sample. y'is one sample ago.- Graph draws the maths; choosing a box lights its code.







