A synthesizer creates sound from changing signals. You do not need a circuit diagram to begin: choose a starting tone, shape how bright it is, and decide how it begins and ends. Those three choices already cover a remarkable range of basses, leads, keys and pads.
Start with Your first sound if the code is new to you. Each example below is independent; replace the previous program with the whole next example when comparing them.
1. Choose the raw material#
An oscillator repeats a waveform. Its repetition rate determines pitch; its shape determines its mixture of overtones, which affects tone color or timbre.
| Starting sound | What to listen for | Useful direction |
|---|---|---|
"sine" | A smooth, pure tone | Sub bass, soft tones, FM building blocks |
"triangle" | A soft tone with a little edge | Rounded basses, gentle leads |
"saw" | A bright buzz | Filtered bass, strings, bold leads |
"square" | A hollow, woody buzz | Retro leads, pulse-like basses |
Listen for: the clean, rounded outline of the melody.
tempo = 120bpm
timingVersion = 2
play "sine" "c4 [e4 g4] b4 g4" |> release 120ms
Make it yours: replace "sine" with "saw". Keep the notes unchanged so you can concentrate on the tone. Then try "triangle" and "square".
2. Sculpt the brightness#
A low-pass filter lets low frequencies through and reduces higher ones. Its cutoff sets where that reduction begins. Raising the cutoff usually makes a harmonically rich sound brighter. Resonance emphasizes frequencies near the cutoff, giving a sweep a more pronounced vowel-like edge.
Listen for: the same saw-wave phrase becoming darker and brighter on alternate bars. The angle brackets choose one cutoff value per cycle.
tempo = 120bpm
timingVersion = 2
play "saw" "c3 eb3 g3 bb3"
|> cutoff "<500 2400>"Hz
|> resonance 2
|> release 100ms
Make it yours: try "<300 4500>"Hz for a larger contrast. A filter cannot reveal high overtones that a pure sine did not contain; use the saw for this comparison. Explore the different colors in Filters.
3. Shape the beginning and ending#
An envelope changes a value over the life of a note. The common ADSR shape has four stages:
| Stage | What it controls | A useful first experiment |
|---|---|---|
| Attack | Time to rise to full level | 5ms for a quick start; 400ms for a swell |
| Decay | Time to fall to the sustained level | Short for a pluck; longer for a soft key |
| Sustain | Level while the note is held | 0.2 is quiet; 0.8 stays strong |
| Release | Time to fade after the note ends | Short for separation; long for overlapping tails |
Sustain is a level, not a duration. A note must last long enough for a slow attack to become audible.
Listen for: the notes swelling in and gently overlapping.
tempo = 120bpm
timingVersion = 2
play "saw" "c4 g4"
|> cutoff 1800Hz
|> attack 350ms
|> decay 300ms
|> sustain 0.55
|> release 700ms
|> reverb 0.37 0.18
Make it yours: change attack to 5ms and release to 80ms. The same oscillator now has a much more immediate, separated feel.
4. Build your own instrument#
A patch puts those choices in one reusable instrument. Inside a patch, pitch is the incoming note, freq pitch converts it to a frequency, and vel is the strength of the incoming hit. Multiplying gain by vel makes the patch respond to accents.
Listen for: a bright initial pluck that quickly becomes softer and darker.
tempo = 120bpm
timingVersion = 2
softpluck = patch {
source = saw (freq pitch),
ampEnv = adsr 5ms 180ms 0.15 160ms,
filtEnv = adsr 2ms 220ms 0 100ms,
cutoff = 500Hz + filtEnv * 2600Hz,
resonance = 1.5,
gain = vel * 0.3
}
play softpluck "c4 [eb4 g4] bb4 g4"
Make it yours: change the filter envelope's 220ms to 600ms. Listen for the brightness lingering after the initial hit. The amplitude and filter envelopes have separate jobs, even when they start together.
Choose your next kind of synthesis#
| Technique | How it makes a sound | Explore |
|---|---|---|
| Subtractive | Start bright and remove frequencies | Filters, Analog character |
| FM and phase modulation | One oscillator changes another at audio speed | FM, phase and ring modulation |
| Wavetable | Move through a collection of waveforms | Wavetable synthesis |
| Additive | Combine individual partials | Additive synthesis |
| Physical modeling | Excite a model of a vibrating object | Strings and resonators |
| Granular | Layer tiny windows of recorded sound | Granular synthesis |
Next: Bring a sound to life adds repeating movement, and The sound recipe book turns these ideas into instruments.