PDA

View Full Version : replaygain = mp3gain??



SlimPvC
2005-10-19, 12:26
For my collection I have used MP3gain to tag information about output level. I was under the impression (and experienced) that this was a way to 'level' the files that came from different sources.
Now, there's Replaygain support, which basically does the same. But from where does it get the info? I have not understood the difference between MP3Gain and Replaygain, if any. (though Mp3gain is a preparation, and replaygain is a correction during replay?)
If using Mp3gain to correct the files to a certain level, does that make Replaygain unnecessary? Do the methods influence each other? I really hope someone can explain this and tell me the best method to 'level' different files.

Thanks
Peter

oreillymj
2005-10-19, 14:53
Peter,

ReplayGain is a method of normalising ('levelling') the perceived volume across files in a collection of MP3's/Flac files etc without actually changing the music data itself.

The normalisation is done by analysing the file and writing a volume adjustement level into the comment tags of the files. The files will then all play at the same volume when re-played by a device that reads, understands the tags and applies the volume change so all files play back at the same volume.


MP3Gain is just an app that does the file analysis and writes the comment to the MP3 file. It usually normalises everything to 89Db.

If you look at the song info in the Web UI of Slimserver you see the volume adjustement info stored in the file. e.g.

Title: One More Robot/Sympathy 3000-21
Artist: Flaming Lips
Album: Yoshimi Battles The Pink Robots
Genre: Rock
Track: 2
File Format: MP3
Duration: 4:59
Year: 2002
Volume Adjustment: 0.40 dB

.. this song needs a boost of .40Db whereas ...

Title: Big Snake
Artist: Lloyd Cole & The Commotions
Album: Mainstream
Genre: Unknown
Track: 8
File Format: MP3
Duration: 5:16
Year: 1987
Volume Adjustment: -0.02 dB

.. this song needs the volume lowered.

The actual song data wasn't altered by MP3Gain, but the Squeezebox is performing the normalisation on-the-fly during playback based on the values in the comment field.



Mick

jth
2005-10-19, 14:58
mp3gain can also apply the gain directly to the files so that the
playback device does not have to understand the replaygain
standard. If you've chosen this method you probably would want to
turn off replaygain for mp3 files in slimserver so you don't get
the volume adjustment performed twice.

oreillymj
2005-10-19, 15:05
oh yeah, I forgot about that. You can have MP3gain apply normalisation to the file and this does alter/degrade each file as it decodes, normalises & re-encodes each file

MP3Gain still writes the gain values into the comments fields, as an Undo option, but I don't recommend altering the files this way.

I'm not sure if Mp3Gain writes the comments with the same name in this case, but if it does, then any device which understands the tag would apply a volume adjustment to an already normalised file making things worse.

cliveb
2005-10-20, 03:09
I don't think anyone has yet actually described the technical difference between MP3Gain and ReplayGain, so I'll try and give the details...

As I'm sure you all know, an MP3 file is a sequence of "frames". As well as the audio data, each frame also contains a header, and one attribute in the header tells the replay device at what level to output the frame. MP3Gain updates this attribute in the header of every frame in the file, in order to adjust the playback level up or down. Note that the actual audio is not updated, just the instruction as to what level it should be. Therefore it's a lossless adjustment. Recent versions of MP3Gain also add a comment in the file's metadata to indicate by what amount it has adjusted the level, so that it can be undone.

In contrast, ReplayGain does not alter the headers in the individual frames, but simply writes some tags in the file's metadata to indicate what amount of playback level adjustment should be made.

As it happens, the same algorithm is used by ReplayGain and MP3Gain to calculate what the appropriate level change should be.

The advantage of MP3Gain is that since the actual frame headers are changed, the loudness equalisation effect works on ALL replay devices. The disadvantage is that only one level change can be applied (ie. you can ask for track gain, or album gain, but not both).

On the other hand, ReplayGain can add multiple tags, to allow for different level changes for different playback scenarios (ie. it can add tags for both track gain and album gain). But the disadvantage is that the replay device needs to understand the ReplayGain tags in order to apply the level change.

If you MP3Gain *and* ReplayGain a file, and then play it back through a device that understands ReplayGain tags, then the playback level adjustment will be applied twice.

Marc Sherman
2005-10-20, 08:22
cliveb wrote:
> I don't think anyone has yet actually described the technical difference
> between MP3Gain and ReplayGain, so I'll try and give the details...
>
> As I'm sure you all know, an MP3 file is a sequence of "frames". As
> well as the audio data, each frame also contains a header, and one
> attribute in the header tells the replay device at what level to output
> the frame. MP3Gain updates this attribute in the header of every frame
> in the file, in order to adjust the playback level up or down. Note
> that the actual audio is not updated, just the instruction as to what
> level it should be. Therefore it's a lossless adjustment. Recent
> versions of MP3Gain also add a comment in the file's metadata to
> indicate by what amount it has adjusted the level, so that it can be
> undone.

Note that there is a subtle edge case where the MP3gain method is not,
in fact, lossless: if the frame was originally recorded with an extreme
gain value (either very close to to 0 or very close to 255), and the
calculated adjustment for the song would push the value outside the
0:255 range, then mp3gain will clip the value to 0 or 255, and is thus
lossy. The mp3gain app will warn in this case.

