I am trying to make an Auto Gain control circuit.

Having any input source's voltage the same.

For example my latop outputs around 1.36Vrms @ 1khz and my iPhone outputs around 0.962Vrms @ 1khz

Regardless of input source I want the input voltage to be around the same as the laptops.

The idea is convert the input signal into a DC signal to essentially map it out. Compare the DC signal the Vref ~=500mV. The comparator will output from 0V to 1V, depending on that it will turn on the respective transistor. One transistor will be a voltage follower and will not doing anything if (V+ > V-) and if (V- > V+) then it will go to the respective transistor and go through an active op amp with a negative feedback containing a digital pot controlled by an ardunio. Using the negative feedback equation the arduino will calculate a value for the R2 resistor (Digital pot) and make it so the voltage will become 1.32Vrms using the equation R2/R1 + 1.

1 - I am not sure if this will work due to how an audio signal isn't a constant amplitude.

2 - For the full bridge rectifier since the voltage of the iphone out is already so small, I believe the Forward Voltage drop of the diode will ruin the idea of it.

3- Is this even possible?


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Possible but distorted by compression noise. A suitable attack/decay times low pass filter must be selected using an OTA to control gain with a Vref for Vpeal \$\endgroup\$ Commented Jun 22, 2018 at 5:53
  • \$\begingroup\$ Glad is possible, however I am still worried about the full bridge rectifier, if the voltage drop is lets say ~1.4V how would that work out? 0.962V * sqrt(2) = 1.36 -1.4 = -0.04? so I guess zero volts at the output? \$\endgroup\$
    – Leoc
    Commented Jun 22, 2018 at 5:58
  • 1
    \$\begingroup\$ They used to make AGC circuits before there were Arduinos and digital potentiometers. Maybe take a look around and see if you can locate an old circuit. \$\endgroup\$
    – JRE
    Commented Jun 22, 2018 at 6:00
  • 2
    \$\begingroup\$ A bridge rectifier is probably not a good way. What you'd want is more like an "ideal diode" made from a regular diode and an opamp. \$\endgroup\$
    – JRE
    Commented Jun 22, 2018 at 6:01
  • \$\begingroup\$ Ahh like a precision rectifier circuit? Oh I have tried looking for one can't really find any that explains it well sadly. \$\endgroup\$
    – Leoc
    Commented Jun 22, 2018 at 6:03

1 Answer 1


If you want to do this, the right way is to use a log rectifier, and a VCA with a mv/dB response. Parts like SSM2020 have both these (twice in fact, for stereo) on a single chip. (It's obsolete now but you can still find them, or maybe there is a more modern equivalent. The datasheet is well worth studying, it shows a number of excellent gain control applications.)

But you are right to be concerned about dynamics of the music. Any which way, you will lose some of that (depending on the time constants in your circuit). AGC circuits are inherently unsatisfactory in this way (although much modern music has been compressed quite excessively).

For the problem you describe, it would be a simpler and better solution to simply have a "PAD" switch, to slightly attenuate the laptop. You switch in a potential divider with an attenuation of about 0.7 when the laptop is in circuit. I assume both outputs are capable of driving headphones : if so, you could use values of, say, 100R and 200R; the output will see 300R, and the following amplifier will be driven by an impedance of less than 100R, which should be fine.

  • \$\begingroup\$ Are a log rectifier and a precision rectifier the same thing? The SSM2020 looks interesting thanks for the heads up. Oh you're right that's infinity much simpler, but you know I like over complicating things, and having it be automatic is kinda cool... \$\endgroup\$
    – Leoc
    Commented Jun 22, 2018 at 15:26
  • \$\begingroup\$ A log rectifier is similar to a precision rectifier, but the response is log not linear. If you have an interest in dynamics processing, read through and maybe try out some of the sample applications in the 2020 datasheet. \$\endgroup\$
    – danmcb
    Commented Jun 22, 2018 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.