Welcome Guest ( Log In | Register )

Difference between Mp3gain and Replaygain
post Jul 30 2004, 15:46
Post #1

Group: Members
Posts: 34
Joined: 16-June 04
Member No.: 14715

Replaygain and MP3Gain

I was confused about the differences between Replaygain and MP3Gain, so wrote this note explaining the difference. I hope this is the correct forum, please move it if it would be better somewhere else.

I realise that the FAQ has a section "Replaygain: WaveGain vs. MP3Gain" but that doesn't obviously cover the features I describe below.

I illustrate the difference by describing adjustment of playback volume using MP3Gain and Foobar2000 (a Replaygain-aware MP3 player). I'm assuming the reader is familiar with the priciples behind Replaygain.

------------------------------------------------------------------------- -

An MP3 file is composed of many blocks of audio, one after the other. Each block corresponds to a few milliseconds of music. Each block has a global gain field which tells an MP3 file player how loud to play that block. In addition to these global gain fields, each MP3 file can also have a Replaygain header which applies to the whole file, and which tells a Replaygain-aware MP3 player how loud to play that file.

MP3Gain determines the Replaygain values for the MP3 file. MP3Gain then writes to the global gain header of every block, adjusting them all up or down by the same amount in order to achieve those Replaygain values. MP3Gain also writes a Replaygain header which applies to the whole MP3 file. Since MP3Gain has adjusted the global gain field for each block to give the right volume, the volume adjustments in that Replaygain header will be small. This MP3 file will then play at the right volume in all players, whether or not they are Replaygain-aware.

Foobar2000 doesn't write to the global gain field of individual blocks. It determines and writes only the Replaygain header which applies to the whole MP3 file. The value it writes to the Replaygain header will therefore be different to that written by MP3Gain since each block is left with it's original global gain field setting.

It is potentially easy to screw this up.

For example, let's say we have a file which is VERY LOUD. We use Foobar2000 to adjust the Replaygain header, which of course writes a value which tells a Replaygain-aware player to turn everything down a lot.

Now suppose we use MP3Gain to adjust the playback volume. And suppose that this time MP3Gain is set to IGNORE tags in the file (i.e. "Options" > "Tags" > "Ignore (do not read or write tags)" is checked). It will still adjust the global gain field of each block (and turn them all down), but it will ignore the Replaygain header, i.e. leave it at the setting which Foobar2000 used.

If we then play our MP3 file in a player which is NOT Replaygain-aware, everything will be fine - the MP3 file will play at the right volume because the global gain field for each individual block has been turned down.

BUT what happens if we then play the MP3 file in an Replaygain-aware player? Now the file will be played much too quietly because the global gain field settings for each block have been turned down AND the Replaygain header for the whole MP3 file is still telling the player to turn down the whole file.

The safest solution to all this is to make sure that if you use MP3Gain on your files, it is NOT set to ignore tags in the file. Then it won't matter which you use to adjust the Replaygain (Foobar2000 or MP3Gain, in any order) since either will set the value of Replaygain correctly.

Edit: Correction. Since I wrote the above paragraph I have got to know foobar2000 better.

There are several different types of headers (usually called "tags") which hold information about an MP3 file - two of the most common are ID3 and APE. Most MP3 taggers and CD rippers use ID3 tags to hold artist information. MP3Gain uses APE tags to hold MP3Gain and Replaygain information.

Because foobar2000 ignores ID3 tags if it finds an APE tag, it is better NOT to let MP3Gain add tags to MP3 files if you intend to use foobar2000 as your MP3 player. If you do let MP3Gain write tags, you will find that foobar2000 will not display Artist/Album/Track etc correctly unless that information is also in the APE tag. Since most MP3 taggers use the ID3 tags to store that information, it will almost certainly not be displayed.

You will lose very little by not letting MP3Gain write tags - each individual block of music has had it's global gain header adjusted so it will always play correctly to within 1.5dB (MP3Gain's accuracy). To set MP3Gain to not write tags to the file make sure "Options" > "Tags" > "Ignore (do not read or write tags)" is NOT checked. MP3Gain can also remove tags which it has previously added. If you want the ReplayGain correction to be exact, you can use foobar2000 to adjust the ReplayGain. foobar2000 can be configured to write ReplayGain values to ID3 tags so any previously-stored Artist/Album/Track information is not lost.

