ReplayGain support

Tobias Leupold tl at l3u.de
Wed Dec 22 13:15:21 GMT 2021


Hi list :-)

I recently stumbled upon Bug #430233 (again), and I thought this here would be 
a better place to chat about this than the bug report.

Still, ReplayGain support would be a very cool feature for Elisa. I didn't 
have a look at the sources yet (and I also don't know if I'm even capable of 
contributing some code to this feature ;-) but I experimented a bit with the 
ReplayGain tags thingy.

Apparently, it's not completely trivial.

E.g. I ripped "Cloud Connected" by In Flames from the original album and 
encoded it to vorbis and opus ("oggenc -q 6" and "opusenc --bitrate 128").

I then added ReplayGain tags with loudness (from https://github.com/jiixyj/
loudness-scanner).

The tool said, for this track, it would apply -11.38 dB for the vorbis file 
and -11.47 dB for the opus file (the difference may be caused by the deviating 
psychoacoustic model or whatever).

Checking the metadata (via vorbiscomment), the vorbis file contains

    REPLAYGAIN_TRACK_GAIN=-11.38 dB

which is exactly the value outputted by loudness (one would have to parse this 
if this is the very content of the data field, but it would be quite trivial).

For the opus file, I got

    R128_TRACK_GAIN=0

which made me wonder a bit. Later on, inside the stream info, I found

    Playback gain: -16.4766 dB

which is more or less the value outputted by loudness, minus 5 dB.

I was pretty sure I saw the R128_TRACK_GAIN tag being set back then, so I 
checked my music collection. There, the same (opus) file had:

    R128_TRACK_GAIN=-4224

set. Which is, divided by 265, -16.5.

So apparently, something changed here, and meanwhile, the R128_TRACK_GAIN tag 
isn't set anymore in favor of setting the stream header value for the 
"playback gain".

So ... do you have some information about this? Why is the opus replay gain 5 
dB lower than the vorbis one? I think I read something about opus using a 
different treshold than vorbis (something about vorbis being louder than 
vorbis and the foobar player or so).

And apparently, we would have to check all those cases to get a unified gain 
value to apply, so that the files actually do have the same volume when 
played.

As said, I'd really like to help here! I'll see how far I can get with the 
code. If somebody is also interested, I'd be very happy to get some answer.

Thanks for Elisa so long :-)

Cheers, Tobias




More information about the Elisa mailing list