Practically speaking, this never happens -- at least with mp3s created
with LAME, the original gain on the frame is well away from the extremes.

For more info, see `mp3gain -? wrap` .

The (huge) benefit of the mp3gain method is that you don't need a player
that understands non-standard tags to play back at the right level --
the frame gain value that mp3gain adjusts is part of the original mp3
spec, and any mp3 player (software or hardware) will respect it.

- Marc

jth
2005-10-20, 10:40
It is probably a better idea to call the process implemented by
mp3gain 'reversible' rather than 'lossless' to avoid confusion.

GoCubs
2005-10-20, 10:55
Peter,
If you look at the song info in the Web UI of Slimserver you see the volume adjustement info stored in the file. e.g.

Title: One More Robot/Sympathy 3000-21
Artist: Flaming Lips
Album: Yoshimi Battles The Pink Robots
Genre: Rock
Track: 2
File Format: MP3
Duration: 4:59
Year: 2002
Volume Adjustment: 0.40 dB

.. this song needs a boost of .40Db whereas ...

Title: Big Snake
Artist: Lloyd Cole & The Commotions
Album: Mainstream
Genre: Unknown
Track: 8
File Format: MP3
Duration: 5:16
Year: 1987
Volume Adjustment: -0.02 dB

OK. Now I'm confused. I had Foobar2000 go through all my MP3's and add replaygain tags. The gain information is visible via Foobar2000 and MP3tag 2.33a (so it's there).

However, when I look at what SlimServer is reading for the tag information (via web interface), it's all zero's. What gives?

I'm running the latest beta of 6.2 and I've done some complete DB rescans. In listening it didn't seem like replay gain was making any difference, and as it turns out, looks like SlimServer isn't picking up the data. Any ideas?

-Greg

SlimPvC
2005-10-20, 10:56
Thanks all for your exhaustive answers!
This thread was very clarifying to me. I doubt that I would have found out myself that it's better to disable replayGain if already using Mp3Gain.

Bye
Peter

Howard Darwen
2005-10-26, 10:47
I didn't see a response to this, but there have been a lot of slim mails in
the last few days :)

Anyway, i used exactly the same tools (foo & mp3 tag) and get exacly the
same behaviour - all zeros in the volume adgustments fields in the web
interface. This is for MP3 files at least. All my flacs (tagged using the
same tools), show replay gain OK. Any resolution that I have missed ... or
do I file a bug?

Thx.

H.

-----Original Message-----
From: discuss-bounces (AT) lists (DOT) slimdevices.com
[mailto:discuss-bounces (AT) lists (DOT) slimdevices.com]On Behalf Of GoCubs
Sent: 20 October 2005 18:55
To: discuss (AT) lists (DOT) slimdevices.com
Subject: [slim] Re: replaygain = mp3gain??



OK. Now I'm confused. I had Foobar2000 go through all my MP3's and
add replaygain tags. The gain information is visible via Foobar2000
and MP3tag 2.33a (so it's there).

However, when I look at what SlimServer is reading for the tag
information (via web interface), it's all zero's. What gives?

I'm running the latest beta of 6.2 and I've done some complete DB
rescans. In listening it didn't seem like replay gain was making any
difference, and as it turns out, looks like SlimServer isn't picking up
the data. Any ideas?

-Greg


--
GoCubs

GoCubs
2005-10-26, 11:09
Anyway, i used exactly the same tools (foo & mp3 tag) and get exacly the
same behaviour - all zeros in the volume adgustments fields in the web
interface. This is for MP3 files at least. All my flacs (tagged using the
same tools), show replay gain OK. Any resolution that I have missed ... or
do I file a bug?

This thread also seemed to touch on the problem:
http://forums.slimdevices.com/showthread.php?t=17342&page=1&pp=10
But likewise, no solution or confirmation of a bug has been said.

-Greg

hdarwen
2005-10-26, 12:02
OK ... so i submitted one ...

http://bugs.slimdevices.com/show_bug.cgi?id=2381

Thx.

h.

-----Original Message-----
From: discuss-bounces (AT) lists (DOT) slimdevices.com
[mailto:discuss-bounces (AT) lists (DOT) slimdevices.com]On Behalf Of GoCubs
Sent: 26 October 2005 19:10
To: discuss (AT) lists (DOT) slimdevices.com
Subject: [slim] Re: replaygain = mp3gain??



Howard Darwen Wrote:
> Anyway, i used exactly the same tools (foo & mp3 tag) and get exacly
> the
> same behaviour - all zeros in the volume adgustments fields in the web
> interface. This is for MP3 files at least. All my flacs (tagged using
> the
> same tools), show replay gain OK. Any resolution that I have missed ...
> or
> do I file a bug?
>
This thread also seemed to touch on the problem:
http://forums.slimdevices.com/showthread.php?t=17342&page=1&pp=10
But likewise, no solution or confirmation of a bug has been said.

-Greg


--
GoCubs

kyleki
2005-11-28, 01:48
This thread has been dormant for a little while now, so I hope there's still someone listening. After reading through it I now understand what mp3gain does to mp3 files, and what ReplayGain is. But what software can I use to apply ReplayGain tags without changing the volume at every frame? I'm not interested in mp3gain because:

1) I don't want to choose between Track & Album normalization.
2) I like the ability to play the files back 'as-is' by simply turning off "ReplayGain" on my Squeezebox.