The above correction may not apply to players other than foobar2000.

------------------------------------------------------------------------- -

Note that the advantage of using MP3Gain is that the global gain header for each block MUST be supported by all MP3 players, hardware or software. The Replaygain header is not supported by all players.

This post has been edited by Pootle_1: Aug 23 2004, 20:48
Go to the top of the page
+Quote Post
Start new topic
post Feb 13 2008, 17:18
Post #2

Group: Members
Posts: 3353
Joined: 6-July 03
From: Sachsen (DE)
Member No.: 7609

To understand this behaviour, a bit of background information is necessary. You need to be aware of the following:

1. Foobar2000 is NOT designed around the idea of the user manually managing tag-types. It is especially not designed for having different kinds of metadata in different tag-types simultaneusly. The approach which foobar uses is to "abstract" metadata: The user only enters the desired metadata, and foobar automatically cares about how to store it. This way, metadata-manipulation across different filetypes works identical on the user-side and therefore is compatible with each other. No matter if you manipulate metadata about an MP3, or metadata about a FLAC, it is always the same procedure and interface. This however can only work, if there is "metadata integrity" - meaning that all metadata of a given filetype is stored the same way and there are not multiple tags in a single file with conflicting metadata. In short: this approach is only feasible when all files and metadata are "in sync". It does not matter if you agree with this approach or not - it just matters that foobar is designed around this approach... therefore, if you cannot live with it, then foobar is the wrong tool for your needs.

2. Foobar currently does not do any merging of metadata when reading files. In the case of mp3, it only reads from the selected (advanced preferences) tag-type and ignores the rest. As for "why?" - well, i dont know the full story, so a dev-reply would be needed for the full picture. What i know however is, that in the past there was no robust idea on how to merge multiple tagtypes when reading - what i mean is the "ruleset when merging". Part of the problem is that when the same metadata field exists in multiple tagtypes (dupe-info), then how should a machine decide which one is preferable? A machine does not understand what metadata like TRACKTITLE says... its just a bunch of random letters to it.

3. For MP3, foobar supports the following tagging schemes: ID3v2, ID3v1 + ID3v2, APE, ID3v1 + APE. Why is there no APE + ID3v2? Well, because ideally, there is absolutely no point to it. APE is a "replacement" for ID3v2, not an addition. The point of using APE tags is getting rid of ID3v2 and its conflicting standards. If you use ID3v2, then there is no point in APE. HOWEVER, for whatever strange reasons, mp3gain uses exactly this weird and senseless combination of tagtypes. The mess starts here.... continue reading....

4. When foobar changes metadata, then it works the following way: First read metadata according to the above rules. Save it in RAM temporarily. Then modify this read metadata according to the user. Then REPLACE the metadata in the file, with this modified metadata.... therefore dropping all unsupported metadata. Why? Well, read "1." again... the whole point of foobars metadata management is that the metadata in files is in sync without the user having to care about it.

From my POV, what we have here is the combination of two design-flaws..... a flaw in mp3gain, and a flaw in foobar. Just one of the flaws is sufficient, to render the current undo-information of mp3gain useless. The flaw on foobar2000's side is that it has not even the slightest capability of merging tagtypes when READING. What FB2k IMO should do in the current scenario, is reading the APE-metadata of mp3gain, and then delete the APE tag and save the undo-information in ID3v2, therefore not causing any dataloss, but making the undo-data incompatible with mp3gain.

The flaw in mp3gain is using a stupid combination of tagtypes. It should write its undo-information in the already existing tagtype instead - so, usually as ID3v2.

I am arrogant and I can afford it because I deliver.
Go to the top of the page
+Quote Post

