View Single Post
  #3  
Old 2005-12-02, 11:47 AM
DoIFeelLucky's Avatar
DoIFeelLucky DoIFeelLucky is offline
 
Join Date: Mar 2005
Location: Toronto
Re: How to detect Replaygain tag?

foobar2000 allows you to scan files for ReplayGain (album- or track-based), allows you to edit ReplayGain gain and peak values manually (although that's not usually a good idea, especially if you're increasing the values, as it can lead to clipping), and lets you remove all ReplayGain info from files.

Now I just did a test, encoding the same file from WAV to FLAC, using FLAC Frontent 1.7.1. Both files had a padding value of 4096. The first was encoded without the ReplayGain option, and the second was encoded to a different folder using ReplayGain. I copied the ReplayGained file to a third folder. Then, I opened this copy in foobar2000, right-clicked on it, selected Replaygain > Remove replaygain info from files.

File sizes (according to foobar2000's file info dialogue):
FLAC: 25,047,172 Bytes
FLAC w/ReplayGain: 25,047,320 Bytes
FLAC w/ReplayGain info removed: 25,047,320 Bytes

Even after I removed the ReplayGain info from the FLAC file, the tags disappeared but the less-than 150 Bytes taken up by the tags was not removed from the file. Since all three files have different wholefile md5 hashes, I'm assuming that the tiny portion of the file's header that contained the ReplayGain tags has been changed to null data.

BUT WAIT!

Since all the FLAC files that I'd created had 4096 bits of padding (FLAC Frontend's default, since I saw no option to specify padding values), I figured, what if I took my original FLAC file (the one I encoded without using ReplayGain), and used foobar2000's ReplayGain scanner to apply ReplayGain info to it? [To do this, right-click on the file or group of files that you want to ReplayGain, and say Replaygain > Scan per-file track gain or Scan selection as album. The latter is pretty much the only viable option for people dealing with concerts, anyway.]

I tried it, and lo and behold, the file was the same size as the original, even after the ReplayGain tags were added (25,047,172 Bytes). Obviously, foobar2000 wrote the ReplayGain tags into the file's padding (which is what the padding is there for, anyway). Checking that file against the md5 hash that I'd calculated earlier obviously produced a different sum and an error message. I then took this file, and using the aforementioned method, removed the ReplayGain info from the file. I checked the file info: the tags were gone and the file size was still 25,047,172 Bytes. I then checked the file against its original md5 hash. This time, it verified OK!

So, long story short, if you want to add ReplayGain info (or any other tags, such as title, artist, album, tracknumber, etc.) to a FLAC file and be able to later remove that info and have it check out OK against the original wholefile md5, use foobar2000's ReplayGain tool to scan and add the ReplayGain tags. This won't work if the file doesn't contain padding to facilitate the writing of tags, but FLAC encoders (such as the FLAC Frontend and foobar2000's FLAC encoder ) add 4096 bits of padding by default, so unless the person encoding it messed around with FLAC's options for some insane reason, it should work fine.
Reply With Quote Reply with Nested Quotes