The alignment problem of audio
Listening to different audio tracks often perceive different levels of volume. These continuous changes in volume between tracks and the next can be very annoying, can cause us to lose focus and constringerci constantly changing the volume level manually.
People in all those cases where you need to concatenate audio / video (Simple Media Player, TV, etc ...)
What to do?
We aim to balance the volume level between different sound sources.
The first problem is to find a function that describes the best possible sound pressure level of a sound.
The sound pressure level (
) Is the logarithmic measure of the sound pressure with respect to a reference value:
The sound pressure is a parameter, expressed in Pa, which represents the change in pressure compared to a condition of peace.
We will use the function Root Mean Square (RMS) to find the sound pressure level of a stream, it is calculated in this way; given a inzieme
The RMS is:
As if we calculate on a continuous function
range
its
will be:
How much change the volume?
With the RMS we can calculate the average sound level of a whole stream so ottenedo
. Both
the amplification factor and
the average value of the volume dedio that we would like in output, then:
The amplification factor will go from
to
to reduce the volume,
to leave it unchanged, and more
to amplify it.
Conclusions
If we have multiple audio streams with different volume levels we can align them bringing them all at the same average volume. To do what we must first analyze each input stream, calculate its
, From that deduce the amplification factor
and apply it to the track.
I wrote a small program in Python that does the job. It consists of a library that takes care of all the transformations of sound volume and a small executable to run the tests with audio files.
Examples
Let's see some examples of the output.
$. / Testgain - help . / Testgain vesion 0.2 Usage:. / Testgain [OPTINS] [MP3/OGG FILE ...] This program is used for testing volumegain library. OPTIONS: -P - play: play the stream <n>-R - rms <n>: set the default and normalized rms apply it to the stream -Q - quiet: quiet mode -V - verbose: more verbose -V - version: print version info and exit -H - help: display this help end exit Report bugs to <danilo.abbasciano@gmail.com>
$. / Testgain audio-v \ example/1.ogg Audio File: Audio example/1.ogg Type: ogg Channel: 0 Mean RMS: 0.198368826507 Pa Mean RMS: -14.0505315166 dB Channel: 1 Mean RMS: 0.229194515258 Pa Mean RMS: -12.7959155894 dB Mean: All Mean channel RMS: 0.213781670882 Pa
$. / Audio testgain \ example / [1-3]. Ogg-r 00:12 Audio File: Audio example/1.ogg All Mean channel RMS: 0.213781662184 Pa Audio File: Audio example/2.ogg All channel RMS Mean: 0.0407199536201 Pa Audio File: Audio example/3.ogg All Mean channel RMS: 0.206117526775 Pa - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ Changing volume. File: Audio example/1.ogg All Mean channel RMS: 0.119991210077 Pa - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ Changing volume. File: Audio example/2.ogg All Mean channel RMS: 0.119997166635 Pa - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ Changing volume. File: Audio example/3.ogg All Mean channel RMS: 0.119992128875 Pa
Downloads
If you want more information download the PDF presentation (in English) here:
[Download file = 'volumegain-Summercamp-presentation.pdf' name = 'volumegain presentation']
If you want to program, including libraries, and examples testgain download this archive:
[Download file = 'volumegain-0.2.tgz' name = 'volumegain-0.2.tgz' version = '0 .2 ']



I would like to know if there is no standard for what 'concerns
RMS sound pressure, applied to different kinds of music, or if the whole thing and 'at the discretion of the engineer?
(Example: Electro Rock -15 db RMS. DISC -10 dB RMS etc. ... etc.)
Thanks for your attention.
JOSEPH.
There is no standard that binds the RMS sound pressure to the genre.
I downloaded Volumegain-0.2, with the extension TGZ.
The operating system you use and 'Windows XP, the system
do not know 'with what application to open the file.
Please would you give me some tips to use
the library.
Thank you so much.
JOSEPH.
TGZ is a compressed archive, you can open it using WinZip or WinRar or any other compression program. Use the library with Windows is not easy. You will need to first install Python ( http://www.python.org/ ), then the Gstreamer libraries ( http://gstreamer.freedesktop.org/ ) that are not well supported Windows and also need pygtk lib.
I suggest you change operating system and switch to Linux or any Unix-like systems.