My only problem is figuring out how to apply the "normalization" via just the ReplayGain tag in the file header.

I see a lot of references to Foobar2000, but I'm running Linux and I'm not a big fan of Wine. Any good Linux programs out there that can handle this (simple) task?

Thanks,
Kyle

Dr Lovegrove
2005-11-28, 04:19
On 28/11/05, kyleki <kyleki.1z789b (AT) no-mx (DOT) forums.slimdevices.com> wrote:
>
> 1) I don't want to choose between Track & Album normalization.
> 2) I like the ability to play the files back 'as-is' by simply turning
> off "ReplayGain" on my Squeezebox.

MP3Gain should do what you want.. If you use the MP3GainGUI app in
windows, and use the 'Album Analysis' button rather than 'Track Gain',
it analyses the files and just writes the replaygain tag info into the files
without touching the audio streams. It'll write both track and album gain
values to the files. You can then choose to use them or not in
SlimServer..

HTH,

--
- Dr Lovegrove
http://www.rusticrhino.com/drlovegrove

kyleki
2005-11-28, 10:40
Hi Dr. Lovegrove,


MP3Gain should do what you want.. If you use the MP3GainGUI app in
windows, and use the 'Album Analysis' button rather than 'Track Gain',
it analyses the files and just writes the replaygain tag info into the files
without touching the audio streams. It'll write both track and album gain
values to the files. You can then choose to use them or not in
SlimServer..

Thank you very much for your reply. As I mentioned in my post, I'm not using Windows; I'm using Linux. Do you know if the '-a' parameter to the mp3gain command-line does what you're talking about? My understanding is that you can only choose one of Track Gain or Album Gain, but not both when using mp3gain. Is this not true? I'm so confused...

Thanks,
Kyle

jth
2005-11-28, 11:05
If you run the command-line version of mp3gain without any
switches (mp3gain album-track-01.mp3 album-track-02.mp3 ...)
it should add the tags but not adjust the gain itself.

You'll need to run it once for every album you have. That
shouldn't be difficult to script if you have one album per
directory.

Of course, test it out before running it against your entire
collection.

kyleki
2005-11-28, 16:48
If you run the command-line version of mp3gain without any
switches (mp3gain album-track-01.mp3 album-track-02.mp3 ...)
it should add the tags but not adjust the gain itself.

You'll need to run it once for every album you have. That
shouldn't be difficult to script if you have one album per
directory.

Of course, test it out before running it against your entire
collection.

Thank you very much! I'll copy a couple of my albums into a separate directory and start playing with this command then.

Do you know if it's possible to have both Track and Album gain tags in a single file? For example, sometimes I like to randomly listen to my music and other times I like to listen to single albums. Depending on how I'm listening to my music that day, I'd like the "Smart" gain feature of the Slimserver to use the right tag, assuming they're both assigned. Is this possible?

jth
2005-11-28, 16:59
Do you know if it's possible to have both Track and Album gain tags in a single file?

Actually the default behavior of mp3gain as I mentioned should
do exactly what you want. It will calculate and add tages for
both track and album gain. You can verify this by using a command
like "strings mysong.mp3 | tail -20" to peek at the ape tags
added to the end of the mp3 file.

kyleki
2005-11-29, 11:01
Actually the default behavior of mp3gain as I mentioned should
do exactly what you want. It will calculate and add tages for
both track and album gain. You can verify this by using a command
like "strings mysong.mp3 | tail -20" to peek at the ape tags
added to the end of the mp3 file.

Cool! I've gone and done my whole 9000 song library using the following script. Thank you very much for your help!:


#!/usr/bin/perl
#

$FindCmd = "find /data/music/mp3/ -mindepth 1 -type d -print";

$i = 0;
open( FINDCMD, "$FindCmd |" ) or die "Can't execute $FindCmd: $!\n";
while( <FINDCMD> )
{
chomp( $line = $_ );

# Take care of escaping special characters in file name
$line =~ s/\(/\\\(/g;
$line =~ s/\)/\\\)/g;
$line =~ s/\!/\\\!/g;
$line =~ s/\?/\\\?/g;
$line =~ s/ /\\ /g;
$line =~ s/\[/\\\[/g;
$line =~ s/\]/\\\]/g;
$line =~ s/'/\\'/g;
$line =~ s/"/\\"/g;
$line =~ s/\&/\\\&/g;
print "DEBUG: $i: $line\n";


$Mp3GainCmd = "mp3gain -k ${line}/*.mp3";
open( MP3GAINCMD, "$Mp3GainCmd |" ) or die "Can't execute $Mp3GainCmd: $!\n";
while( <MP3GAINCMD> )
{
print "$_";
}
close( MP3GAINCMD );

print "\n\n";
$i++;
}
close( FINDCMD );