rganalysis

A script for adding replaygain tags to music files

Stars
30

rganalysis.py: Add Replay Gain tags to your whole music library

To use this script, simply run it on your Music library directory. The help text (rganalysis.py --help) contains (almost) all you need to know:

Installation

Then you can install this package from Github using pip:

pip install https://github.com/DarwinAwardWinner/rganalysis/archive/master.zip

Note that rganalysis only works with Python 3. If you want progress bars in the output, you should also install tqdm.

Lastly, you need to install the prerequisites for at least one backend. Right now there are 2 backends available for computing replay gain: one which uses the audiotools Python module, and one which uses the command-line program bs1770gain. You'll need to install either one or the other to use this script. (If you prefer another tool for computing replay gain, feel free to let me know about it, and I will see if I can write a backend for it.)

What is an album?

When doing "album" or "audiophile" Replay Gain tags, one needs to carefully define an album. For example, if you happen to have half an album in FLAC format and the other half in MP3, they might be at different volumes to begin with, so calculating Replay Gain tags on the whole album is a bad thing -- the MP3s will end up too loud and the FLACs too quiet, or vice versa.

Anyway, this script considers two tracks to belong to the same "track set" for the purposes of calculating audiophile gain if:

  • They are in the same directory on the filesystem
  • They are both the same music format (MP3, OGG, FLAC, etc.)
  • They have the same "album" tag (preferring the "albumsort" tag if
    present)
  • They have the same "albumartist" (preferring the "albumartistsort"
    tag if present, and falling back to "artistsort" then "artist" if
    there is no album artist tagged)
  • They have the same "discnumber" tag (or lack thereof)

This means if you have a multi-artist album, you'll need to set the "albumartist" tag to the same value (e.g. "Various Artists") on all songs in the album in order for all the songs to be grouped as a single album. You can still set a different "artist" tag on each song.

See also

Transfercoder, a tool for transferring your music to your portable mp3 player while simultaneously transcoding music formats that the player doesn't recognize.