Mp3 volume tags? (MP3Gain volume normalization)

Apr 18, 2013 at 8:18 PM
I've used MP3Gain to set all of my mp3s to 89db, but it sounds like it doesn't modify the mp3, but sets some kind of tag which NAudio doesn't appear to respect. Anyone know how to handle this?
Coordinator
Apr 18, 2013 at 9:38 PM
I have no idea how MP3Gain works, but NAudio simply passes on the MP3 frames to the ACM decompressor that comes with Windows.
Apr 19, 2013 at 2:08 PM
Grass,

You are correct, MP3Gain uses ReplayGain, which is just a tag indicating how much to attenuate (or boost) the decoded audio to reach the specified average level. The spec explains it pretty well (it's just some math), and at the end you should have a linear scaling factor (multiply each sample by scaling_factor to get the correct volume level). Reading the ReplayGain tag is an exercise left to the reader (see the spec!).

The simplest way to support it is with a VolumeSampleProvider wrapper around the MP3 decoder. Set the volume to the calculated scaling factor for each track and everything should "just work".