A filter removes part of the sound. A low-pass keeps the lows and cuts the highs — and once an envelope moves the cutoff, the filter stops being tone control and becomes the instrument.
cutoff = const 1200Hz sets where the filter starts cutting; harmonics above it get quieter. resonance boosts a peak right at the cutoff — a touch adds character, a lot makes it whistle.
A static cutoff is a fixed color. The classic synth move is to let an envelope open the filter on every note: declare a second envelope (filtEnv = adsr …) and write the cutoff as a formula.
cutoff = const 300Hz + filtEnv * 2500Hz reads: start at 300Hz, and let the envelope add up to 2500Hz on top — every note now goes bwow.
Multiply vel into the formula and hard-struck notes open brighter than soft ones — the filter starts responding to how you play.
The starting point#
The lesson opens with this song in the editor. Every edit recompiles and plays.
-- The filter: a low-pass carves the harmonics. Right now it's frozen in place.
saws = patch {
source = saw (freq pitch),
ampEnv = adsr 5ms 200ms 0.5 150ms,
cutoff = 1200Hz,
resonance = 6,
gain = vel * 0.4
}
loop = play saws !"c3 e3 g3 e3"
What to watch#
Watch the spectrum on each note: the high bars bloom open as the envelope rises and shut as it falls. Crank the resonance and a bump rides the moving edge.
Goals#
The workbench checks these as you work; the solution is there when you want it.
- Let an envelope open the cutoff
- Push the resonance to 8 or more and listen for the squelch
- Stretch: harder notes open brighter
Make it yours#
Sweep the base cutoff from 200Hz to 2000Hz a few values at a time, then shorten the filter envelope's decay until the bwow becomes a blip.
Further reading#
Filters: shape brightness and resonance in the reference.