AGC - Automatic Gain Control

Audacity is not able to apply effects in real time while recording, but this plug-in provides an equivalent to AGC (Automatic Gain Control) when applied after recording.
The effect is similar to the AGC found on pocket recorders, camcorders and similar devices.
Note: It does not repair clipped audio. The original recording level still needs to be below 0 dB. What it does is to dynamically bring the recorded level up to 0 dB.

Controls:

AGC Strength: [0 to 100 %. Default 100 %] How much effect is applied. At 0% there is no effect.
Gain reaction speed: [0.5 to 10 seconds. Default 1.5] How quickly the gain reacts to changes in volume level.
Audio source filter: [Options: Music, Voice, Telephone. Default “Music”] Pre-filters the audio to reduce low rumble and high hiss. The “Music” setting is unfiltered (full spectrum).
Squelch threshold level: [-60 to -6 dB. Default -60 dB] Level at which “Squelch” is activated (see notes below).
Squelch attenuation: [-30 to 0 dB Default 0 dB] How much sound below the squelch threshold is attenuated (see notes below).


Difference between this effect and a “Dynamics Compressor”:

  • The default settings are far more “aggressive” than you will find on most “compressor” effects.
  • Rather than pushing down the level of the loud parts, this effect pushes up the level of the quiet parts. Even though a conventional compressor may apply “make up gain”, the overall effect is still not quite the same.
  • Typically a dynamics compressor will mostly affect peaks that are above a fairly high threshold, thus there is a lot more “effect” on loud parts than on quiet parts. This AGC plug-in affects all audio that is above a fairly low threshold, thus there is more “effect” on quiet parts than on loud parts.

Tips:
For evening out the level of multiple people talking, some loudly and some quietly, try a short “Gain reaction speed” of around 0.5 seconds.
For classical music, try a slow “Gain reaction speed”, say around 6 seconds, and turn down to AGC strength (try around 50%).

Notes:
Squelch: “Noise Squelch” is a feature that is commonly found on walkie talkie radios to reduce or mute the noise level when no-one is talking. This plug-in includes two “Squelch” controls.

Squelch threshold level sets the level below which the “squelch” is activated. The default level is -60 dB, which is suitable for a high quality recording. For recordings that have a higher background noise level, best results will be achieved by increasing this control. If it is set too high it will prevent quiet sounds from being automatically amplified.

Squelch attenuation sets how strongly noise below the squelch threshold is muted. The default is 0 dB which does not “mute” audio below the threshold, but just limits how much it is amplified. For a stronger “noise gate” type effect, try moving this slider to the (-30 dB) minimum.

One problem that is inherent with AGC effects is that when the input goes quiet, the background noise level may be drastically boosted. To reduce this unwanted effect, increase the “Squelch” threshold (if necessary). Sound below the squelch threshold will be boosted less than audio above the threshold.

Tip:
If, when applied to a voice recording, some quiet voices are not being amplified, then either the Gain reaction speed is set too slow (try reducing it to 0.5 seconds) or the Squelch level is set too high.


Audio Source Filter
When set to “Music” there is no pre-filtering.

The “Voice” setting will filter out low booms, pops and rumbles, and high hiss before applying the automatic gain effect. This setting is recommended for voice recordings.

The “telephone” setting reduces more low and more high frequencies than the “Voice” filter. On high quality speech recordings it will probably remove too much, making voices sound “thin” and a bit “muffled”. For low quality voice recordings it can help to reduce a lot of unwanted noise. This setting is recommended for telephone and other low quality voice recordings.
agc.ny (2.45 KB)
Latest Version of Automatic Gain Control.
Please read the additional notes in this post: https://forum.audacityteam.org/viewtopic.php?p=337691#p337691

Could something like this be what we need to displace the “Leveller” effect?

I didn’t find the “Squelch attenuation” control made much difference with the material I tried, only the “Squelch threshold”. Would it be less fiddly to not have that attenuation control (just set attenuation quite high) or only have a few choices for it, instead of a slider?



Gale

My one reservation about removing the Leveller effect is that it is the only “Distortion” effect that is shipped with Audacity.

Personally I find the Leveller effect pretty useless for “evening out the volume”, but it can come in useful as a distortion effect, especially as it is the only distortion effect that is included (even if it is only a distortion effect by accident).

As a “volume levelling” effect I think this AGC plug-in does a reasonable job, but it does not provide a “distortion” effect, In fact this plug-in has extremely low harmonic distortion.

