Chapter 4
Instruments & effects
Load a sound, chain effects after it, set any control.
The chain
.synth("…") loads an instrument; each .fx("…") adds an effect after it,
as many as you like.
lead: note("c4 e4 g4 b4")
.synth("Wavetable")
.fx("Chorus")
.fx("Delay").postgain(1)
These devices are built in, the same as in the browser build. The sounds tab lists them, and names autocomplete inside the quotes. Your VST/VST3 plugins load the same way (below).
| Instruments | |
|---|---|
Wavetable | two wavetable oscillators with warping, a sub and noise |
FM | eight operators, each able to modulate every other |
Granular | a sample played as a cloud of grains |
Noise | noise in ten colors, from white to brown and on to velvet, crackle, digital, stepped and chaos |
Formant | a spectral peak that stays put while the note moves: VOSIM pulse trains, or a driven impulse fired every cycle |
Additive | up to sixty-four sine partials a voice, shaped by a slope, the balance of odd and even, a stretch toward bells, damping that darkens each note as it rings, and a spectrum you draw as a named shape |
Analog | two drifting oscillators, a sub and noise through an analog filter circuit with its own envelope on every voice: acid lines, basses, leads, pads, brass and strings (one voice is a monosynth) |
Acid | an acid bassline voice modeled from its circuit: saw or square into a diode ladder, with the accent sweep and the slide (monophonic) |
Kick | an analog-style bass drum: a saturated body swept down to f0, with a click (one hit at a time) |
Hat | hi-hats, cymbals and a cowbell: clusters of square waves and noise through a bright band and a body band, analog or sampled in character (one hit at a time) |
Drum | a struck body and a burst of noise: claves, wood blocks, rims, toms, congas, snares, claps and everything between |
Pluck | plucked strings: a burst of noise into a tuned delay loop, two strings a voice, from nylon and steel through muted and bowed to stiff bars and bells |
Plaits | a macro oscillator with twenty-four models behind three controls (monophonic) |
Braids | forty-eight oscillator models behind two controls |
Rings | a resonator struck by its own exciter |
Elements | a modal resonator played by a bow, a breath and a mallet (monophonic) |
| Effects | |
|---|---|
Filter · EQ · LPG | multimode filter: the classical shapes, and eight analog circuits modeled with their saturation and resonance · four-band equalizer, each band's Slope setting a cut or shelf to 12, 24, 36, 48, 72 or 96 dB per octave · low-pass gate, struck by notes routed in with .midi() or by its Trigger: .param("Trigger", button()) |
Filterbank · Resonator | filter banks whose band levels Shape moves, scrolled across the bands or rippling across them, and Levels steps, a cycle of a pattern at a time · narrow ringing bands on every note of the track's scale, or on the notes another track holds, with .midi() |
Distort · Overdrive · Crush | waveshaping, with curves you draw as named shapes · band-limited drive · bits and rate |
Compressor · Multiband · Limiter · Ducker | dynamics; the compressor and ducker take a sidechain |
Delay · GrainEcho · Stutter | stereo delay · grain delay · synced repeats |
Chorus · Flanger · Phaser | modulation |
Reverb · Spring · Convolver · CloudSeed · Galactic | algorithmic · a two-spring tank whose echoes arrive as rising or falling chirps, with a saturating driver, feedback past unity and Shake to knock it; notes routed in with .midi() tune it and ping it · impulse responses · two very large spaces |
Clouds · FreqShift | granular processing · frequency shifting |
Shift · VocalShift | pitch and formant shifting: chords and whole mixes · one voice or line, with less delay |
Looper | a press of Record records the next pass of Length bars, starting and ending on that grid; the first pass sets the loop and the rest overdub onto it; Mix crossfades the input against the loop, heard and (while recording) recorded; tape-style speed and reverse, and Clear to start again |
setscale("E minor")
bells: n("0 4 7 <9 11>").sc(4).synth("Rings")
.param("Model", "'Sympathetic String'").param("Brightness", 0.6)
.fx("GrainEcho").postgain(0.6)
pulse: note("e1*8").synth("Braids").param("Shape", "'Saw Sub'")
.fx("Filter").param("Mode", "ladder").param("Cutoff", saw(0.5).range(0.25, 0.55))
.fx("Overdrive").postgain(0.3)
Filter's circuit modes are each an analog filter's own equations, so they saturate as
Drive goes up and their resonance behaves the way the circuit's does. ladder
is the transistor four-pole: it loses bass as the resonance rises and sings at the top.
diode is the diode four-pole of acid bass lines: rubbery, its peak moving with the
resonance, ringing without ever quite singing. ota is a smoother four-pole that keeps
its bass. The two-poles take Morph, lowpass to bandpass to highpass:
sallen screams as its clipped feedback bites, statevar is smooth and runs
through a notch instead of a band, cmos grinds, polar is hard and harsh, and
diodepair has a squelchy peak.
acid: note("c2 c2 c3 <eb2 g2> c2 bb1 c3 f2").synth("Wavetable")
.fx("Filter").param("Mode", "diode").param("Resonance", 0.85).param("Drive", 3)
.param("Cutoff", saw(2).range(0.25, 0.6)).postgain(0.5)
Filterbank and Resonator move their bands' levels with Shape. In
scroll mode each band shows what Shape was a moment before the band under it, so a
sweep travels up the spectrum; in ripple mode Shape strikes the band at
Where and the ripples bounce between the ends. Levels takes one cycle
of a pattern, laid across the bands from low to high.
setscale("D dorian")
pad: n("<0 3> [4 7]").sc(3).synth("Wavetable")
.fx("Resonator").param("Shape", sine(0.5)).param("Decay", 0.4)
.param("Levels", "<[1 0 .5 1] [0 1 0 .3]>")
.postgain(0.5)
kick: s("bd*4")
.fx("Filterbank").param("Mode", "ripple").param("Where", 0.2)
.param("Shape", perlin(4)).param("Width", 0.3)
.postgain(0.5)
Kick plays one hit per note, and settles on f0 whatever the note is.
Sweep is how many semitones above f0 the pitch starts, falling on one
fixed curve; Drive hardens
the body. Decay is the length and Decay Curve its shape: up keeps the
belly, down falls away into a thin tail. Click is the click's level,
Click Tone turns it from a pitched tick through a pulse into noise, Click
Pitch is the tick's pitch, and Click HP and Click LP filter the
click. Click Length is the trigger: a shorter one is a brighter click and less sweep.
Click Sample plays a file as the click instead, with its lows cut at least where the
sweep starts; Click Pitch then transposes it, in semitones. Tone brightens or softens the whole hit. A new hit
restarts the sweep; the last one fades under it. A softer note is quieter, with less click
and less sweep.
kick: note("f0*4").synth("Kick")
.param("Sweep", "34st").param("Drive", 0.5).param("Tone", 0.8)
.decay("<0.4 0.9>").postgain(0.8)
Pitch Env takes a drawn shape in place of the fixed curve: pitches over
Length, on a log axis from 20 Hz at the bottom to 20 kHz at the top, played as drawn.
A point written n instead of a level is on the note: it lands on the note each hit
is played on, and the points before it stay where they were drawn. A curve whose tail is on the
note is tuned by the notes, as an 808 is. In the editor, right-click a point to put it on the
note. Sweep is the fixed curve's alone, and velocity leaves a drawn curve's pitch as drawn. Amp Env takes a drawn level
the same way, stretched over Decay.
kick: note("<f0 f0 g0 d#0>*4").synth("Kick")
.param("Pitch Env", "drop").decay(0.6).postgain(0.8)
_shape("drop", "0,0.4 0.25,0.2,-2 0.5,n 1,n")
Hat plays one hit per note, and a new hit cuts the last, so a closed hat chokes an open
one: pattern .decay() and the long hits are the open ones. Middle C plays its squares at
their own pitches; other notes retune them. Source picks the squares: an analog cluster, a
thinner one, a dense one that stands in for a recorded cymbal, or two, which is a cowbell.
Tone moves the filters from dark to bright, Attack lets each hit swell
up as a shaker does (.attack() sets it), Hold keeps the level up before it
drops, Body adds a lower band that rings on after the bright one, Noise
blends in white noise, and Lofi gives it the grit of a coarse recording.
Warp folds the squares into a denser, clangier metal, Ring makes the bright
band whistle, and Filter Sweep starts each hit's filters above or below Tone and
brings them back: a zap. Harder hits are louder and brighter and sweep further, and no two hits are
quite the same.
hats: note("c3*8").synth("Hat")
.decay("<0.07 0.07 0.5 0.07>").vel("<1 0.6 0.8 0.6>")
.param("Tone", sine(0.25).range(0.7, 0.95))
.postgain(0.6)
Presets in four characters, each with a closed, an open and a pedal hat: analog,
thin, crisp and grainy, with cymbals, a crash, a ride and two
cowbells; and zap, whistle, clang, foldcymbal and
shaker.
hats: note("c3*8").synth("Hat").preset("<crispclosed crispclosed crispopen crisppedal>").postgain(0.6)
ride: note("c3*4").synth("Hat").preset("crispride").postgain(0.4)
bell: note("~ c3 ~ c3").synth("Hat").preset("cowbell").postgain(0.5)
zap: note("~ ~ c3 ~").synth("Hat").preset("<zap clang>").postgain(0.5)
Drum plays one hit per note: a struck body and a burst of noise. Material
is what is struck, from one resonance (a clave) through a wooden bar (a wood block) to a drum
skin (a tom, a conga), and the note is the pitch of the body's lowest mode. Edge
is where it is struck: turned up, the upper modes come forward, past the lowest at the top.
Decay is how long the body rings, Ring how long its upper modes
keep up (all the way is a metal shell), Drop how far above its pitch it starts and
Click the stick, which Click HP and Click LP filter.
Click Sample plays a file as the click instead, with its lows cut at least at the
body's starting pitch, and Click Pitch transposes it. Noise mixes the body against noise, up to all
noise; Noise Tone is where the noise sits, Noise Length how long it
lasts, Noise Tail a quieter second stage eight times as long, and
Stutter splits its start into quick bursts, as a clap does. Cutoff is a
resonant lowpass over each hit, which Filter Sweep starts above or below and brings
back over Filter Decay; FM bends the body with a second sine at FM Ratio
times the note, fading over the same time. Drive saturates the whole hit. Hits ring into one another,
and note offs are ignored. Each hit keeps the controls it was struck with while it rings, so
one track can play a whole kit: a preset or a control that changes per note changes the next
hit and leaves the last one ringing. Level follows as the hit plays.
It comes with presets, each at its own pitch on c3. Snares: snare,
brightsnare, tightsnare, gritsnare, hisssnare.
Claps: clap, bigclap, shortclap. Rims: rim,
lowrim, woodrim. Toms: lowtom, midtom,
hightom, sweeplow, sweepmid, sweephigh,
ringlow, ringmid, ringhigh. Hand drums: conga,
bongo, slapbongo, lowbongo, doum, tek,
timbale, lowtimbale. Wood: woodblock, clave.
Swept and bent: zap, knock, clang, boom,
buzz, crunch.
A preset sets every control but Level and Voices.
kit: note("c3*8").synth("Drum")
.preset("<[sweeplow brightsnare lowrim brightsnare] [slapbongo bigclap woodblock bigclap]>")
zaps: note("c3 [~ c3] [c3 c3] ~").synth("Drum").preset("<zap knock>")
.param("Filter Decay", "<30ms 80ms 200ms>").postgain(0.6)
wood: note("c3*8").synth("Drum").preset("clave")
.param("Material", "<0 0.25 0.5 0.75>").postgain(0.4)
Analog is a classic subtractive synth. Each oscillator is a saw,
square (with Width), triangle or sine; osc 2 sits
Osc 2 Semi and Osc 2 Detune away, Sync restarts it with osc 1 so
its tuning moves the tone, and Mix sets the balance of the two. Sub is a square
an octave down and Noise is white. Drift lets each oscillator wander slightly
out of tune. Every voice has its own filter: Filter Type is any of the Filter effect's
modes, by the same names - lowpass, highpass and bandpass at their slopes, notch, peak, comb,
allpass, formant, and the analog circuits - and Morph turns the multimode circuits toward
bandpass and highpass; Cutoff and
Resonance set it, Drive pushes into a circuit, Key Track moves it with
the note, and Env Amount is how far the filter envelope sweeps it, up or down, in
semitones. Velocity is how much a harder note opens the filter further. Both envelopes are
on the device's graphs. With Voices at 1 it is a monosynth: a note played over a held one
slides there over Glide without starting the envelopes again. A note marked with
.slide() does the same on any synth with a Glide, overlapping or not -
which is how an acid line slides.
Presets: acid, bass, sub, lead, sync
(one voice each), pad, strings, brass, keys,
pluck. A preset sets every control but Level, and these set
Voices too.
acid: note("c2 c2 [c3 eb2] c2 g1 c2 [bb1 c2] c3").synth("Analog").preset("acid")
.slide("0 0 [1 0] 0 0 1 [0 1] 0")
.param("Cutoff", sine(0.125).range(0.25, 0.5)).postgain(0.5)
pad: note("<[c3,eb3,g3,bb3] [ab2,c3,eb3,g3]>").synth("Analog").preset("pad").postgain(0.4)
Acid is one voice of the classic acid bassline machine, modeled from its circuit. The
oscillator is a saw, or at Waveform 1 the lopsided square its shaper makes of the saw
(Square Shape moves the edge). The filter is a four-pole diode ladder whose
Resonance is fed back through a highpass, so it squeals near the top of a sweep and
stays quiet at the bottom. Character sharpens it: at 0 the circuit's soft ladder, at
1 a steep lowpass whose corner sits on Cutoff. Cutoff sets it, Env Mod is how far the
filter envelope sweeps it, and Decay how long that envelope falls. A note at velocity
0.9 or more is accented: its envelope falls in 0.2 s whatever Decay says, and
Accent sends it into the accent sweep, which opens the filter and the level - with
the resonance up, a run of accents stacks, each opening further than the last
(Sweep scales how long it holds). A note marked with .slide() glides
over Slide without a new attack; hold the note before it into it with
.clip(). Drive clips after the amplifier. Presets: squelch,
rubber, square, mellow, scream,
hollow, driven.
bass: note("c2 c2 c3 bb2 eb2 c2 g1 c2").synth("Acid").preset("squelch")
.vel("1 0.7 0.7 1 0.7 0.7 1 1").slide("0 0 0 1 0 0 0 0")
.clip("0.5 0.5 1 0.5 0.5 0.5 0.5 0.5").postgain(0.6)
Controls
.param("name", value) sets a control on the last device in the chain,
by the name its panel shows. The value can be a number, a pattern, or anything that moves
(next chapter).
keys: n("0 2 4 <5 7>").scale("D dorian").synth("Plaits")
.param("Engine", "Chord")
.param("Timbre", sine(0.2))
.fx("Reverb").param("Mix", 0.35).postgain(0.45)
Every value is a 0..1 position on the control, and the device maps it to its real
range (Cutoff runs 20 Hz to 20 kHz, so 0.5 is about 630 Hz). A list control takes its option's
name ("ladder", or "'Saw Sub'" for a name with a space in it) or
index; a switch takes 0 or 1. So an LFO or a macro drives any
control as it is.
A value written with a unit is in the control's own units: "3x", "800hz",
"2khz", "-6db", "250ms", "7st", "50ct".
A note on a control in hertz is its frequency, as a name ("c5") or as a
note() pattern. A bare number is a position.
bell: n("0 2 4 <5 7>").scale("D dorian").synth("FM")
.param("Op 2 Level", 0.6).param("Mod 2 to 1", 0.5)
.param("Op 2 Ratio", "<1x 2x 3.5x 7x>")
.fx("Filter").param("Cutoff", "<1.2khz 4khz>").postgain(0.5)
To find names, evaluate once, then open params in the sounds tab: every control
of every device on the track, searchable, click to copy. They autocomplete inside
.param("…") too.
Name a device first and .param() reaches it wherever it sits in the chain:
.param("Delay", "Feedback", 0.6). When two devices share a name,
"Filter#2" is the second of them in chain order. A label given as
.fx("Filter", { label: "lo" }) is reached as "lo" however the chain is
reordered. .wet() takes a device the same way. Inside a .when(), a control
follows the condition, then yields: to a .param() outside the .when(), or,
with none, to wherever the control was before. A .param() after the .when()
wins over it, as a later call always does.
keys: n("0 2 4 <5 7>").scale("D dorian").synth("FM")
.fx("Filter", { label: "lo" }).param("Cutoff", 0.35)
.fx("Delay").wet(0)
.when("<0 1>", x => x.param("lo", "Cutoff", 0.7).wet("Delay", 0.5))
.postgain(1)
.wet(v) after a device blends it with what goes into it: 0 bypasses, 1 (the default) is
fully processed. It takes a signal, so an effect can fade in over a song.
Parallel branches
.split() runs the chain in parallel and sums the branches; anything after it
processes the sum. Each branch is a function that builds a chain on the signal it is handed,
(x) => x is the signal as it arrives, and a branch's .postgain() and
.pan() are its own level and place in the sum. Every device in every branch is on
the same track, so notes routed in with .midi() strike a gate in any of them, and
.param() reaches the device just before it, branch or not. Here two low-pass gates,
one short and one long, sit either side of the dry synth:
lead: note("c2 eb2 g2 <bb2 f2>").synth("Wavetable")
.split(
(x) => x.postgain(0.3),
(b) => b.fx("LPG").midi("lead").param("Decay", 0.08).pan(-0.6),
(b) => b.fx("LPG").midi("lead").param("Decay", 0.6).pan(0.6).postgain(0.7),
)
.fx("Reverb").param("Mix", 0.25).postgain(0.6)
.bands([frequencies], ...) splits by frequency instead, one function per band from the
lowest up. The crossovers are Linkwitz-Riley, so bands left alone add back up to the input, and
each one is a control: a number, a pattern or a signal, swept here. The devices in the bands
number as they would in a .split(): the crossovers are not effects of the chain.
drums: s("pt_kit:0*4, ~ pt_kit:4 ~ pt_kit:4")
.bands([sine(0.1).range(150, 400), 2500],
(low) => low,
(mid) => mid.fx("Distort").param("Drive", 0.6),
(high) => high.postgain(0.8),
)
.postgain(0.5)
Branches nest, and a .split() can sit inside a band, or a .bands() inside
a branch.
Presets
synth or fx to open a device's panel.
Double-click the synth or fx name to open the device's panel
(a plugin's own window, for a plugin). Change anything there and the whole state is captured
into the code as a named preset: the call gains .preset("lead"), and the preset is
kept in a folded _preset(…) line at the foot of the buffer. There is nothing to press,
and the song sounds the same when it is next opened.
// a different preset each cycle
lead: note("c4 e4 g4 [b4 c5]").synth("Wavetable").preset("<soft buzz>")
.postgain(0.5)
_preset("soft", "Wavetable", "eyJkZXZpY2UiOiJXYXZldGFibGUiLCJ2ZXJzaW9uIjoxLCJwYXJhbXMiOnsib3NjMS50YWJsZSI6OCwib3NjMS5wb3NpdGlvbiI6MC4zNSwiYW1wZW52LmF0dGFjayI6MC4wNiwiYW1wZW52LnJlbGVhc2UiOjAuNSwic3ViLmxldmVsIjowLjN9LCJmaWxlcyI6e319")
_preset("buzz", "Wavetable", "eyJkZXZpY2UiOiJXYXZldGFibGUiLCJ2ZXJzaW9uIjoxLCJwYXJhbXMiOnsib3NjMS50YWJsZSI6NCwib3NjMS5wb3NpdGlvbiI6MC42LCJvc2MxLnVuaXNvbiI6NCwib3NjMS5kZXR1bmUiOjMwLCJhbXBlbnYuYXR0YWNrIjowLjAwNSwiYW1wZW52LmRlY2F5IjowLjI1LCJhbXBlbnYuc3VzdGFpbiI6MC40LCJhbXBlbnYucmVsZWFzZSI6MC4xNX0sImZpbGVzIjp7fX0=")
Preset names pattern like anything else. Double-click preset to pick, make, copy
and tweak them.
export hands someone one file that plays exactly what you hear; link copies the patch without its presets.
A share link carries the presets with the code.
A device's preset opens the same in the browser build and the desktop app.
Most devices come with presets of their own, listed in the preset picker in their panel:
.synth("Wavetable").preset("pad") plays one, and a preset of yours with the same
name wins. Each sets every control but Level and Voices.
Your plugins
Any VST/VST3 instrument or effect you have installed loads by its own name, in the same places a
device does. This guide uses "Serum 2", "Diva" and so on as stand-ins:
use plugins you have. The sounds tab lists them (press rescan
after installing one; click a name to copy it), and names autocomplete inside the quotes.
lead: note("c4 e4 g4 b4")
.synth("Serum 2")
.fx("ValhallaDelay")
.fx("Pro-Q 3")
Double-click the name to open the plugin's own window. What you change there is captured into a
.preset(), as with a device.
.param("Filter 1 On", 1)
.param("Filter 1 Freq", 0.6)
.param("Frequency#95", 0.3) // the control at index 95, where two share a name
A plugin's values are 0..1 unless a mapping file in mappings/*.json gives them real
units (one ships for Serum 2, so its cutoff takes Hertz:
.param("Filter 1 Freq", sine(0.3).range(200, 5000))). When a plugin reuses a name,
"Frequency#95" picks one by index; autocomplete shows that form where names collide.