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:
usage: rganalysis.py [-h] [-f] [-i] [-n] [-g auto]
[music_directories [music_directories ...]]
This program will add replaygain tags to all the music files in the
directories that you specify.
positional arguments:
music_directories
optional arguments:
-h, --help show this help message and exit
-f, --force_reanalyze
Reanalyze all files and recalculate replaygain values,
even if the files already have valid replaygain tags.
Normally, only files without replaygain tags will be
analyzed.
-i, --include_hidden Do not skip hidden files and directories, or otherwise
treat them differently from normal files.
-n, --dry_run Don't modify any files. Only analyze and report gain.
-g auto, --gain_type auto
Can be "album", "track", or "auto". If "track", only
track gain values will be calculated, and album gain
values will be erased. if "album", both track and
album gain values will be calculated. If "auto", then
"album" mode will be used except in directories that
contain a file called "TRACKGAIN" or ".TRACKGAIN". In
these directories, "track" mode will be used. The
default setting is "auto".
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 have the same album name tag
- They have the same disc number tag (or lack thereof)
- They are in the same directory on the filesystem
- They are both the same music format (MP3, OGG, FLAC, etc.)
I may add "same album artist" to this list in the future