You are not logged in.

#1 2011-09-02 00:33:31

olga
Member
Registered: 2008-10-20
Posts: 10

How to normalize the loudness of an entire music library?

I have a ~15 GB music collection comprised of MP3, FLAC and M4A files.

Is there a program that could run through an entire directory tree and normalize the loudness of all the audio files it finds to the same level?

ReplayGain is perfect for this, as I understand it, but I'm still not sure how to go about accomplishing this task. :newbie:

Thanks!

Offline

#2 2011-09-02 00:50:09

olga
Member
Registered: 2008-10-20
Posts: 10

Re: How to normalize the loudness of an entire music library?

I guess I should've googled a bit more first. smile

This is what I will do:

0) Backup everything.
1) Since I don't care much about the other formats, I'll first convert them into MP3 via mp3ify (found on archwiki and AUR).
2) Then I'll run "mp3gain -r" on the entire directory tree, normalizing everything to the same loudness.

I sure hope that works.

Last edited by olga (2011-09-02 00:50:54)

Offline

#3 2011-09-02 03:26:00

olga
Member
Registered: 2008-10-20
Posts: 10

Re: How to normalize the loudness of an entire music library?

Okay, I did. Just in case anyone else stumbles upon here with the same question:

Assuming your music is located at ~/music, do the following:

0) Backup everything: cp -R ~/music ~/music.backup
1) Convert everything to MP3: mp3ify ~/music ~/music
2) Add ReplayGain data to every MP3:  find ~/music -name "*.mp3" -exec mp3gain -r -c -s r '{}' +
3) Delete the FLAC, M4A and other converted files: find ~/music -name "*.flac" -delete

Make sure you play your music with a ReplayGain-aware media player, such as Clementine.

Last edited by olga (2011-09-02 03:31:17)

Offline

#4 2011-09-02 08:44:28

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: How to normalize the loudness of an entire music library?

You don't need a backup. The normalisation info is stored in the MP3 tags by mp3gain afaik, so you can revert it anytime you want.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#5 2011-09-02 08:52:05

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: How to normalize the loudness of an entire music library?

Do you only want track gain or do you also want album gain? I just want to say, that e.g. with olga's 2) you won't get an album gain analysis.

Offline

#6 2011-09-02 13:04:26

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: How to normalize the loudness of an entire music library?

Army wrote:

Do you only want track gain or do you also want album gain? I just want to say, that e.g. with olga's 2) you won't get an album gain analysis.

Very much depends how you listen to your music - and is very much a personal preference.

If you tend to create random playlist from numerous albums - you might do better with "per track"
If you have a more traditional listening habit and listen to complete albums in their linear form - you might prefer "per album"

15GB !!! You ain't even scratched the surface... 500GB and counting + a few 100 DVD backups big_smile

Replaygain is purely a file "tag" that indiciates the required amplification to bring a track up (or down) to the norm - it may not be read by your portable player so might be a complete waste of time sad if that is your primary listening method.

The alternative is to copy all the files you want on you portable device to a temporary folder and apply a "hard normalisation" with soundconverter and the like - this does change the file and cannot be removed so only do it on copies of your files. Using your original source files is a very bad idea as it will "mutilate" the original dynamics wink

You can always remove the replaygain tag with puddletag or other mp3 tag editors wink

Last edited by satanselbow (2011-09-02 13:06:23)

Offline

#7 2011-09-02 13:34:04

olga
Member
Registered: 2008-10-20
Posts: 10

Re: How to normalize the loudness of an entire music library?

Army wrote:

Do you only want track gain or do you also want album gain? I just want to say, that e.g. with olga's 2) you won't get an album gain analysis.

I always listen to a randomly populated list of tracks from the entire library, so applying replaygain per album isn't really worth it for me. To get album gain analysis, replace "mp3gain -r" with "mp3gain -a" in 2).

satanselbow wrote:

15GB !!! You ain't even scratched the surface... 500GB and counting + a few 100 DVD backups big_smile

I tend to only keep particular songs I grow attached to. Growing fond to more than 500 GB of music would be impossible to me. smile So, there's only about 2300 songs in my library so far, and this is after years of slowly collecting them.

Last edited by olga (2011-09-02 13:35:49)

Offline

#8 2011-09-02 15:12:04

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: How to normalize the loudness of an entire music library?

mp3gain sucks majorly... use this script instead of calling mp3gain directly:

it makes sure that replaygain is PROPERLY added into the id3v2 field instead of a) modifying the actual audio data or b) using the crappy apev2 tags.
Script needs eyed3 from aur.

#!/bin/sh

LC_NUMERIC=POSIX; export LC_NUMERIC

MP3GAIN=`which mp3gain`
if [[ $? != 0 ]]; then
    echo "mp3gain executable not found." >&2
    exit 1
fi

