Wednesday 22 June 2011

Sound check, replay gain

Ever since the neighbours downstairs complained about my music being too loud, I've been a bit paranoid when listening to music. The trouble is that it's hard to know how loud it is, since everything is recorded at different levels. There is also the loudness war to contend with. Ideally, I want to know that if my stereo indicates (say) -45dB then this will not be too loud, regardless of the source material.

Replay gain is a (de-facto) standard where the source material's loudness is compared to a reference level and the playback volume adjusted to match that level. Determining loudness it is an expensive computation, so it is done in advance and the gain value is stored in the music file as a metadata tag. In fact there two gain values, one for the individual track, and one for the whole album. When listening to a complete album, especially classical music, the relative loudness between tracks should be preserved using the (same) album gain for all tracks. When listening to a mix of music, track gain might be better.

Luckily, my playback system (a Squeezebox Touch)  supports replay gain as long as the music files are appropriately tagged. Most of my music is encoded in the open source lossless format FLAC, and there are tools to add the gain information (e.g., metaflac on the command line, foobar2000 on Windows). I used metaflac with the aid of some shell scripts to update my music collection overnight. This leaves my MP3 and AAC files to scan, and I am still looking into the best way to do that on my Mac. I might use foobar2000 with emulation.

The Squeezebox Touch needs to be configured to use replay gain using the web UI (Settings > Player > Audio, choose one of the volume adjustment options). It all works very smoothly and really tones down the loud mixes. This is not at the expense of quality; volume adjustment is done linearly in a 24-bit domain. There is no loss of dynamic range when volume is reduced, and positive gain is restricted to prevent any clipping (using peak data which is also harvested during the replay gain scan).

Now that it is all done, the volume knob on the stereo is actually set a bit higher than usual, because almost all music has a negative gain. Ironically, early CD pressings (1980s) are closest to the reference level, while modern mastering, especially radio-friendly pop music, is very heavily compressed and fatiguing to listen to for long periods. A negative gain on these tracks doesn't make them sound any better, but at least saves reaching for the remote!

No comments:

Post a Comment