Posts in this topic
- Pootle_1   Difference between Mp3gain and Replaygain   Jul 30 2004, 15:46
- - Pio2001   Experts, do you confirm the above ? Can I include ...   Jul 30 2004, 18:52
- - Garf   IIRC it's not a 'global gain header' b...   Jul 30 2004, 18:58
- - singaiya   IIRC, I had problems with mp3gain screwing up my t...   Jul 30 2004, 19:45
|- - Mike Giacomelli   QUOTE (singaiya @ Jul 30 2004, 10:45 AM)IIRC,...   Jul 30 2004, 21:53
- - singaiya   But the thing is, I've never used ID3v2; I...   Jul 30 2004, 22:11
- - Hanky   I can confirm this behaviour when using this proce...   Jul 30 2004, 23:14
- - Raja   I can confirm that using only APE tags will solve ...   Jul 31 2004, 08:27
- - /\/ephaestous   To solve this problem you can: A) Use foobar2000 ...   Jul 31 2004, 08:52
- - Pootle_1   I've edited my original post in response to so...   Aug 2 2004, 10:35
|- - Pootle_1   Added a correction concerning ID3/APE tags after p...   Aug 23 2004, 17:11
- - rfarris   QUOTE (Pootle)Since MP3Gain has adjusted the globa...   Aug 23 2004, 17:50
|- - Pootle_1   QUOTE (rfarris @ Aug 23 2004, 08:50 AM)I assu...   Aug 23 2004, 20:58
|- - rfarris   QUOTE (Pootle_1 @ Aug 23 2004, 12:58 PM)QUOTE...   Aug 24 2004, 19:32
- - dreamliner77   QUOTE (/\/ephaestous @ Jul 31 2004, 03:5...   Aug 24 2004, 04:24
|- - magic75   QUOTE (dreamliner77 @ Aug 23 2004, 07:24 PM)P...   Aug 25 2004, 08:26
- - kwanbis   i still have some doubts ... on mp3gain, to what...   Sep 3 2004, 23:41
|- - Pootle_1   QUOTE (kwanbis @ Sep 6 2004, 08:36 AM)i still...   Sep 7 2004, 09:09
|- - kwanbis   QUOTE (Pootle_1 @ Sep 7 2004, 08:09 AM)QUOTE ...   Sep 7 2004, 17:17
|- - Pootle_1   QUOTE (kwanbis @ Sep 6 2004, 08:36 AM)so, it ...   Sep 10 2004, 14:10
- - kwanbis   UP the question!   Sep 6 2004, 17:36
- - litmitil   I struggled with this issue when I first started u...   Sep 7 2004, 18:41
- - ToS_Maverick   another solution would be if MP3Gain would read/su...   Sep 10 2004, 14:51
- - singaiya   Just wanted to note that the tag issues I referenc...   Jul 31 2005, 17:17
- - Bill02888   I'm just starting to use MP3Gain on my MP3 fil...   Oct 22 2005, 17:07
- - Bill02888   I was being stupid. The log doesn't know that ...   Oct 23 2005, 05:14
|- - Eric S   this entire thread has been VERY interesting. Isn...   Jan 30 2007, 02:54
- - Firon   The files are modified? That's about it, reall...   Jan 30 2007, 05:19
|- - Eric S   QUOTE (Firon @ Jan 29 2007, 22:19) The fi...   Jan 30 2007, 15:20
- - pepoluan   With MP3Gain you must choose between Track RG and ...   Jan 30 2007, 06:45
- - Hollunder   Is there some sort of standard in the meantime? I...   Jan 31 2007, 00:52
- - Eric S   "MP3Gain determines the Replaygain values for...   Feb 25 2007, 20:36
|- - Martin H   QUOTE (Hollunder @ Jan 31 2007, 00:52) Ma...   Feb 27 2007, 13:34
|- - Eric S   Thanks! One thing confuses me: if sounds lik...   Feb 28 2007, 00:21
|- - Martin H   QUOTE (Eric S @ Feb 28 2007, 00:21) if so...   Feb 28 2007, 16:31
- - Northpack   Hello, after diving through all of these topics c...   Feb 12 2008, 13:51
|- - pdq   QUOTE (Northpack @ Feb 12 2008, 08:51) PS...   Feb 12 2008, 15:19
- - Lyx   Here is a - from my understanding - safe procedure...   Feb 12 2008, 16:46
- - Northpack   QUOTE (pdq @ Feb 12 2008, 15:19) If you h...   Feb 12 2008, 18:25
- - Bourne   I have one stupid question.... Turning an MP3 gai...   Feb 12 2008, 18:48
|- - Northpack   QUOTE (Bourne @ Feb 12 2008, 18:48) I hav...   Feb 12 2008, 19:26
- - 2Bdecided   7.5dB or 9dB - mp3gain only works in multiples of ...   Feb 12 2008, 19:20
|- - Northpack   QUOTE (2Bdecided @ Feb 12 2008, 19:20) 7....   Feb 12 2008, 19:45
- - Bourne   David... So, consider two WAV files, one processe...   Feb 12 2008, 19:35
- - Bourne   I just never knew what that was... you put it righ...   Feb 12 2008, 19:49
|- - Lyx   QUOTE (Bourne @ Feb 12 2008, 19:49) I jus...   Feb 12 2008, 20:17
- - Bourne   oh yes it's placebo and the dogma of the enigm...   Feb 12 2008, 20:57
|- - Northpack   QUOTE (Bourne @ Feb 12 2008, 20:57) oh ye...   Feb 12 2008, 21:02
- - Lyx   To understand this behaviour, a bit of background ...   Feb 13 2008, 17:18
|- - Northpack   Lxy: thanks for this very comprohensive response. ...   Feb 13 2008, 19:09
|- - Lyx   QUOTE (Northpack @ Feb 13 2008, 19:09) I ...   Feb 13 2008, 20:05
|- - Northpack   Lyx: ....still growing wiser ... I wonder what th...   Feb 13 2008, 22:49
||- - Lyx   QUOTE (Northpack @ Feb 13 2008, 22:49) Ly...   Feb 13 2008, 23:53
||- - Northpack   QUOTE (Lyx @ Feb 13 2008, 23:53) EDIT: Po...   Feb 14 2008, 02:02
||- - Lyx   QUOTE (Northpack @ Feb 14 2008, 02:02) I ...   Feb 14 2008, 02:52
|||- - Northpack   QUOTE (Lyx @ Feb 14 2008, 02:52) QUOTE (N...   Feb 14 2008, 10:32
|||- - Lyx   QUOTE (Northpack @ Feb 14 2008, 10:32) Bu...   Feb 14 2008, 10:47
|||- - Northpack   QUOTE (Lyx @ Feb 14 2008, 10:47) You...   Feb 14 2008, 11:05
||- - gism   QUOTE (Northpack @ Feb 14 2008, 03:02) I ...   Jul 26 2010, 20:05
|- - 2Bdecided   QUOTE (Lyx @ Feb 13 2008, 19:05) 2. MP3ga...   Feb 18 2008, 17:18
|- - Northpack   QUOTE (2Bdecided @ Feb 18 2008, 17:18) I ...   Feb 18 2008, 19:39
- - Bourne   If you run MP3Gain through your files, they will g...   Feb 13 2008, 18:49
|- - Lyx   QUOTE (Bourne @ Feb 13 2008, 18:49) If yo...   Feb 13 2008, 18:59
- - Bourne   QUOTE Except of that non APE-aware players will: ...   Feb 13 2008, 23:56
- - tycho   FYI: metamp3 does convert APE2 RG tags to ID3 tags...   Feb 14 2008, 11:49
- - Typhoon859   MP3Gain doesn't detect RG information when it...   Aug 1 2012, 13:40
- - greynol   Did you read the entire discussion before you post...   Aug 1 2012, 15:10
|- - Typhoon859   QUOTE (greynol @ Aug 1 2012, 10:10) Did y...   Aug 1 2012, 21:53
|- - kiit   QUOTE (Typhoon859 @ Aug 1 2012, 12:53) .....   Aug 2 2012, 11:03
- - greynol   Seeing this topic was abandoned two years ago and ...   Aug 1 2012, 22:11

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 27th November 2015 - 12:06