Bug 23 - Support --replay-gain in flac encoding
Summary: Support --replay-gain in flac encoding
Alias: None
Product: Asunder
Classification: Unclassified
Component: All (show other bugs)
Version: 2.7
Hardware: PC Linux
: enhancement
Assignee: Andrew Smith
Depends on:
Reported: 2015-11-28 21:22 EST by Orion Poplawski
Modified: 2015-12-05 15:35 EST (History)
1 user (show)

See Also:


Description Orion Poplawski 2015-11-28 21:22:25 EST
I'd like to be able to use the --replay-gain argument when encoding my flac files.
Comment 1 Andrew Smith 2015-12-05 15:35:34 EST
Hi Orion

You're not the only one who asked for this, I'll paste into here an email thread about this. Basically I don't know exactly how it would work and if I did - what the user interface for it would be.



Hi Andrew,

You're welcome.  I'll keep an eye out for an update, but in the mean
time i'll stick to my postprocessing script.

On Mon, 13 May 2013 21:42:20 -0400
Andrew Smith <andrew@littlesvr.ca> wrote:

> Hi Reinout
> Thanks for running that test. I'll put this on the todo list, who
> knows, maybe one day I'll find some spare time to implement something
> useful like this.
> Cheers,
> Andrew
> Le 2013-05-13 13:46, Reinout Wijnveen a écrit :
>> Hi Andrew,
>> Thanks for getting back to me.
>> That's actually a pretty good question you're asking.
>> Normally there are two separate gain tags per track computed: track
>> gain album gain. That does make sense because the individual
>> loudness can vary from track to track within an album.
>> For album gain you do indeed need the other tracks of the album as a
>> 'context' in order to keep the loudness variations within the album
>> intact.
>> Currently i use something like 'metaflac --add-replay-gain *flac'
>> inside a folder containing an album, so i guess metaflac has that
>> context, since it receives all the files on the commandline at
>> once. It can analyse them all and the tags when all information is
>> available.
>> So i decided to do a test. I ripped a CD to flac and wav.
>> On the flac output i performed the metaflac command as above.  The
>> wav files were encoded one by one with the command: flac
>> --replay-gain -8 <file>  (Simulating the ripping method of asunder)
>> The result is indeed different:
>> metaflac:
>> metaflac --list 0*.flac |grep _GAIN
>> 01.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-1.63 dB
>> 01.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 02.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-0.38 dB
>> 02.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 03.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-2.88 dB
>> 03.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 04.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-1.98 dB
>> 04.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 05.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-1.41 dB
>> 05.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 06.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-2.56 dB
>> 06.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 07.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-2.49 dB
>> 07.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 08.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-1.97 dB
>> 08.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 09.flac:    comment[4]: REPLAYGAIN_TRACK_GAIN=-1.80 dB
>> 09.flac:    comment[6]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> Individual encoding with adding gain tag:
>> metaflac --list 0*.flac |grep _GAIN
>> 01.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-1.63 dB
>> 01.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-1.63 dB
>> 02.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-0.38 dB
>> 02.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-0.38 dB
>> 03.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-2.88 dB
>> 03.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-2.88 dB
>> 04.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-1.98 dB
>> 04.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-1.98 dB
>> 05.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-1.41 dB
>> 05.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-1.41 dB
>> 06.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-2.56 dB
>> 06.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-2.56 dB
>> 07.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-2.49 dB
>> 07.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-2.49 dB
>> 08.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-1.97 dB
>> 08.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-1.97 dB
>> 09.flac:    comment[1]: REPLAYGAIN_TRACK_GAIN=-1.80 dB
>> 09.flac:    comment[3]: REPLAYGAIN_ALBUM_GAIN=-1.80 dB
>> The one by one method just sets the album gain equal to the track
>> gain and is therefore less accurate.
>> So what i suggested turns out to be more of a quick and dirty
>> hack. Adding an accurate gain calculation to Asunder requires more
>> work and the presence of a metaflac command.
>> On Sun, 12 May 2013 16:25:23 -0400
>> Andrew Smith <andrew@littlesvr.ca> wrote:
>>> Hi Reinout
>>> Sorry for the late reply.
>>> I'm not familiar with replaygain and reading about it quickly am
>>> not sure I understand completely.
>>> Would it be of any use to pass --replay-gain to flac if I'm only
>>> doing one file at a time? Or does it only make sense if I'm
>>> encoding an entire album at the same time?
>>> Cheers,
>>> Andrew
>>>> Hi Andrew,
>>>> I have been using asunder to rip my CD's for over a year now. It
>>>> works quite well for me. I switched to asunder from other tools
>>>> the moment i decided to go lossless and realized i needed mp3 for
>>>> the car and could use flac at home. The only thing that bothers
>>>> me is that i need to postprocess the flac files with metaflac to
>>>> add replaygain. lame can add gain tags by default. The flac
>>>> encoder can add gain tags, but always needs a separate
>>>> commandline option (--replay-gain). I have been looking through
>>>> the GUI and the config file, but i don't think i can add that in
>>>> asunder. It would be nice to have an optional free text field
>>>> (per file format/encoder) where the user can enter commandline
>>>> options. Unfortunately i'm not at all fluent in C, so i'm unable
>>>> to send you the diffs :-(
>>>> Anyway: thanks for creating asunder.
>>>> Regards,
>>>> Reinout


Reinout Wijnveen

"All who believe in psychokinesis raise my hand"

Note You need to log in before you can comment on or make changes to this bug.