How an envelope follower works
An envelope follower turns a sound into a voltage that follows how loud it is: a diode rectifies it and a capacitor smooths it. Here the capacitor charges in about 2 ms and lets go through 100 kΩ, 63% in 100 ms, fast enough to follow a plucked note's fade.
circuit Follower setting input: 1 V, from 0.1 V to 2 V setting release: 100k, from 10k to 1M U1 in k d opamp rails 12V D1 d k 1N4148 Ra k e 1k C1 e gnd 1u Rr e gnd release U2 e out out opampendPress Play to see the wave after the circuit, at out.
What you're hearing
First, keep only one side of the wave. A sound swings above and below 0 V, so its average is zero, whatever its loudness. To measure loudness, the circuit lets only the tops through: that's rectifying, a diode's job (see the octave-up rectifier). A diode on its own needs about 0.6 V across it before it conducts much, which would lose the quiet end of every note. So D1 sits inside U1's feedback. U1 compares the input with the far side of the diode and lifts its output by whatever the diode drops, so the far side, k, matches the input exactly while the input is above the capacitor. Below it, U1 swings down, D1 turns off, and nothing gets back. This is a precision rectifier, half-wave: it catches the positive peaks.
Then a capacitor holds the peaks. Each peak charges C1, 1 µF, through Ra, 1 kΩ. Between peaks, C1 drains through Rr, the release knob, 100 kΩ. Charging is quick: from silence to a steady 1 V note, the output is 63% of the way there after 1.9 ms and 90% after 11 ms, a few cycles, because the diode conducts only near each peak. Letting go is slow: the time constant is Rr × C1 = 100 kΩ × 1 µF = 100 ms, so 37% is left after 100 ms and 10% after 230 ms. That's attack and release: a small resistor in, a big one out, and the diode decides which one is working. U2 copies C1's voltage to the output without draining it (see the op-amp's two rules).
It follows the note's fade. Here the input is a plucked note, once a second, starting at 1 V and fading 40 dB each second. The release is quicker than the fade, so the output stays within a few percent of the note: 0.62 V after 0.1 s, when the note's peak is 0.63 V, and 0.098 V after 0.5 s, against 0.100 V. You hear it through a filter: 1 V at the output moves the cutoff three octaves up from 200 Hz. Each note opens it to about 1.2 kHz (0.87 V), and it closes as the note fades: 725 Hz after 0.1 s, 245 Hz after half a second. That's an auto-wah.
The trade-off is ripple. Between two peaks of a 110 Hz note, 9.1 ms apart, C1 drains a little. At 100 kΩ, a steady 1 V note gives a peak of 0.93 V with a dip of 0.070 V between peaks, 7.5%, a slight buzz in the filter. "Fast release" makes Rr 10 kΩ, a 10 ms time constant, about one cycle of the note: the output drops from 0.81 V to 0.41 V between peaks, the cutoff wobbles by more than an octave at 110 Hz, and the filter growls. "Slow release" makes it 1 MΩ, a 1 s time constant: the ripple shrinks to 0.008 V, but the output can't fall as fast as the note. It's still at 0.56 V after half a second, when the note is at 0.10 V, and at 0.34 V when the next note comes, so the filter never closes. A low note needs a slower release than a high one, so every follower picks a compromise.
Slow attack: a swell. "Slow attack" makes Ra 10 kΩ. On a steady note, the output takes 21 ms to get 63% of the way and 57 ms to get 90%. On each pluck it now peaks after 49 ms, at 0.52 V, instead of 0.87 V after 12 ms. It also settles lower, 0.67 V on a steady 1 V note: C1 only charges near each peak, while Rr drains it all the time, and a bigger Ra loses more of that race.
Without the op-amp, the tail is lost. "Plain diode" takes U1 out and feeds D1 straight from the input. Now the diode's drop comes off every peak: the note starts at 0.91 V, and the output reaches only 0.44 V. By 0.25 s, with the note at 0.32 V, the output is down to 0.08 V, and by half a second it's nothing. The filter opens to about 500 Hz and shuts while the note is still sounding.
Where followers are used. The same voltage can steer anything: a filter, as here; a VCA, so a synth's level follows a guitar; another sound's level, turned down whenever this one plays (ducking); or the sound's own level, turned down as it gets louder: the heart of a compressor. The op-amps here are ideal. A real one takes time to climb back from its rail every cycle, which smears the peaks of high notes (see an op-amp's slew rate).
Try this
- Turn release from 100k down to 10k, then up to 1M. The wah gets snappier, then starts to growl, then hangs open between notes.
- Press "Plain diode: the tail is lost", then "Release 100 ms". The same parts but one op-amp: listen to how much of each note's fade comes back.
- Open it in SynthMaker to change the parts. Make C1
2.2u: every time on this page grows 2.2 times, and the ripple shrinks with it.
The parts list
circuit Follower setting input: 1 V, from 0.1 V to 2 V setting release: 100k, from 10k to 1M U1 in k d opamp rails 12V D1 d k 1N4148 Ra k e 1k C1 e gnd 1u Rr e gnd release U2 e out out opampendU1's minus input is k, the diode's far side, so the op-amp makes up the diode's drop. input's range is written from the top so that a rising wire turns it down: here an LFO's rising saw, once a second, makes each note start loud and fade. For the plain diode, put a # in front of U1's line and change D1 to D1 in k 1N4148.
How we checked it
Checked against ngspice, a standard circuit simulator: the follower's output for a steady 1 V note is within 0.02% of ngspice. Measured in SynthMaker at the default release: a steady 1 V note gives a 0.93 V peak with 0.07 V of ripple, it charges to 63% in 1.9 ms and lets go to 37% in 100 ms.
Build it step by step
- The circuit format: Start a circuit, for writing diodes, op-amps and their rails in a parts list.
- The two halves: the octave-up rectifier, for the diode, and the RC filter, for the resistor and capacitor.
Further reading
- How a diode and a capacitor follow a signal's peaks, and the ripple trade-off: Wikipedia: Envelope detector.
- How an op-amp hides a diode's drop: Wikipedia: Precision rectifier.
- How a capacitor charges and discharges through a resistor: Wikipedia: RC time constant.
- What ripple is: Wikipedia: Ripple (electrical).
- A filter opened by how hard you play: Wikipedia: Auto-wah.
- Attack, release and the level detector in a compressor: Wikipedia: Dynamic range compression.
- How SynthMaker simulates a circuit: M. Holters and U. Zölzer, "A Generalized Method for the Derivation of Non-Linear State-Space Models from Circuit Schematics", EUSIPCO 2015. PDF