Volumegain: alignment of the volume of stream

The alignment of the audio problem

Listening to different audio tracks often perceive different levels of volume. These constant changes in volume between tracks and the next can be very annoying, can cause us to lose concentration and constringerci constantly changing the volume level manually.
The problem affects all those cases where you need to concatenate audio / video (Simple Media Player, TV, etc ...)

What to do?

We plan to balance the volume level between different sound sources.

The first problem is finding a function that describes the best possible sound pressure level of a sound.
The sound pressure level ( L_p ) Is the logarithmic measure of sound pressure than a reference value: L_p = 10 \ log_ (10) (p/p_0) ^ 2
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 is calculated in this way, given a inzieme X = \ (x_1, x_2, ..., x_n \) the RMS:

X_ (rms) = \ sqrt (\ frac (1) (n) \ sum_ (i = 1) ^ (n) (x_i ^ 2))

While if we calculate on a continuous function f range t_0, t_1 its f_ (rms) will:

f_ (rms) = \ sqrt (\ frac (1) (t_1 - t_0) \ int_ (t_0) ^ (t_1) [f (x)] ^ 2 dx)

Than change the volume?

With RMS, we can calculate the average sound level of an entire stream so ottenedo M_ (s) . Both st the amplification factor and M_ (rms) The average volume dedio we want to output, then:

M_ (rms) \ v backsimeq M_s

v \ backsimeq \ frac (M_ (rms))) (M_s

The amplification factor will be 0 to 1 to reduce the volume 1 to leave unchanged and greater than 1 to amplify it.

Conclusions

If we have more audio streams with different levels of volume we can align them by bringing them all to the same medium volume. To do what we must first analyze each input stream, calculate its M_s From this derive the amplification factor st and apply it to the track.

I wrote a small program in Python that does the job. It consists of a library that deals with all the changes in sound volume and a small executable to perform the tests with audio files.

Examples

Let the output of a few.

 $. / 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
     R-n - 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>

 $. / Audio-v testgain \ example/1.ogg
 Audio files: 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 channel RMS Mean: 0.213781670882 Pa

 $. / Audio testgain \ example / [1-3]. Ogg-r 00:12
 Audio files: Audio example/1.ogg
 All channel RMS Mean: 0.213781662184 Pa

 Audio files: Audio example/2.ogg
 All channel RMS Mean: 0.0407199536201 Pa

 Audio files: Audio example/3.ogg
 All channel RMS Mean: 0.206117526775 Pa

 -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
 Changing volume.  File: Audio example/1.ogg
 All channel RMS Mean: 0.119991210077 Pa

 -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
 Changing volume.  File: Audio example/2.ogg
 All channel RMS Mean: 0.119997166635 Pa

 -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
 Changing volume.  File: Audio example/3.ogg
 All channel RMS Mean: 0.119992128875 Pa

Downloads

If you want more information download the presentation in PDF (in English) here:

Download presentation here volumegain

Download presentation volumegain

File size: 297.39 kB

If you program including libraries, and examples testgain download this archive:

4 Responses to "Volumegain: alignment of the volume of stream

  1. LEGGIO JOSEPH - November 18th, 2009

    Let me know if there is no standard for what 'regards
    RMS sound pressure applied to different kinds of music, or if everything 'at the discretion of the engineer?
    (Example: Electro Rock -15 dB RMS. DISC -10 dB RMS etc. ... etc.)
    Thank you for your attention.
    JOSEPH.

  2. Feather - November 19th, 2009

    There is no standard that binds the RMS sound pressure with the genre.

  3. LEGGIO JOSEPH - November 23rd, 2009

    I downloaded Volumegain-0.2, extension TGZ.
    The operating system and use 'Windows XP, the system
    do not know 'with that application open the file.
    Please would you give me some tips to use
    the library.
    Thank you very much.
    JOSEPH.

  4. Feather - November 26th, 2009

    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 simple. You'll need to first install Python (http://www.python.org/), then the GStreamer libraries (http://gstreamer.freedesktop.org/) that are not well supported for Windows and also require pygtk lib.
    I suggest you change the operating system and switch to Linux or any Unix-like.

Leave a Reply