With some material the Squelch attenuation can have a huge effect.
You will not tend to notice it much unless the peak signal level stays below the squelch threshold for at least as long as the “Gain Reaction Speed”.

I agree that the Squelch settings are a bit fiddly, but they can make a lot of difference. The problem is that we don’t know how bad the recordings are. For relatively good recordings it is quite easy to set the squelch level and you probably don’t need the squelch attenuation. For really bad recordings they are harder to set, but make a bigger improvement when set correctly.

Here’s a bad recording:

Try AGC with default settings and you will notice that the “background” noise is greatly amplified.

The "background noise peak level is around -20 dB, so set the Squelch to -18 dB (a little above the noise floor).
The background noise is not amplified as much.

Now set the Squelch attenuation to -30 dB.
The background noise is virtually silenced until the gain starts rising for the start of the music.

In this version I’ve attempted to combine both “squelch” functions into one slider.
I’ve assumed that the higher the squelch level, the greater the required muting.
agc.ny (2.48 KB)

This plugin runs uber slow in Audacity 2.0.2. Chriss Capel’s compressor runs at least 10 times faster, and I’m not exagerating. Any idea why?

That’s strange. On my machine this plug-in runs a bit faster than Chriss Capel’s compressor.
What sort of machine are you on?

It has nothing to do with my machine, since I don’t have this problem running similar effects such as compressor, SC4, etc. This plugin is just uber slow.

Well I suppose you could add a distortion control if that’s what is needed…


Gale

Thunderbol1000T was on Windows XP a while ago.



Gale

Thank you for the feedback, but it does not help without some details.

SC4 is a LADSPA plug-in, written in C++
Chris’s Compressor and AGC are Nyquist plug-ins.
Nyquist and C++ are very different.

I’ve just tested a track with both Chris’s Compressor and this AGC plug-in. On my Linux machine, Chris’s Compressor took 19 second (averaged over 3 runs) and this AGC plug-in took 17 seconds averaged over 3 runs.

I presume that you are not running Linux. There could be some platform dependent performance issues.

The processing time for the AGC plug-in depends partly on the settings, particularly the “Gain Reaction Speed”. A faster reaction time time uses a lot more processing.

Why not include a distortion effect?
I doubt that many users would think of looking at an AGC effect if they want distortion. They are far more likely to look for (and not find) a distortion effect.

Not in your new version AGC - Automatic Gain Control - #5 by steve , where at a -30 dB setting the background noise before the music is about the same as at -60 dB (which seems more intuitive given the noise is at -20 dB) ?

Politics. AGC with intentional distortion is better than Leveller with unintended distortion and can’t be called a regression.


Gale

As Nyquist effects are “below the line”, would it not be possible to remove Leveller and squeeze in 2 Nyquist effects below the line?
I think that guitarists in particular would want a distortion effect with a bit more tonal control than just “how much clipping”.
We also get a lot of requests regarding vocal distortion effects (robot voices, monsters, airline pilots…)

It could be due to the amount of RAM being used.
This plug-in loads the entire audio into RAM. If the amount of free RAM gets too low, Windows will start swapping data to the hard drive and the plug-in will be really slow,
How much RAM do you have on your computer? Do you know how much of that is free (unused)? How long was the track that you were processing? Was it a stereo track? What was the track sample rate?

I’ve tested the plug-in on XP and it is a bit slower than some other Nyquist effects (such as Chris’s Compressor) but I did not find that it was unreasonably slow as long as there was enough free RAM.

Gale, yes, I’m still on XP. This plugin shouldn’t be as slow as it is on my machine, because similar plugins such as SC4, Audacity’s built-in compressor, and Chriss Capel’s compressor are much faster. I’m thinking that AGC may require more memory than those other plugins. It runs at least 10 times slower than any of those plugins.

There is probably not much that Gale can do about this. He is not the developer of this plug-in.
As I wrote previously, SC4 is a LADSPA plug-in and LADSPA is a completely different type of code from Nyquist.
AGC requires a lot more memory than Chris’s dynamic compressorr when processing long audio selections because AGC requires that the entire audio track is loaded into RAM.
How much RAM do you have on your computer? Do you know how much of that is free (unused)? How long was the track that you were processing? Was it a stereo track? What was the track sample rate?

The memory would explain everything, since I only have 1GB of RAM. This plugin would work much better on my machine if the entire audio track didn’t have to be loaded into RAM.

That may be possible, but it’s not an easy programming task.
If there is sufficient interest in this effect then I’ll look into that, but I’m not inclined to spend a lot of time on it if there is no interest.