Better handling of ReplayGain for song RG in random playback

Issue description:

I’m using Navidrome and have switched to Symfonium specifically because it has ReplayGain support. I’ve been testing this using the ReplayGain Test Vectors, and while ReplayGain does work in Symfonium, there is a noticeable delay of about 1-2 seconds before ReplayGain changes are applied to the audio. This results in a jarring shift in volume in a lot of instances where a large amount of gain needs to be applied.

Repro steps are pretty much to use any files with ReplayGain tags (the ones I’ve linked above are what I used in the logs, but this behaviour can be seen in other ‘normal’ music files as well), enable ReplayGain (I’ve tried each of the modes, but have used Track in the logs), then play and you’ll notice the volume change isn’t instant.


debug.log (157.9 KB)


Can’t think of any that would help here, but happy to add some if needed.

Additional information:

ReplayGain works fine when playing these same files via Navidrome in a desktop client, or through a browser, so I think this isn’t a configuration issue, but as I’ve just started using Symfonium it might be a setting within the app causing this?

Well yes this is the limits of current ExoPlayer solution :frowning:

Due to Gapless implementation the preload on mid quality mp3 can be large before the replay gain is applied.

For the most common use cases of flac or playing albums with album RG (or auto) this is not an issue but when playing random songs without empty time on start / end and large RG changes this can be problematic.

I’m not sure I can disable gapless on Exoplayer for that use case (I’ve asked there) but the other solution would be to apply RG on the source file via ffmpeg as I intend to do to apply RG to Chomecast.

Next release will have an option for that mode.

Thanks for looking into this so quickly Tolriq.

I see in the 5.4.0 there’s a mention of an “experimental option to leverage transcoding engine for replay gain”, but I’m struggling to find this setting anywhere? Apologies if this is a dumb question, but I’ve scrolled through the various settings menu multiple times and can’t spot it.

Am I to understand that enabling this setting means that gapless playback is then disabled? If that’s the case, is there no compromise to be reached, eg. if you’re playing an album then Symfonium will ensure gapless is enabled, if you’re playing random songs then this new ReplayGain setting will be enabled? As it seems like a not ideal solution if you’re for example playing a Various Artists compilation and then have to go into the settings menu and toggle a setting to re-enable gapless before listening to a live album.

It’s Playback it’s advanced so in Playback / Advanced :wink:

Of course since it’s based on the transcode engine the transcode engine option must be enabled.

For the rest of your question I do not understand, this does not change anything about how replay gain works, just how it’s applied.

Thanks, I’ve found the setting :slight_smile:

Unfortunately, this breaks ReplayGain for me completely, both with MP3 and FLAC files. The beta transcoding engine itself is fine, but as soon as I turn on the Enhanced ReplayGain Processor setting, I no longer get ReplayGain applied on playback whatsoever.

I’ve attached a debug log for you, as well as the exact files that I used when generating the debug log. With the Enhanced ReplayGain Processor setting disabled, the gain of these files is automatically adjusted on playback, with the delay as we’ve spoken about previously. With the Enhanced ReplayGain Processor setting enabled (which it is in this debug log), the files are played at their original volumes - using the three files I’ve attached, the first one is at normal volume, the second one plays too loud, the third plays too soft.

It may be that I’ve done something wrong, or perhaps this setting is clashing with another setting I’ve got enabled, but I can consistently replicate this problem across multiple files and formats.

debug.log (97.5 KB)
ReplayGain Test (2.3 MB)

Seems you have the playback cache enabled and those files are cached. This might be the reason as this can’t work from the cached files and should recache them, maybe a key issue that I’ll need to check.

Disable playback cache, or clear it from the advanced settings then force kill / restart the app.

You’re right, playback cache was the issue here, and clearing it sorted it.

This new setting has fully solved my original issue of delays in ReplayGain, and has no adverse effect on gapless playback so my question around that can be disregarded.

Thanks again Tolriq!