EYED3=`which eyeD3`
if [[ $? != 0 ]]; then
    echo "eyeD3 executable not found." >&2
    exit 1
fi

if [[ $# > 1 || $# == 1 && $1 != "-f" ]] ; then
    echo "Usage: `basename $0` [-f]" >&2
    echo " for ReplayGain'ing all mp3 file into current directory" >&2
    echo " -f -- force re-ReplayGain'ing for already ReplayGain'ed files" >&2
    exit 2
fi

if [[ $# == 0 ]]; then
    $EYED3 --no-color *.mp3 \
    | egrep -i '^UserTextFrame: \[Description: replaygain_album_gain\]$' >/dev/null 2>&1
    if [[ $? == 0 ]]; then
        echo "Files already ReplayGain'ed." >&2
        exit 1
    fi
fi

$MP3GAIN *.mp3

TMPFILE=`mktemp`

for n in *.mp3; do
    $MP3GAIN -s c "$n" > $TMPFILE
    $MP3GAIN -s d "$n"
    TRACK_GAIN=`awk '/^Recommended "Track" dB / { printf("%+.2f dB", $5)   }' $TMPFILE`
    ALBUM_GAIN=`awk '/^Recommended "Album" dB / { printf("%+.2f dB", $5)   }' $TMPFILE`
    TRACK_PEAK=`awk '/^Max PCM /                { printf("%.6f", $7/32768) }' $TMPFILE`
    ALBUM_PEAK=`awk '/^Max Album PCM /          { printf("%.6f", $8/32768) }' $TMPFILE`
    $EYED3 \
        --set-user-text-frame="replaygain_track_gain:$TRACK_GAIN" \
        --set-user-text-frame="replaygain_track_peak:$TRACK_PEAK" \
        --set-user-text-frame="replaygain_album_gain:$ALBUM_GAIN" \
        --set-user-text-frame="replaygain_album_peak:$ALBUM_PEAK" \
        "$n"
done

rm -f $TMPFILE

using this method the actual audio file is NOT changed at all, you can safely use this method on your original files. all this does is creating a few tags.
for ogg you can use vorbisgain and for flac use metaflac.


The easiest way to do it would be wine+foobar2000 -> load all your files in a huge playlist -> rightclick -> replaygain -> album gain by tag.

Last edited by Rasi (2011-09-02 15:14:17)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#9 2011-09-02 17:22:07

karoshi
Member
From: Marburg
Registered: 2008-02-26
Posts: 182

Re: How to normalize the loudness of an entire music library?

I have all my music in folder "Music" (mp3, m4a and flac), every album is a subfolder of "Music", for normalization i use:

MP3s

find /home/$USER/Music/ -type d | while read FOLDER; do cd "$FOLDER" && mp3gain -a -k *.mp3; done

M4As

find /home/$USER/Music/ -type d | while read FOLDER; do cd "$FOLDER" && aacgain -a -k *.m4a; done

FLACs

find /home/$USER/Music/ -type d | while read FOLDER; do cd "$FOLDER" && metaflac --add-replay-gain *.flac; done

Works for me smile


It's a bug planet!

Offline

#10 2011-09-02 18:17:26

igndenok
Member
From: Sidoarjo, Indonesia
Registered: 2010-06-07
Posts: 160

Re: How to normalize the loudness of an entire music library?

My music library dominated by FLAC and Wavpack. karoshi already made nice command for FLAC replaygain,
and for Wavpack just a little bit change from karoshi command

find /home/$USER/Music/ -type d | while read FOLDER; do cd "$FOLDER" && wvgain -a *.wv; done

As for MP3, I always convert from my lossless for my portable player using this command

lame -V 6 --noreplaygain --nogap --nogaptags track01.wav track02.wav ... trackN.wav

To produce gapless (because I always convert an album) with no replaygain.
If you want lame calculate replaygain use

--replaygain-fast (default) or --replaygain-accurate

So there's no need mp3gain.


Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.

Offline

#11 2011-09-02 22:28:58

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: How to normalize the loudness of an entire music library?

igndenok wrote:
--replaygain-fast (default) or --replaygain-accurate

So there's no need mp3gain.

This will only create trackgain values. And I dont know if players handle it at all. I guess most dont use this at all, since this option is enabled as default in lame, but my mpd definately does not use it.

Last edited by Rasi (2011-09-03 07:14:00)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#12 2011-09-03 02:54:48

igndenok
Member
From: Sidoarjo, Indonesia
Registered: 2010-06-07
Posts: 160

Re: How to normalize the loudness of an entire music library?

Yeah, it's only produce 'RadioGain'. If you playing mixed track (not per album) maybe it's worth using 'RadioGain'.
As for capability with player, I really don't know about that.
Some replaygain application save replaygain data in MP3 tag (e.g.: fb2k) and some apply directly into 'inside' MP3.


Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.

Offline

Board footer

Powered by FluxBB