No announcement yet.

Volume Leveling and Winamp (Replaygain)

  • Filter
  • Time
  • Show
Clear All
new posts

  • Volume Leveling and Winamp (Replaygain)

    Volume Leveling/ReplayGain
    (Keeping your songs playing at close to the same overall volume)

    PART 1

    Why Volume Leveling is Needed?

    Although music is encoded to a digital format with a clearly defined maximum peak amplitude, and although most recordings are normalized to utilize this peak amplitude, not all recordings sound equally loud. This is because once this peak amplitude is reached, perceived loudness can be further increased through signal-processing techniques such as dynamic range compression and equalization. Therefore, the loudness of a given album has more to do with the year of issue or the whim of the producer than anything else. Volume differences between songs have always existed, but digital mastering has taken this to new heights. Link below to an article on the "Loudness War".

    A random play through a music collection can have significant volume changes with every other track played! Tired of manually adjusting volume while listening to a playlist? There [I]is a solution[I] to this annoyance: within each audio file, information can be stored about what volume change would be required to play each track or album at a standard loudness. Music players, that support it, can use this "replay gain" information to automatically nudge the volume up or down as required.

    To prevent clipping when applying an overall target dB level for the standard loudness, it's best to use a relatively low level than a high one. Analog clipping is a form of waveform distortion that occurs when an amplifier is over-driven and attempts to deliver an output voltage or current beyond its maximum capability. Along with distortion, clipping can damage a speaker's tweeter (the part that plays high frequencies) via overheating. In digital signal processing, clipping occurs when the signal is restricted by the range of a chosen representation for the signal. For example in a system using 16-bit signed integers, 32767 is the largest positive value that can be represented, and if during processing the amplitude of the signal is doubled, sample values of, for instance, 32000 should become 64000, but instead they are truncated to the maximum, 32767. This causes the relative differences in amplitude between different parts of the signal not being what they should be.

    Clipping in the original file or when applying an overall target dB level most often occurs because of the DSP engineering techniques applied to the file.

    What is ReplayGain?

    The ReplayGain specification is a standard which defines an appropriate reference level, explains a way of calculating and representing the ideal replay gain or volume for a given track or album, and provides guidance for players to make the required overall volume adjustment during playback. The standard also specifies a means to prevent clipping when the calculated replay gain exceeds the limits of digital audio and it describes how the replay gain information is stored within audio files.

    The audio industry does not have a standard for playback system calibration, but in the movie industry a calibration standard has been defined by the Society of Motion Picture and Television Engineers (SMPTE). The standard states that a single channel pink noise signal with an RMS level of -20 dB relative to a full-scale sinusoid should be reproduced at 83 dB SPL.

    ReplayGain adapts the SMPTE calibration concept for music playback. Under ReplayGain, audio is played so that its loudness matches the loudness of a pink noise signal with an RMS level of -14 dB relative to a full-scale sinusoid.

    In ReplayGain implementations, the reference level is described in terms of the SMPTE SPL playback level. By the SMPTE definition, the 83 dB SPL reference corresponds to -20FS dB system headroom. The -14 dB headroom used by ReplayGain therefore corresponds to an 89 dB SPL playback level on a SMPTE calibrated system and so is said to be operating with an 89 dB reference level.

    SMPTE cinema calibration calls for a single channel of pink noise reproduced through a single loudspeaker. In music applications, the ideal level of the music is actually the loudness when two speakers are in use. So, ReplayGain is calibrated to two channels of pink noise.

    Your eyes glazing over yet? Had enough of this technical stuff? Yes, move on the Part 2. No, search the WEB for more details. Here's a link to get you started.

    Last edited by Rocker; 19 June 2012, 02:08.
    Winamp v5.9.2.10042 - Quinto Black CT v3.8 skin
    Windows 11 Home 64-bit v22H2 desktop - Logitech Z906 5.1 speaker system

  • #2
    PART 2

    ReplayGain and Winamp

    To apply WA's ReplayGain (RG) to your music files, right-click one or more selected songs in the Media Library or Playlist and select 'Calculate Replay Gain' via the 'Send To' menu. Some Winamp skins (user interfaces) provide additional ways to select a RG calculation. The calculated RG values are stored in special file tags. These tags can only be understood by music players that recognize this particular implementation. The actual audio data is unchanged. The data in these tags is used by WA to control the overall volume as it plays the song. Offically supported file formats are MP3, WMA, WMV, AAC, MP4, M4A, OGG & FLAC. The wavpack format (WV) is also supported if the wavpack decoder (included in the Winamp Essentials Package) is installed.

    The RG calculation determines the peak value detected in each song. The peak value is used along with the track (song) and album adjustment values for a particular target dB level that will control the overall volume without causing clipping. The relatively low overall target dB level used is not published and can not be changed. The final overall volume may be lower than it needs to be, but this 'safe' dB level is easily countered by raising your sound device's master volume control and/or applying the Replay Gain Preamp (explained below).

    Album value calculations seek to maintain any relative volume level differences between songs, as they are on the real album. To use this correctly, only select the songs that are from the same album when you do the RG calculation and be sure the album tag in these files is correct. If a file's album tag is empty, the album value is not calculated but the track value is. The track values are always calculated even if there are no tags in the files.

    Selecting 'Save as Album' when you save the RG calculation results saves both the album and track values. That way you can use either one when you want to. WA dev's recommended preference is to use 'Save as Album'. Selecting 'Save Track data' when you save the RG calculation results only saves the track values. I recommend using this option if you have included songs from different albums in the same RG calculation. You can redo the RG calculations at any time (if you decide to group song selections by album and add their RG album values later).

    WA's use of these RG tags is enabled/disabled via the General Preferences - Playback - Replay Gain options. The other 8 options on this General Preferences page are;

    1) Amplification Mode: Default selection is 'Apply Gain / Prevent Clipping' (recommended by WA devs). This will level out the overall volume and prevent distortion. Three other choices are available: Apply Gain, Prevent Clipping, and Normalize. These are sub-optimal ways to use RG. Applying gain alone may cause clipping. Preventing clipping alone will not level out the overall volume. Normalizing will apply a constant amount of 'correction' to reach the target dB level and may cause clipping. Normal RG uses varying amounts of 'correction' to reach the target dB level.

    2) Preferred Source: Choose between 'Track' (default, all songs play at close to the same level even if they are from the same album) or 'Album' (songs from the same album will maintain their relative volume differences, if any).

    3) Disable if preferred source not available: Disables RG if e.g. 'Album' source is selected but only 'Track' tags are available.

    4) Adjustment for files without RG: Pre-amp selection applied to all files without RG tags (default value is -6.0 dB). -6.0 dB was chosen as an average across a broad range of music and deemed appropriate for the target dB level that WA's RG uses. I recommend changing this to 0 dB and adjusting it as needed when playing songs with RG tags mixed with those without RG tags.

    5) Replay Gain Preamp: Pre-amp selection to adjust the global gain for all files with or without RG tags (default value is 0 dB). This gain is not taken into account by the RG calculations. It may be useful when playing streaming media that is very soft or very loud (you still need to be ready to adjust volume manually). This gain can also be useful if you feel that WA's RG overall volume level is too soft. Use this preamp (and the previous option #4) with care, it could work against what you're trying to accomplish with RG.

    6) Ask before writing Replay Gain to analyzed files: When enabled, the RG calculation results window will appear at the end of the calculation. When disabled, track and album (if applicable) values will be saved automatically without prompting. WA always displays a window that shows the progress of the calculations.

    7) ---Ask after each album is scanned: Prompts to save values after each file is scanned.

    8) ---Ask after all files are scanned: Prompts to save values after all files are scanned.

    Within the media library's CD ripping options is another RG related option, "Automatically calculate Replay Gain". This option enables/disables the automatic calculation and application of RG values to ripped files. This is a hidden process which occurs at the end of each individual track. The default behavior is to apply album and track tags. Note that enabling this option may considerably slow down the overall ripping process.

    Undo (returning songs to their original volume levels) is simple, just disable WA's use of the RG tags. Alternatively, the WA tag editor may be used to delete the RG tags from files that use the vorbis tagging standard (e.g. flac). A 3rd party tagger must be used to delete RG tags from files that use other tagging standards (e.g. id3 in mp3s) and may also be used to delete vorbis RG tags.

    Still using mp3s? Yes, move on the Part 3. No, go apply WA's RG and stop jumping for the volume control.
    Last edited by Rocker; 19 June 2012, 02:09.
    Winamp v5.9.2.10042 - Quinto Black CT v3.8 skin
    Windows 11 Home 64-bit v22H2 desktop - Logitech Z906 5.1 speaker system


    • #3
      PART 3

      A 3rd Party ReplayGain Alternative for MP3s Only!

      "MP3Gain" is a free program that can analyze and adjust mp3 files so that they have the close to the same overall volume. It is a different implementation of the ReplayGain spec. MP3Gain uses David Robinson's Replay Gain algorithm to calculate how loud the file actually sounds to a human's ears. With MP3Gain, the loudness adjustment is done on the data itself, in a lossless/reversible way. The physical volume is adjusted in 1.5 dB steps. There is no quality lost in the change because MP3Gain adjusts each mp3 file directly, without decoding and re-encoding the file.

      Here's the technical reason on why it's lossless (despite operating on the data itself), and also why the smallest change possible is 1.5 dB:

      The MP3 format stores the sound information in small chunks called "frames". Each frame represents a fraction of a second of sound. In each frame there is a "global gain" field. This field holds an 8-bit integer which can represent values from 0 to 255.

      When an MP3 player decodes the sound in each frame, it uses the "global gain" field to multiply the decoded sound samples by 2^(gain/4). If you add 1 to this field in all of the MP3's sound frames, you effectively multiply the amplitude of the whole file by 2^(1/4) = 119 % = +1.5 dB. Likewise, if you subtract 1 from this field in all of the frames, you effectively multiply the amplitude by 2^(-1/4) = 84 % = -1.5 dB, thereby reducing the amplitude of the whole file.

      The way MP3Gain works actually has a very strong benefit. Since it is the "global gain" field data itself that is modified, special support in music players is not required. All music players can play mp3s 'adjusted' by MP3Gain.

      MP3Gain can store 'analysis' and 'undo' information in special tags inside the mp3 file. These tags use the APEv2 format. If you choose not to use these tags or delete them with a 3rd party tagger, then you will not be able to use MP3Gain to automatically undo its changes. You will still be able to undo the changes you make, but you will have to do it manually. MP3Gain can make logs of its analysis, changes, and any errors detected. These logs are text files and may have names and storage locations of your choosing. MP3Gain must be used, along with information from the changes logs, to manually undo the changes made with MP3Gain.

      MP3Gain provides either Track mode or Album mode analysis and respective overall volume adjustment values. Album mode seeks to maintain the any relative volume level differences between songs, as they are on the real album. To use Album mode correctly, only select the songs that are from the same album when you do the analysis. Both modes may be used for analysis even if there are no tags in the mp3 files, but only a track or an album adjustment can be written to a file.

      MP3Gain is very easy to use. Have it load one or more mp3 files or a folder of mp3s and select a track or album mode analysis. As MP3Gain analyzes each file, the results are displayed along with an indication of whether clipping is present in the original file. After all files are analyzed, overall target dB levels (to a tenth of a dB, i.e. xx.x) can then be chosen, before they are applied, to see their effect on clipping. This allows a minimum overall target dB level adjustment to be made when the main goal is to remove clipping in the original file. Of course, the same overall target dB level adjustment (minimum or not) needs to be made to all files when the main goal is overall volume leveling of all files in the group. Additional analysis and adjustments, moving the overall target dB level up or down, can be made at any time.

      Use MP3Gain or WA's RG for your mp3s, while it is possible, I don't recommend using both on the same mp3 files. If you use MP3Gain for your mp3s and WA's RG for your other file formats, be sure to set the "Adjustment for files without RG" option to 0 dB or take whatever it's set to into account when you select the MP3Gain overall target dB level for your mp3s.


      There is another app with a very similar name. "Mp3Gain PRO" does a different form of volume normalization inside the mp3s. If you feel a song is too quiet or too loud at the beginning (or middle, or end), then it can boost or reduce the volume just for that part. Pretty cool, if that's what you need. In order to make its fine-tuned adjustments, it must re-encode the mp3 file and the changes it makes are not undo-able. For these reasons, I do not recommend Mp3Gain PRO for general use and recommend making a backup of the original mp3 file.
      Last edited by Rocker; 19 June 2012, 02:10.
      Winamp v5.9.2.10042 - Quinto Black CT v3.8 skin
      Windows 11 Home 64-bit v22H2 desktop - Logitech Z906 5.1 speaker system


      • #4
        discussion on this topic can be found here