Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPUS gain is applied incorrectly/undocumented #969

Closed
hknutsen opened this issue Jan 20, 2025 · 7 comments
Closed

OPUS gain is applied incorrectly/undocumented #969

hknutsen opened this issue Jan 20, 2025 · 7 comments
Assignees
Labels
bug Something isn't working playback Related to music playback

Comments

@hknutsen
Copy link

hknutsen commented Jan 20, 2025

Context:

  • Most files (e.g. FLAC and MP3 files) use the ReplayGain standard for volume normalization. ReplayGain adjusts to -18 dB LUFS by default.
  • Opus files use the EBU R 128 standard for volume normalization. EBU R 128 adjusts to -23 dB LUFS by default.
  • In short: Opus files are 5 dB quieter than files that use the ReplayGain standard.

Also:

  • ReplayGain stores album gain in the REPLAYGAIN_ALBUM_GAIN tag, and track gain in the REPLAYGAIN_TRACK_GAIN tag.
  • Opus stores album gain in the header (referred to as "header gain" here), and additional track gain in the R128_TRACK_GAIN tag.
  • In short: Opus files have built-in album gain.

I've been trying to figure out how Auxio applies header gain to Opus files by digging through issues, PRs and commits in this repository, however I'm still confused.

Would it be possible to document how Auxio applies gain to Opus files? For example in the wiki?

What could be documented:

  • Are Opus files automatically adjusted to target -18 dB by default (i.e. +5 dB added to Opus files), to ensure consistency with files that use the ReplayGain standard instead?
  • Is header gain always applied? I often see header gain referred to as "base gain" in this repo, which implies that it's always applied. See also this issue comment.
@OxygenCobalt
Copy link
Owner

re Opus files automatically adjusted to target -18 dB by default (i.e. +5 dB added to Opus files), to ensure consistency with files that use the ReplayGain standard instead?

Auxio does, but I don't know if the system media codec handler does.

Is header gain always applied? I often see header gain referred to as "base gain" in this repo, which implies that it's always applied. See also #521 (comment).

That is my belief. The system media codec handler is documented to already process and handle the header gain. Auxio handles the additional R128 tags.

Does this help @hknutsen?

@hknutsen
Copy link
Author

hknutsen commented Jan 21, 2025

Thank you for the quick response!

As a result of your very helpful comment, I did a couple of quick tests where I compared the volume in Auxio with the volume in Spotify.

Test 1

  • Opus files target -23 dB LUFS by default.
  • Spotify targets -14 dB LUFS by default (referred to as the "normal" level here)
  • Assuming that Auxio applies +5 dB by default to Opus files, I added +4 dB to the pre-amp to target the same loudness as Spotify (23 - 14 - 5 = 4).

With this configuration, Auxio plays back the exact same song at a noticeably lower volume than Spotify (that song being Fossegrim by Kvelertak, streamed on Spotify here and bought on Qobuz here. The UPC and ISRCs match between Spotify and Qobuz, so these are the same release).

Test 2

  • Assuming that Auxio does not apply +5 dB by default to Opus files, I added +9 dB to the pre-amp to target the same loudness as Spotify (23 - 14 = 9).

With this configuration, Auxio seems to play back at the same volume as Spotify (or at least close enough that I'm unable to make out a difference).

Findings

I'm fully aware that this is not a very formal testing method, but these are my findings for now:

  • The system media codec does seem to apply header gain by default.
  • Auxio does not seem automatically add +5 dB to Opus files.

@hknutsen
Copy link
Author

hknutsen commented Jan 21, 2025

I'm fully aware that this is not a very formal testing method, but these are my findings for now:

  • The system media codec does seem to apply header gain by default.
  • Auxio does not seem automatically add +5 dB to Opus files.

Just to clarify:

This issue was not created to argue whether Auxio should apply +5 dB gain to Opus files or not. I created it simply to clarify how gain is currently applied to Opus files, and that it should be documented to prevent future confusion, since gain for Opus files can be a confusing topic (hence my own confusion) 🙂

@OxygenCobalt
Copy link
Owner

Will need some time to consider these results, as far as I know I'm doing everything right, but there may be a gotcha I'm not seeing @hknutsen.

@OxygenCobalt OxygenCobalt added bug Something isn't working playback Related to music playback labels Jan 22, 2025
@OxygenCobalt OxygenCobalt self-assigned this Jan 22, 2025
@OxygenCobalt OxygenCobalt changed the title Document how gain is applied for Opus files OPUS gain is applied incorrectly/undocumented Jan 22, 2025
@hknutsen
Copy link
Author

FWIW @OxygenCobalt, I think you're doing everything right as well 🙂 See this comment.

@OxygenCobalt
Copy link
Owner

OxygenCobalt commented Jan 22, 2025

Okay, I updated Supported Audio Formats to document the OPUS base gain behavior @hknutsen. Thanks for the heads-up.

@hknutsen
Copy link
Author

Documentation looks perfect, thanks @OxygenCobalt !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working playback Related to music playback
Projects
None yet
Development

No branches or pull requests

2 participants