Skip to content

Envelopes and Modulation

A raw oscillator is static: press a key and it drones at one volume and one tone forever. Real instruments are alive — a note swells, brightens, decays, and fades. Modulation is the umbrella word for something changing over time, and it is what turns a flat synth tone into a musical sound.

This page explains the two kinds of modulation sources you will meet most often (envelopes and LFOs), the performance inputs that also act as modulation (velocity and key tracking), and the mod matrix that wires sources to destinations. It is concepts only — no code. For the blocks being modulated, read Synthesis Basics first.

The ADSR amplitude envelope

An envelope is a shape that plays out once per note. The classic envelope has four stages — Attack, Decay, Sustain, Release (ADSR) — and the most important one controls loudness over the life of the note:

StageWhat it controlsLong value sounds likeShort value sounds like
AttackTime to rise from silence to full levelSlow swell (pad, strings)Instant hit (pluck, piano)
DecayTime to fall from the peak down to the sustain levelGradual settleQuick drop
SustainThe level held while the key stays down (not a time)Loud held body (high level)Quiet or silent even while held (low/zero level)
ReleaseTime to fade after the key is let goLong tail, reverb-likeAbrupt cut-off

A plucked sound is fast attack, fast decay, zero sustain, short release. A pad is slow attack, high sustain, long release. Same oscillator — completely different instrument, just from the envelope.

SYNTH · SUBTRACTIVEIDLE
ADSR envelope — how a note rises and falls

The same held A3, shaped by its amplitude envelope. Attack and decay set how the note reaches and leaves its peak; sustain is the level it holds while a key is down; release is the fade after the key lifts. The top outline is that envelope — drag a control and watch the shape, then press play to hear it. (Sustain cannot reach a true zero here: the engine reads 0 as "leave the preset value", so the slider stops just above it.)

Attack
8 ms
Decay
140 ms
Sustain
0.75
Release
280 ms

Attack/Decay/Release are times; Sustain is a level

Three of the four ADSR controls are durations (in milliseconds). Sustain is the odd one out: it is a volume level, the amount held for as long as you keep the key down. That is why a "zero sustain" patch goes silent even while the key is still pressed.

A separate filter envelope

The amplitude envelope shapes loudness. A second, independent envelope can shape the filter cutoff so the tone evolves on its own schedule. A fast filter attack that decays back down gives the bright "pluck" of a synth bass; a slow filter attack makes a pad bloom open. Because the two envelopes are separate, a note can get quieter while getting brighter, or any combination.

The LFO — slow, repeating movement

An LFO (low-frequency oscillator) is an oscillator too slow to hear as pitch — typically a fraction of a hertz up to a few hertz. Instead of being heard directly, its gentle up-and-down wave is used to modulate something:

  • LFO → pitch = vibrato (the small wavering of a held note).
  • LFO → amplitude = tremolo (a pulsing volume).
  • LFO → filter cutoff = the slow "wobble" of bass and electronic textures.

The two key LFO controls are rate (how fast it cycles) and depth (how far it pushes the destination).

SYNTH · SUBTRACTIVEIDLE
LFO tremolo — modulation you can see

An LFO (low-frequency oscillator) is too slow to hear as a pitch; instead it moves something else. Here LFO 1 is routed to amplitude — tremolo — so the envelope ripples instead of holding flat. Rate sets how fast it pulses; depth sets how far. Turn depth to zero and the ripple disappears, leaving the plain held note. Press play to hear the pulsing. This is one routing in the mod matrix; the same LFO aimed at pitch would be vibrato, at the cutoff a filter wobble.

Rate
6 Hz
Depth
0.6

Velocity and key tracking

Two modulation sources come from how you play rather than from the synth itself:

  • Velocity — how hard a key is struck, sent as a number from 0 to 127 (see MIDI Basics). Routing velocity to amplitude makes soft presses quiet and hard presses loud; routing it to the filter makes hard presses brighter, like a real instrument played harder.
  • Key tracking — which key you play. Routing the played pitch to the filter cutoff keeps high notes as bright as low notes (without it, high notes can sound dull because their harmonics fall above a fixed cutoff).

The mod matrix

The mod matrix is the patch bay that connects everything. Each routing is three choices:

PartMeaningExamples
SourceWhat does the movingLFO 1, LFO 2, amp envelope, filter envelope, velocity, key tracking, mod wheel, random
DestinationWhat gets movedPitch (cents), filter cutoff (cents), amplitude (gain), pan (position)
DepthHow much, and which directionA large positive depth = a strong upward push; negative = the opposite

So "LFO 1 → pitch, small depth" is vibrato; "velocity → cutoff, large depth" is dynamic brightness; "filter envelope → cutoff" is the classic synth pluck. The same handful of sources and destinations, recombined, produce an enormous range of expressive behavior.

How libsonare implements this

In NativeSynth, modulation lives in the SynthPatch. The amplitude envelope is ampAttackMs, ampDecayMs, ampSustain, and ampReleaseMs; the independent filter envelope is the matching filterAttackMs / filterDecayMs / filterSustain / filterReleaseMs set. Two LFOs are configured with lfoRateHz and lfo2RateHz (with lfoToPitchCents as a direct vibrato shortcut). Free routings live in modRoutings, an array of { source, destination, depth } entries — the source is one of 'lfo1', 'lfo2', 'amp-env', 'filter-env', 'velocity', 'key-track', 'mod-wheel', 'random', and the destination is one of 'pitch-cents', 'cutoff-cents', 'amp-gain', 'pan-units'. A non-empty modRoutings replaces the base preset's matrix, and the matrix holds up to eight routings.

Related: Built-in Synthesizer (NativeSynth), Synthesis Basics, MIDI Basics