Moonbase59 / loudgain

ReplayGain 2.0 loudness normalizer based on the EBU R128/ITU BS.1770 standard (-18 LUFS, FLAC, Ogg, MP2, MP3, MP4, M4A, AAC, ALAC, Opus, ASF, WMA, WAV, AIFF, WavPack, APE)
Other
182 stars 23 forks source link

Option to enable "recommended settings" on a per-file basis #14

Open haasn opened 4 years ago

haasn commented 4 years ago

Rather than users/scripts needing to duplicate the loudgain invocation with the recommended flags based on the filetype, it would be cool if you could add one single -G / --golden flag to enable your recommended settings.

This would offer a few minor advantages:

  1. Users could build scripts similar to rgbpm much more easily, without needing to reproduce your settings for every file type.
  2. You could make changes to these settings, or more probably, add settings for new file types, as the years go by.
  3. You could support calculating album gain for files with mixed file formats. Consider an album in which one specific file was transcoded from the original format to a different format for some reason. I have e.g. cut up a single MP3 track of an album into 2+ separate files (and stored them losslessly to prevent modifying the bits in the process). If I want to calculate album gain for this album, I would need to calculate them as part of a single loudgain invocation, i.e. loudgain {01..04}*.mp3 05*.flac {06..09}*.mp3. Using -G here would apply the recommended settings per file, based on its format (e.g. using -L for the mp3 files but not the flac). Similar scenarios can arise when a "bonus track" is only available in MP3 format but the rest of the album is FLAC, etc.

A simple wrapper script could accomplish this in practice, but rather than going by the file extension, it would be ideal to look at the file type itself (since you decode it anyways); which would require integration into loudgain

Moonbase59 commented 4 years ago

Interesting idea, then again, the recommendation could change, or the users have their own preferences. In principle, I’m kinda against hardcoding things like that. Probably some kind of config file would be nice to have.

The scripts were done way back, and in a "quick-and-dirty" way, that’s why they check for file extensions only. Loudgain itself actually tries to correctly determine what the file really is, and the stream number to use (yes, you could even use it to tag a video file, say "mp4" …). So, if you’ve misnamed, say, a FLAC file to ".mp3" accidentally, it would still see it’s FLAC and handle it correctly.

You can actually already today mix file types in an album (though I don’t recommend it). Commandline options only affect file types for which they make sense, i.e., if you specified "-L -I 3" this would affect MP3 files but tags in FLAC would of course still be uppercase Vorbis Comment tags.

If you mix different file types in one album, loudgain will issue a warning (but continue). The only exception that generates an error (and aborts) is mixing Opus and non-Opus files in one album. Opus is based on a fixed -23 LUFS reference, so it is not possible to calculate correct album values when mixing with other files that might be referenced to -18 LUFS.

I’ll consider your idea of predefined "recommended settings" for a future version. It’s just that I’m a bit short of time right now.