Previous Table of Content Next

Volume Control Dialog

Automatic Gain Control

Automatic Gain Control, if enabled (see Volume Control), tries to find a good setting for the volume fader of the mixer, that comes together with your sound card. Do not confuse "Automatic Gain Control" with the more common "Volume Compression". Volume compression has the aim of squeezing a signal with a large volume range into a limited volume range by reducing the volume of loud parts of the input signal or equivalently amplifying low volume parts. Volume compression will change the gain temporarily for loud parts and will increase the gain as soon as the loud part is over. It inherently alters the signal and therefor has to be applied with great care.

The aim of automatic gain control is much more modest: to find a good setting for the volume fader and then leave it there. You can observe the working of automatic gain control, by watching the fader in the windows mixer application going up and down. The Options menu offers an easy way to open the standard windows (XP or earlier) mixer application.

The algorithm used by m3w to find the best setting is as follows:

  1. For every 1/10 th of a second interval, the peak level of the input signal is measured.

  2. These peak measurements, that you can see interactively in the peak level meters, are put into four categories: noise (dark blue), too low(blue), normal(light blue), or too high(yellow). The volume meter uses different colors to indicate the different regions (see Volume Control).The values that determine these levels can be changed interactively with this dialog. The values are given as a negative dB values, where 0 dB is the maximum possible peak level.

  3. Any single peak value within such a short interval is quite meaningless. Even in a piece of very soft music, there might be an occasional high peak, e.g. the sound of a triangle. Hence, 50 of the peak values (five seconds) are collected and considered together.

  4. If more than 1/5 of the intervals are high level intervals and less then 1/3 of the intervals are low level, the input gain is adjusted downward.If more than 2/3 of the intervals are low level intervals and less than 1/10 of the intervals is high level, the input gain is adjusted upward.

  5. Upward or downward adjustment of the signal volume is done by using the mixer controls that (most) soundcards provide. You can observe the adjustments made, if you open the standard windows sound mixer (from the Options menu) and look at the sliders. The amount of adjustment applied is determined by the setting of the Step level. It is given as a percentage of the maximum level.

  6. Without a special treatment of intervals of noise, any short pause in the signal would cause an immediate upward correction of the input level. This is usually not what you want. It is better to keep the volume control where it is and wait until the pause is over. To achieve this effect, intervals of silence/noise are ignored. They are not collected into the set of intervals that determine the next volume correction.

You can find settings of these values by experimenting with different signal sources and observing the behavior of m3w. Some examples, however, might help.

High=-6dB, Low=-40dB, Noise=-55dB, Step=2%
This is the default setting. There is enough room for normal intervals, and we can hope that after an initial adjustment, the gain will remain stable. At the upper end, there might be parts of the signal that contain many peaks above -6dB of the maximum volume, some of these will even be big enough to exceed the maximum value and cause a cut off of the signal (clipping). Clipping is an audible distortion if it occurs too often. Here, we hope that it isn't too often.
At the lower end, we will increase the gain only so much to get most intervals above the -40dB level. Not very much, but it leaves a lot of headroom to avoid clipping.The noise level of -55dB is quite high, but big enough to keep the gain steady between two tracks of a recording.
The step level of 2% is small, as to make any adjustments slowly and render them inaudible.

High=-3dB, Low=-50dB, Noise=-50dB, Step=15%
The low and the noise level are equal. With this setting there won't be any low intervals. This means that there is never any upward correction of the input gain. Hence you can set your input gain manually and you still have some assurance that the input gain will be swiftly (15%) reduced if the level gets extremely high. You have to adjust the level back yourself once the sound level gets normal again.

High=-10dB, Low=-20dB, Noise=-50dB, Step=4% (not a recommended setting, just an example)
The narrow band of normal intervals will cause permanent adjustment. You have some sort of volume compression, but only after the low or high values have occurred. The step value (4) could be even greater to achieve even faster adjustments, however, the overall delay of at least 5 seconds before any adjustments are made, will remind you that you are using automatic gain control. For these applications you should use the volume compression feature, adjusting the volume before the peaks!

Volume Compression

The volume compression (thanks to Philip Van Baren) is a peak detection, with an instantaneous rise, peak-hold, and then slow decay rate. The peak level is inverted using a power factor between 0 and -1 (depending on the amount of volume compression you want) to get a gain value which brings the peak level up. That gain value is low-pass-filter to smooth the gain transitions. The waveform data is delayed by 3x the time constant of the low pass filter, and then multiplied by the current gain value. This allows the gain to complete the transition smoothly, and be close to the desired gain level before the peak is reached.

It also implements a noise detection, and freezes the peak detector when there is no signal. Optionally you can also have it switch to a low gain while there is no signal present, so you don't amplify the noise floor. The switch between low gain and high gain passes through the same "rise time" low pass filter, so the "rise time" parameter controls how fast the switching occurs.

There are a few parameters, on the volume compression options dialog:

A few possible operating modes:

Various shades between these 3 modes give combined effects. The default settings of 30 ms rise, 10 sec fall, compress 20dB to 3dB, noise attenuation=6dB works well for speech, giving some volume compression along with automatic gain control, and a little bit of noise gating. Volume compression should be combined with automatic gain control, especially in settings, where m3w is used in unsupervised mode to broadcast events.

Summary

Auto gain and volume compression complement each other.

Automatic gain works as early in the signal path as possible, because once the signal is distorted by clipping (signal too high) or quantization noise (signal to low) there is no way of repair. Auto gain works by adjusting the controls of the the soundcards audio mixer. It is working best, if it does nothing, leaving the gain where it is, at a position where the signal level is neither to high nor too low. If, however, the signal is too high or too low, the input gain is adjusted slowly and in small steps (in oder not to be audible). If in doubt, keep the signal level at the low end not at the high end. A small amount of quantization noise is better then permanent clipping.

Volume compression works late in the signal path. It can not prevent clipping that has already occurred in the sound card and can not remove quantization noise that is in the signal. If, however, the loudness of the signal has great variations, within the possible dynamic range, volume compression can make the parts that have a low level louder, by selectively amplifying them. This reduces the overall dynamic range.

A smaller dynamic range is desired, if the listening conditions are not perfect. In a noisy environment, e.g. listening to music in a car, or listening to a speech as part of a larger audience, the soft parts of the signal are covered by the noise during listening. Also a limited dynamic range during transmission, for example over a telephone line, or within a largely compressed bitstream, will benefit from a compressed signal.

The advantage of volume compression in a streaming application like m3w, is the ability to adjust amplification based not only on the current and past signal level, but also on the future signal level. This is achieved, by a small look ahead buffer, where the signal is inspected before being processed. Therefore the amount of amplification can be reduced gradually before the input signal turns loud again.

Here is my recommendation, if for example you do unsupervised broadcasting of live events mainly with speakers (discussions, church services, and so on):

Auto gain will prevent your mixer setting to be completely wrong for an extended period of time, but in regular use, auto gain will just do nothing. Its an insurance against wrong mixer settings. Volume compression will give you a wider dynamic range, that will help the listeners of your broadcast to better understand a speaker with a soft voice by increasing the volume. If you have reoccuring events, experiment with the settings in this dialog to adapt it to your specific situation.