vanilla-music / vanilla

Vanilla Music Player for Android
GNU General Public License v3.0
1.17k stars 295 forks source link

ReplayGain for Opus encodes isn't being applied correctly #982

Open Ceremony64 opened 5 years ago

Ceremony64 commented 5 years ago

Once a track contains a negative replay gain, the opus version is a lot quieter than FLAC, MP3 or OGG Vorbis counterparts.

I tried the latest build at http://android.eqmx.net/android/vanilla/VanillaMusic-nightly.apk but that didn't seem to change anything, despite the mentioned fix in #952.

I prepared a collection of FLAC, MP3, OGG Vorbis and Opus for testing with a fixed track gain of -10db written with foobar2000: https://storage.superconnected.org/random/ReplayGain.zip (14.5MiB) Source: https://archive.org/details/mmm016

P.S. I guess a positive replay gain will result in a louder Opus version as well, tho I have not tested it.

issue-dispenser commented 4 years ago

@adrian-bl In c57d256a1c37eaf566d5845bdbf5762332b3b98e the r128 = true was removed from the if(tags.containsKey("R128_BASTP_BASE_GAIN")) block, which means that the +5.0f R128->RG translation isn't applied. Was that intentional?

issue-dispenser commented 4 years ago

I played around a bit and it seems like the Opus file (which is shown as rgain found=true, track=5.00, album=5.00) is equal (or very close) in volume to the MP3 file with the track RG changed to replaygain_track_gain: -15.00 dB instead of the provided replaygain_track_gain: -10.00 dB.

The aforementioned +5.0f (which in this case happens to be added even if there is a bug) doesn't actually do anything in applyReplayGain because the rg_result is 10^(5/20) ~= 1.778 which is clipped to 1 and thus isn't applied.

Edit: Confirmed this by using opusinfo from opus-tools:

Processing file "[Opus] Neely.opus"...

New logical stream (#1, serial: 0000398a): type opus
Encoded with libopus 1.3-26-ge85ed772, libopusenc 0.2.1-2-g9cb17c6
User comments section follows...
        ARTIST=The Vox
        TITLE=[Opus] Neely
        ALBUM=Amateurs on Plastic: A Tribute to Teenbeat Records
        DATE=2002
        GENRE=Indie
        COMPOSER=Air Miami
        TRACKNUMBER=5
        TRACKTOTAL=22
        DISCNUMBER=1
        DISCTOTAL=1
        COMMENT=http://www.mymeanmagpie.com
        R128_TRACK_GAIN=0
Opus stream 1:
        Pre-skip: 312
        Playback gain: -15 dB
        Channels: 2
        Original sample rate: 44100 Hz
        Packet duration:   20.0ms (max),   20.0ms (avg),   20.0ms (min)
        Page duration:   1000.0ms (max),  998.3ms (avg),  800.0ms (min)
        Total data length: 1818334 bytes (overhead: 0.815%)
        Playback length: 1m:59.774s
        Average bitrate: 121.5 kbit/s, w/o overhead: 120.5 kbit/s
Logical stream 1 ended