iAVC
(integer Automatic Volume Control)

Overview
Overview
Settings
Algorithm Details
License
Download
Audacity
Author

Overview

Have you ever listened to CDs in your car and had to frequently change the volume control in order to be able to hear the soft sections and not be blown out of the car during the loud sections?  Well then, Automatic Volume Control is for you!

Process your music tracks using iAVC and you can stop fiddling with the volume control.

An easy way to think of what  iAVC does is to imagine you are in your car listening to a fairly new CD.  All of a sudden you notice that the music is getting hard to hear (a little soft) so you reach for the volume control and turn it up a little.  A little later the music is getting too loud so you turn the volume control down.  Well, iAVC changes the volume control for you in a similar manner.  It automatically adjusts the volume for you based on the music that has just played.  iAVC can make soft music louder and loud music softer - and you can control the amount of adjustment.

Just like when you're listening to a new CD, you may get some surprises with iAVC.  For example if the music is very soft and immediately switches to VERY LOUD, you won't be able to reach the volume control fast enough to turn it down without momentarily hearing too loud music.  Similarly, since iAVC adjusts the volume based on music that has just played, it takes it a fraction of a second before it reduces the volume.  The good news is that iAVC can detect volume change and change the volume setting much faster than you can react to changes in volume.

So (making sure you don't violate any copyrights or other intellectual property rights) rip your CDs, adjust each track using iAVC, and burn a new CD with adjusted tracks for use in your car.

You may have to experiment with iAVC's settings in order to obtain the best results for your environment, but you might find the default settings perfectly adequate for you - after all they work for me.

Settings

Note: Some programs that use iAVC may not allow adjustment of some of these window settings. 

There are 3 window sizes that can be set: 

1.  Sample Window Size: Total number of samples kept in a circular buffer. The caller can "delay" retrieving samples this long, although there is probably no reason to make this bigger than the Adjuster Window size. 

2.  Adjuster Window Size: Total number of samples in the moving average that is used to determine the amplification multiplication factor.  This size must be less than the Sample Window Size.

3.  Caller's put/get delay. A non-zero value for this window size allows the adjustment of each sample to be based not only on music just played, but also on some music that is about to be played.  This may help avoid some of the "shock" that occurs when the music quickly goes from very soft to very loud.

 |- oldest sample                                         newest sample -|
 |                                                                       |
 <----------------------- Sample Window --------------------------------->
                             <------------ Adjuster Window -------------->

                                                                         ^
                                       last sample put by PutNextSample -|

                                    ^
                                    |- last sample got by GetNextSample

                                    <-- callers put/get delay "window" -->
There are two other settings that determine how often the volume can be adjusted and when to adjust the volume.  These two adjustments are used to control the number of times the volume is adjusted since too many adjustments can cause distortion.

1.  Samples Before Switch.  Once the volume has been adjusted it will not be adjusted again for at least this many samples, except when clipping may occur.

2.  Percent Change.  The volume will not be adjusted unless the desired multiplier for the current sample average has changed by at least this percentage.

Finally, there is  an array of settings that, for each sample value, specifies the desired adjusted sample value.  For example if an audio sample with an original value of 50 is to be amplified 8 times, then the desired adjusted (new) sample value is 400.  The default values provide high multiplication values for soft samples and a multiplication factor of 1 for loud samples.  The multiplier used for each sample is based on the average of the samples in the Adjuster Window.

Algorithm Details

iAVC provides a "poor man's" dynamic range compression algorithm that was build on heuristics. It's purpose is to perform fast dynamic range compression in real time. Processing time is more important than memory.  Therefore the algorithm uses only integer arithmetic. 

Normal audio "power" is determined by using RMS.  iAVC uses a simple average of the sound samples to estimate the audio power level, which is much faster - especially on embedded processors that do not have native floating point operations.

iAVC uses a percentage of the current multiplication value to determine when to change level.  Since audio volume perception is based on a log10 scale and not a linear scale, using a percentage of the multiplication factor does not always provide volume change points consistent with human volume perception.  The current multiplication value is changed immediately if a sample clips to minimize distortion and unusually loud bursts of sound.  Unfortunately loud bursts that do not clip are not detected.

The algorithms are safe for files with the number of samples <= 2,147,483,647 since 32 bit signed integers are used in some places.

License

Copyright (C) 2002 Vincent A. Busam
15754 Adams Ridge
Los Gatos, CA 95033
email:

The iAVC library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

The iAVC library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

For details on the license see: http://www.gnu.org/licenses/licenses.html#LGPL

Download

Download of the iAVC library will be available soon.  In the meantime contact the author directly at:

See the Audacity section below for downloading a version of Audacity with iAVC.

You can download my main one minute test file as either WAV file (9.7MB!) or MP3 file version (900KB).  Notice the blip at about 10.5 seconds that gets amplified.  During amplification, iAVC amplifies everything, unfortunately even any noise that may be present.  For comparison, here is my main one minute test file after it has been transformed by iAVC (MP3 file, 900KB).

Audacity

 iAVC is being added to the current development branch of Audacity, a free open source fast multi-track audio editor and recorder for Linux, MacOS, and Windows. Supports WAV, AIFF, Ogg, and MP3 formats.  For full information regarding Audacity, see the Audacity home page.

To run my test version of Audacity, you should first download and install the latest Audacity Beta Version (e.g. 1.1.0) , which you can find by clicking here.

Then you can click below to download my unstable development version of Audacity with iAVC that you can run on Windows and Linux.
download Window Version zip file (10/16/02 1.2MB)
download Linux (RedHat 7.2) Version (sorry, not yet available).  
Take the file you download, unzip it, and replace the Audacity executable file you installed above.

Audacity provides access to the following  iAVC settings:

1.  Adjustment Window (see Adjuster Window above)
2.  Adjustment Delay (see Get/Put delay window above)
3.  Minimum Change Window (see Samples Before Switch above)
4.  Minimum Change % (see Percent Change above)
5.  Desired adjuster sample values in grid format

The Sample Window size is set to the Adjuster Window size.

Here is my sample WAV file's ORIGINAL waveform in Audacity.

Here is the default Automatic Volume Control dialog effect in Audacity.

Here is the sample WAV file's waveform AFTER the transformation done by iAVC.

This may not look like much, but remember that audio perception is log10 of the sample values.  There is a very definite difference in the audio level between the before and after WAV files.  It makes a huge difference when I listen to them both on my computer and in my car.  Try for yourself.  I'm sure you will notice the difference.

NOTE:  Audacity has a problem that sometimes puts pops or crackles into the audio file.  To avoid this, right after opening a file in Audacity, "Select All" and then do Effect / Amplify.  In my experiments, this seems to solve the problem.

Author

iAVC was written by Vincent A. Busam.