feat(player): add volume boost with automatic real-time gain - #13762
Open
dev-stupid-codes wants to merge 1 commit into
Open
feat(player): add volume boost with automatic real-time gain#13762dev-stupid-codes wants to merge 1 commit into
dev-stupid-codes wants to merge 1 commit into
Conversation
Some streams are mastered so quietly that they are hard to hear even at the maximum system volume. Add a volume boost, reachable from a new speaker button in the player control bar, which amplifies the decoded PCM samples before they reach the audio track. The boost can either be picked by the user, from 100% up to 300%, or be left to the player: in automatic mode the gain is derived in real time from the loudness of the stream itself, so that quiet passages are brought up while already loud ones are left untouched. - VolumeBoostAudioProcessor amplifies 16 bit and float PCM samples, clipping whatever exceeds the range of the encoding. In automatic mode it measures the loudness (RMS) and the peak of every buffer, aims for about -16 dBFS, keeps the peak below full scale to limit clipping, and smooths the gain with a fast attack and a slow release so that sudden loud passages do not clip and quiet ones do not pump. - VolumeBoostRenderersFactory installs that processor into the audio sink and keeps the wanted gain across the sinks which are rebuilt whenever a player is created. CustomRenderersFactory now extends it, so both factories the player picks from support the boost. - The main player shows VolumeBoostDialog, with a slider and an "Adjust automatically" switch. The popup player, which has no activity to host a dialog, shows a menu of gains instead. - The button is tinted while the audio is being amplified, so that it is obvious the stream is not played back as it is. - Both the gain and the automatic mode are saved to the preferences and restored on the next playback, like the playback speed already is. The audio processors ExoPlayer itself adds are kept, therefore playback speed, pitch and silence skipping keep working alongside the boost.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What is it?
Description of the changes in your PR
Some streams are mastered so quietly that they are hard to hear even at the maximum
system volume. This adds a volume boost which amplifies the decoded PCM samples before
they reach the audio track, either with a gain the user picks or with one the player
derives from the stream in real time.
slider and an "Adjust automatically" switch (off by default). The popup player
has no activity to host a dialog, so it gets a menu of gains instead.
the range of the encoding (the same trade-off VLC makes for its own volume boost).
for roughly -16 dBFS, caps the gain so the peak stays below full scale, and smooths
the gain with a fast attack (50 ms) and a slow release (2 s), so a sudden loud passage
does not clip and a quiet one does not pump. It only ever amplifies, never attenuates,
and resets when the processor is flushed (seek, next stream).
wanted gain across the sinks that are rebuilt every time a player is created.
CustomRenderersFactorynow extends it, so both factories the player picks fromsupport the boost.
that the stream is not played back as it is.
next playback, like the playback speed already is.
silence skipping keep working alongside the boost.
Unit tests were added for the processor (amplification and clipping for both encodings,
empty input, clamping, and the automatic mode amplifying quiet audio, leaving loud audio
alone and resetting on flush) and for the new
SliderStrategy.Linear.Fixes the following issues
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane,
click on "CI", scroll down to "artifacts" and click "app" to download the zip file which
contains the debug APK of this PR. You can find more info and a video demonstration
on this wiki page.
Due diligence