Wednesday, December 14, 2011

Understanding iTunes and Sound Check as well as Replay Gain

I've been very unhappy with the Sound Check option in iTunes. Many, if not most, of my songs seem to be at considerably different volume levels and I can't stand it. So, I made it my goal to understand how to fix this.

At first glance, I thought turning Sound Check off then back on would allow iTunes to reevaluate all my songs. That didn't happen. Turning Sound Check off only seemed to make the songs worse, so I can assume it was doing something. I started looking into other programs that would correct this horrible volume issue. What I found was just as confusing as using iTunes. Eventually, through my own testing and reading up on the basics (Replay Gain and tagging standards such as ID3), I was able to finally figure out some of this, enough to know what is going on at a basic level.

First, I looked at the .xml file that stores the iTunes library. I noticed that there were no tags referencing volume, gain, or level. I tested a few things with Sound Check and still there were no references. Eventually, I went to the properties of an individual song and used the volume slider adjustment under the Options tab. This added a reference in the XML file as follows:

Volume Adjustment-45

What does this mean? For starters, the volume adjustment has nothing to do with Replay Gain or Sound Check. This adjustment does not stay with the Mp3 file, but instead is only ever used in iTunes. I didn't test to see if this adjustment affected playback volume for that file on the iPod. However, I don't really care, it is an inefficient method of adjusting volume. Now, at least you know where the reference is stored.

I found a few important references on the internet when I searched Replay Gain and Sound Check. The most useful websites were the Reply Gain Wiki and this website discussing Replay Gain as it works with iTunes and iPods.

The Replay Gain Wiki gave me tons of useful information on what RG is, how it stores the data, as well as how iTunes does the same with Sound Check. Funny enough, Sound Check is similar to Replay Gain in how it analyzes the overall volume of a file, but it is not nearly as good at it. What we know is that Replay Gain stores the value in two metatags: replaygain_track_gain and replaygain_track_peak. iTunes stores Sound Check in one tag: iTunNORM.

*Note: one big problem, and one most likely to be responsible for why Sound Check does such an awful job of leveling, is that an Mp3 with bad data (sounds like chirps in the song) can be interpreted as having an overall higher volume. In reality, the volume analysis is supposed to be based on an average over the whole song, but given how quickly iTunes Sound Check analyzes files (MP3Gain took over 16 hours to analyze 11500 songs), I would say it did more of a random sampling and likely pushed the gain reduction to a higher number because of it.

When any software offers to add tags to a file to adjust the volume, there has to be a reference. iTunes uses a built in reference level and I presume it is less than 89 dB. I leveled all my music using MP3Gain and they are all louder with Sound Check off, the leveling was done to a reference of 89 dB. The Replay Gain community had suggested going to a standard 83 dB to provide more headroom to prevent clipping, but that has not gone into affect. iTunes may have adopted this same concept though and thus, their overall track volume seems to be lower. Also, note that iTunes only displays the Volume tag if Sound Check is on, see the screenshot below.





The real issue is how do we get iTunes and the iPod to read the replay gain tags? Since iTunes includes their own sound leveling, it makes sense that they would ignore something as oft used as Replay Gain. Well, that other website covers it quite well. I'll copy those steps below.

There is an easy way to convert the SOUNDCHECK values to replaygain values instead. This is particularly useful if you prefer ALBUM gain rather than TRACK gain (as I do). You'll need MP3TAG to do the job (a very nice program in general). The instructions below assume you have added album and track replaygain tags to your files (using either fb2k or dbpoweramp or some application, etc.).


1. First, you'll need a relatively recent (last year or so) build of mp3tag.
2. Second, you'll need the action that converts the replaygain album number to the soundcheck (Comment ITuneNorm). You should create a new action in MP3TAG. Do this by selecting "convert" from menu (must have a file loaded and selected I think). Then select "Actions". Then you'll see a popup box with a few "actions". Select the icon on upper right side of this box. This is create new action option. Give it a name that makes sense to you (e.g., replaygain action). Then select again the icon on upper right side of this new popup. In the dropdown menu select "format value" formatting the field "COMMENT ITUNENORM" (that is a space between COMMENT and ITUNNORM and you'll have to type this in the box) with the following format string you'll type into the next field below this: $rg2sc(%REPLAYGAIN_ALBUM_GAIN%)

If you want to use replaygain track level simply replace the "ALBUM_GAIN" above with "TRACK_GAIN" (although not worth the effort as track level replaygain and soundcheck values added by itunes are essentially the same). If you want to replace AAC (m4a) files' soundcheck values with the replaygain values all is the same but the field you are formatting is "ITUNNORM" rather than "COMMENT ITUNNORM"

I can confirm that this method works very well. A song that iTunes had marked as -7.8 dB was corrected by MP3Gain and the iTunNorm tag was updated by Mp3tag so that now it is at -0.7 dB. That is a huge improvement to the volume level analysis.