School me on: Replay gain

Wheels Of Confusion

Ars Legatus Legionis
66,177
Subscriptor
Let's say I have a music collection consisting of CD rips in FLAC.

Let's say the mastering is all over the place since these things span literal generations, from the early years of optical to the Loudness Wars and beyond.

Let's say I have a single, large playlist with lots of tracks from various albums, and some are mastered too 'quiet' next to the others.

Let's say I want to transcode them to mp3 and put them on a single disc/card/whatever with the playlist, and hopefully some kind of replay gain to enlouden the quiet ones so they don't get aurally lost if a loud one just ended.

What's the most efficient and fool-proof way to go about this? And what are the odds a random piece of audio playback hardware (not an app on a general purpose device) would respect the replay gain?

EDIT: Forgot to mention, I'm using foobar2000 to manage the playlist.
 
Last edited:

Nazgutek

Ars Scholae Palatinae
875
I already do this, in foobar2000.

I scan the FLACs by albums, and then apply ReplayGain tags to the FLAC, so that the original waveform data is untouched. My ReplayGain settings in foobar2000 are the default. By tagging the FLACs you can rescan or just drop the ReplayGain info at any time without worrying about the actual FLAC itself.

I then use the built-in converter to transcode to AAC (VBR Q 109), and under 'Processing', have Apply album gain, with preamp selected (nearly everything I have that doesn't need attenuating has some headroom so I preamp by 6db otherwise things are too quiet for mobile use).

1715253439933.png

The second important part is under the 'Other' section, ensure "Transfer ReplayGain info" is not selected. Otherwise, on a ReplayGain aware device, you'll end up with the ReplayGain applied twice!

The result is AACs where the waveform itself has been ReplayGained, and no ReplayGain tags, so that the relative loudnesses are all the same on all playback devices.

Foobar's converter is great for this, can save off the preset under a specific name ("FLAC to AAC VBR -RG 95db" in my instance) then it's listed under 'Convert' when right clicking on FLACs.
 

Ardax

Ars Legatus Legionis
19,076
Subscriptor
I'm using foobar2000 to manage the playlist.
We're going to start from the end, since this is important. FB2K has amazing ReplayGain support built in.

Let's say I have a music collection consisting of CD rips in FLAC.

Let's say the mastering is all over the place since these things span literal generations, from the early years of optical to the Loudness Wars and beyond.
So, if you haven't already done this, you should be scanning all these CDs in Album Mode and saving the ReplayGain tags to the files. That sets up everything else.

Let's say I have a single, large playlist with lots of tracks from various albums, and some are mastered too 'quiet' next to the others.

Let's say I want to transcode them to mp3 and put them on a single disc/card/whatever with the playlist, and hopefully some kind of replay gain to enlouden the quiet ones so they don't get aurally lost if a loud one just ended.
OK, so @Nazgutek has already covered the bit about applying ReplayGain during your transcode. In this case, since you have a collection of singles rather than complete albums in your playlist, you'll want to use Track Gain instead of Album Gain during your conversion.

And what are the odds a random piece of audio playback hardware (not an app on a general purpose device) would respect the replay gain?
With the volume correction applied during conversion, nothing special is needed. The audio that was encoded already had the volume changes applied. I don't really follow audio hardware as a hobby, but I wouldn't expect any kind of audio hardware devices to know about or respect ReplayGain tags. Of course, I'd expect FB2K on mobile devices to respect it along with a minority of other audio players for mobile devices, but that's not the same thing.

All this said, if you have a collection of MP3s in particular (and possibly some other file types as well), FB2K can also apply the gain correction directly to the audio without reencoding the file. (The old MP3Gain tool used to do this for MP3s.) The file structure has a field for it in the frame structure and compliant decoders (which should be everything at this point) will respect it. This does modify the file, and while FB2K may store "undo" information, it's not something I'd want to do to my original files.
 

redleader

Ars Legatus Legionis
35,019
What's the most efficient and fool-proof way to go about this? And what are the odds a random piece of audio playback hardware (not an app on a general purpose device) would respect the replay gain?

EDIT: Forgot to mention, I'm using foobar2000 to manage the playlist.
I used foobar to apply replaygain to the decoded PCM and then transcode to lossy for basically the entire iPod to early smartphone era back when hardware didn't support RG at all. It works perfectly for this.
 

Wheels Of Confusion

Ars Legatus Legionis
66,177
Subscriptor
All this said, if you have a collection of MP3s in particular (and possibly some other file types as well), FB2K can also apply the gain correction directly to the audio without reencoding the file. (The old MP3Gain tool used to do this for MP3s.) The file structure has a field for it in the frame structure and compliant decoders (which should be everything at this point) will respect it. This does modify the file, and while FB2K may store "undo" information, it's not something I'd want to do to my original files.
I'm looking to take my FLAC sources and transcode them to mp3s in a new folder specifically to make this playlist portable, so if there's a step or two to scan all the playlist source files and apply normalization (make the quietest on par with the loudest) to the mp3s during that step (or directly on the mp3s in the new directory after transcoding), I think that's what I'm after?
 

Nazgutek

Ars Scholae Palatinae
875
You can scan multiple albums at once for ReplayGain in foobar, just select them all and pick “scan by albums”. It’ll scan everything and tag ReplayGain info to every track, both album gain and track gain values.

Then, you can use the foobar converter to apply the ReplayGain factor to the output mp3 waveform as I mentioned earlier. By default ReplayGain aims for a 89db loudness but that can be too quiet on mobile devices so I apply a 6db preamp gain. All my FLACs live in X:\Music\FLAC and I point the converter to X:\Music\AAC with the folder pattern being %albumartist%\%album%\%filename% to mimic my FLAC folder structure.

In theory I can rescan all 700+ albums for ReplayGain with a right click and some left clicks, and then transcode everything again with another right click and a few left clicks.
 

Wheels Of Confusion

Ars Legatus Legionis
66,177
Subscriptor
All my FLACs live in X:\Music\FLAC and I point the converter to X:\Music\AAC with the folder pattern being %albumartist%\%album%\%filename% to mimic my FLAC folder structure.
Same, except I use Vorbis as my usual target instead of AAC. I was going to do the same here with a special folder just for these tracks, in mp3, then take that whole folder and put it on something portable. Hopefully so that whatever I played it on would boost the quiet stuff a bit and I wouldn't need to touch the volume button at all.

So I'm clear, telling foobar to scan my FLAC files simply has it read them all, determine what peak level of loudness there is, and assign them a metadata value that it can use to boost or reduce that volume during playback as needed?

So my first step is to scan my FLAC originals for replay gain information, and it it set those metadata tags in the files. Probably with the "scan as albums by tags" option because there are some dupes (different editions, etc.). By itself, that will not affect playback on anything, but if I enable replay gain in foobar2k it will use those tags to even out the sound while playing through them.

Then I go to my new playlist, select the whole thing, and set up a custom encoder profile. Here's the default for LAME v1 (for space reasons) -S --noreplaygain -V 1 - %d

In my use case, snip out the bit that says noreplaygain, then go back and use that profile like I would anything else, and the resulting directory will have all the files normalized to the appropriate level on anything that recognizes replay gain tags?
 

Ardax

Ars Legatus Legionis
19,076
Subscriptor
So I'm clear, telling foobar to scan my FLAC files simply has it read them all, determine what peak level of loudness there is, and assign them a metadata value that it can use to boost or reduce that volume during playback as needed?
Correct.

So my first step is to scan my FLAC originals for replay gain information, and it it set those metadata tags in the files. Probably with the "scan as albums by tags" option because there are some dupes (different editions, etc.). By itself, that will not affect playback on anything, but if I enable replay gain in foobar2k it will use those tags to even out the sound while playing through them.
That's all exactly correct.

In my use case, snip out the bit that says noreplaygain
Don't do this. LAME has its own ReplayGain analyzer that will analyze the incoming audio stream and write tags to the resulting MP3, but it's not as robust as Foobar's. Also, by virtue of the encoder working file by file, it has no ability to compute album level tags.

Leave the --noreplaygain flag in place, and use the converter options to apply ReplayGain during transcoding. I haven't used Foobar in years so I don't remember exactly how to get to them, but I'm sure they're still there somewhere and somehow.
 

Wheels Of Confusion

Ars Legatus Legionis
66,177
Subscriptor
Don't do this. LAME has its own ReplayGain analyzer that will analyze the incoming audio stream and write tags to the resulting MP3, but it's not as robust as Foobar's. Also, by virtue of the encoder working file by file, it has no ability to compute album level tags.

Leave the --noreplaygain flag in place, and use the converter options to apply ReplayGain during transcoding. I haven't used Foobar in years so I don't remember exactly how to get to them, but I'm sure they're still there somewhere and somehow.
Alright, looks like it's in the Processing section of the converter dialog. The options are Source Mode (none, track, album) and Processing (apply gain, apply gain and prevent clipping according to peak, prevent clipping according to peak)

Looks like I'd prefer apply gain and prevent clipping, but would I want "track" for the Source Mode option?
 

ant1pathy

Ars Tribunus Angusticlavius
6,461
Only downside to "track" source mode is if you want a track to maintain the same relative loudness to the rest of the album it's on. I use source mode album for this reason, I didn't want quiet intro pieces to get boosted compared to the main tracks.
Exactly this. You should expect album tracks to be appropriately loud amongst themselves, while you might need to pull the whole album up a few db. Applying replay gain in any way other than a whole album/work is madness :p.
 

Ardax

Ars Legatus Legionis
19,076
Subscriptor
I mean, it depends on what you're transcoding and why. If I'm listening to a grab bag of singles on shuffle, use track mode.

If I'm listening to an album or large chunks of it in sequence, then use album mode.

It's why we have both.

Now, if we scroll allllll the way back up to the OP, we see:

Let's say I have a single, large playlist with lots of tracks from various albums
That -- to me at least -- says "use track mode".