How to Light an LED by Clapping Your Hands, or How a Peak Detector Works.
First of all, a peak detector is designed to register the maximum or minimum amplitude of a signal. The simplest peak detector can be built from two parts, a diode and a capacitor.

When a signal of arbitrary shape is applied to the input of a peak detector, the capacitor charges as shown in the picture below, so the voltage across the capacitor plates always equals the maximum value of the signal over the elapsed period.

Suppose we need to capture the maximum amplitude of the signal over certain time intervals, for example once per second. To do this, a resistor must be connected in parallel with the capacitor; now, after each peak, the capacitor will discharge through the resistor at a certain rate. The capacitor's discharge rate is determined by the resistor value, which is calculated using the following formula.

All would be well, but there's a nuance we haven't taken into account: the voltage drop across the diode. The voltage across the capacitor plates will always differ from the signal's peak voltage by the diode's voltage drop, as you can see in the oscillogram below. Channel one is the input voltage, channel two is the capacitor voltage.

The circuit shown below will help us fix this.

To understand how it works, we need to recall the following:

The oscillogram shows that the peak values match, after which the capacitor discharges through the resistor. We've dealt with the theory; now let's put this knowledge into practice.

The LED in the circuit will light up when you clap your hands. By changing the value of the resistor in parallel with the capacitor, we adjust how long the LED stays lit.
Now we know how to light an LED by clapping our hands and how a peak detector works.

When a signal of arbitrary shape is applied to the input of a peak detector, the capacitor charges as shown in the picture below, so the voltage across the capacitor plates always equals the maximum value of the signal over the elapsed period.

Suppose we need to capture the maximum amplitude of the signal over certain time intervals, for example once per second. To do this, a resistor must be connected in parallel with the capacitor; now, after each peak, the capacitor will discharge through the resistor at a certain rate. The capacitor's discharge rate is determined by the resistor value, which is calculated using the following formula.

All would be well, but there's a nuance we haven't taken into account: the voltage drop across the diode. The voltage across the capacitor plates will always differ from the signal's peak voltage by the diode's voltage drop, as you can see in the oscillogram below. Channel one is the input voltage, channel two is the capacitor voltage.

The circuit shown below will help us fix this.

To understand how it works, we need to recall the following:
with negative feedback, an op-amp acquires an interesting property. It will always try to adjust its output voltage so that the voltages at its inputs are equal, giving a zero difference.
This is exactly our case: since the capacitor is connected to the inverting input and the input voltages are equal, the capacitor voltage will equal the voltage at the non-inverting input. Let's build the circuit, feed a signal from the generator to the input (channel one) and connect the oscilloscope to the output (channel two).
The oscillogram shows that the peak values match, after which the capacitor discharges through the resistor. We've dealt with the theory; now let's put this knowledge into practice.

The LED in the circuit will light up when you clap your hands. By changing the value of the resistor in parallel with the capacitor, we adjust how long the LED stays lit.
Now we know how to light an LED by clapping our hands and how a peak detector works.