GenxiTechSolutions

Precision Peak Detector: Simulating an Audio Envelope Follower in LTspice

LTspice schematic of a dual op-amp precision peak detector circuit with feedback diodes and hold capacitor

A peak detector does exactly what it sounds like — it grabs the highest point of a signal and holds onto it. Feed it a messy, jumpy waveform like an audio track, and it hands you back a clean, stepped line tracing every peak. That's the circuit we're building and simulating here, using a real two-op-amp precision peak detector in LTspice, driven by an actual .wav audio file instead of a plain sine wave.

What a Peak Detector Actually Does

A basic diode-and-capacitor peak detector works fine at high signal levels, but it struggles with small voltages because the diode's forward drop eats into the signal before it ever reaches the capacitor. The fix is to put the diode inside an op-amp's feedback loop. The op-amp's open-loop gain forces the diode to conduct with almost no error, so the capacitor charges to the true peak voltage — not the peak minus a diode drop.

Diagram showing an input waveform with rising peaks and the output holding each new peak value

The diagram above is the concept in its simplest form: as Vin rises and falls, Vout only ever moves upward, stepping to match each new peak and holding steady until a taller peak comes along.

Circuit Breakdown

The schematic uses two op-amps, two diodes, and a hold capacitor:

LTspice schematic of the precision peak detector with U1, U2, D1, D2, R1, R2, and C1
  • U1 (comparator stage): Compares the incoming audio (V3, sourced from a .wav file) against the held output voltage.
  • D1 + C1 (10µF): When U1's output swings high, D1 conducts and charges the hold capacitor to the new peak almost instantly.
  • D2 + R1 (10k): This feedback path keeps U1 from railing out and slamming into saturation when the input drops — without it, the circuit would take too long to "wake up" for the next peak, a classic peak detector slew problem.
  • U2 (buffer stage): Isolates the capacitor from R2 (10k) so the load doesn't discharge the stored peak, giving a clean, low-impedance Vout.
  • V1 / V2 (±12V): Supply rails for both op-amps.

Feeding It Real Audio in LTspice

Instead of a sine or triangle wave, this simulation uses a real .wav file as the input source — a good way to stress-test the circuit against a signal with unpredictable, fast-changing peaks, closer to what the circuit would see in a real audio application like a VU meter or compressor sidechain.

LTspice Component Attribute Editor showing the wavefile=test2.wav value entered for a voltage source

To set this up yourself:

  1. Place a standard voltage source in LTspice.
  2. Hold Ctrl and right-click the source symbol to open the Component Attribute Editor.
  3. In the Value field, type wavefile=yourfilename.wav — swap in your actual file name.
  4. Click OK, then run a transient simulation (here, .tran 15 for a 15-second run).

Important: keep the .wav file in the same folder as your .asc schematic file, or LTspice won't find it.

The Result

Run the simulation and overlay Vin against Vout, and the peak-tracking behavior is obvious — the red trace climbs in clean steps, locking onto each new high point in the audio while ignoring everything below it.

LTspice simulation waveform showing the stepped peak-detector output tracking the envelope of an audio waveform

Notice how the output only ever steps upward within this window — that's expected for a positive peak-hold detector with no reset or decay path. In a real audio application you'd typically add a bleed resistor across C1 to let the voltage decay slowly between peaks, turning this into an envelope follower rather than a pure peak-and-hold.

Where This Circuit Is Used

Precision peak detectors like this one show up in audio level meters, AGC (automatic gain control) circuits, envelope followers for synthesizers, and RF signal strength measurement — anywhere you need to capture and hold the highest point of a fast-moving signal without losing accuracy to diode drop errors.

Frequently Asked Questions

A plain diode-capacitor circuit loses accuracy at low signal levels because the diode's forward voltage drop subtracts from the real peak. Putting the diode inside an op-amp feedback loop cancels that error almost entirely, giving a much more precise reading.

D2 stops the first op-amp (U1) from saturating against the negative rail when the input signal drops below the held peak. Without it, U1 would take too long to recover and respond to the next incoming peak.

This is a pure peak-hold circuit — the capacitor only charges up, never discharges, so it holds the highest value seen so far. Adding a bleed resistor across the capacitor would let it decay over time, turning it into an envelope follower instead.

Use a standard voltage source, then Ctrl + right-click it to open the Component Attribute Editor and set the Value field to wavefile=yourfile.wav. Keep the .wav file in the same directory as your schematic file.

Audio level meters, automatic gain control (AGC), synthesizer envelope followers, and RF signal strength detectors all rely on this same core topology.
🤖

GenxiTech Assistant

Online · AI Powered · Always Ready