forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Improvements for audio normalization #1
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
Merged
smallketchup82
merged 14 commits into
smallketchup82:audio-normalization
from
hwsmm:audio-normalization
May 20, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b81277f
Use framework loudness
hwsmm e58115f
Remove direct BASS usage in AudioNormalization and use framework coun…
hwsmm 6f2d873
Add normalization volume bindables in OsuGameBase
hwsmm 663aa15
Update normalization volume in MusicController
hwsmm 729f22d
Apply normalization to hitobjects
hwsmm baede41
Create AudioNormalizationManager instead of putting in OsuGameBase
hwsmm 2ce022d
Apply framework-side rename (AudioLoudness to TrackLoudness)
hwsmm 89aabae
Add docs in AudioNormalizationManager
hwsmm 6182878
Transform normalized volume along with queued track
hwsmm 46f11c7
Remove AudioManager dependency from MusicController
hwsmm 7abcb5f
Fix xmldoc in AudioNormalization
hwsmm 953d661
Refactor Audio Normalization
hwsmm b5ceb48
Add audio normalization setting
hwsmm 7b9360e
Refator audio normalization 2
hwsmm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Audio.Track; | ||
| using osu.Framework.Bindables; | ||
| using osu.Framework.Logging; | ||
| using osu.Game.Beatmaps; | ||
| using osu.Game.Configuration; | ||
|
|
||
| namespace osu.Game.Audio | ||
| { | ||
| /// <summary> | ||
| /// Manages audio normalization. | ||
| /// </summary> | ||
| public class AudioNormalizationManager | ||
| { | ||
| /// <summary> | ||
| /// Fallback volume for tracks that <see cref="TrackLoudness"/> failed to measure loudness. | ||
| /// </summary> | ||
| public const double FALLBACK_VOLUME = 0.8; | ||
|
|
||
| private readonly Bindable<bool> audioNormalizationSetting; | ||
|
|
||
| /// <summary> | ||
| /// Samples assigned to hitobjects needs to bind to this bindable to normalize their volume in line with track. | ||
| /// </summary> | ||
| public readonly BindableDouble SampleNormalizeVolume = new BindableDouble(1.0); | ||
|
|
||
| /// <summary> | ||
| /// Creates a new <see cref="AudioNormalizationManager"/>. | ||
| /// </summary> | ||
| /// <param name="config">An osu config to get beatmap hitsounds bindable from.</param> | ||
| /// <param name="beatmap">A bindable for beatmap.</param> | ||
| public AudioNormalizationManager(OsuConfigManager config, IBindable<WorkingBeatmap> beatmap) | ||
| { | ||
| audioNormalizationSetting = config.GetBindable<bool>(OsuSetting.AudioNormalization); | ||
|
|
||
| updateNormalization(audioNormalizationSetting.Value, beatmap.Value); | ||
| audioNormalizationSetting.BindValueChanged(change => updateNormalization(change.NewValue, beatmap.Value)); | ||
| beatmap.BindValueChanged(ev => onBeatmapChanged(ev.OldValue, ev.NewValue)); | ||
| } | ||
|
|
||
| private void updateNormalization(bool value, WorkingBeatmap current) | ||
| { | ||
| if (value) | ||
| { | ||
| SampleNormalizeVolume.BindTo(current.TrackNormalizeVolume); | ||
| current.EnableTrackNormlization(); | ||
| Logger.Log($"Normalization value: {(int)(current.TrackNormalizeVolume.Value * 100)}%"); | ||
| } | ||
| else | ||
| { | ||
| SampleNormalizeVolume.UnbindFrom(current.TrackNormalizeVolume); | ||
| SampleNormalizeVolume.Value = 1.0; | ||
| current.DisableTrackNormalization(); | ||
| } | ||
| } | ||
|
|
||
| private void onBeatmapChanged(WorkingBeatmap oldBeatmap, WorkingBeatmap newBeatmap) | ||
| { | ||
| SampleNormalizeVolume.UnbindFrom(oldBeatmap.TrackNormalizeVolume); | ||
| updateNormalization(audioNormalizationSetting.Value, newBeatmap); | ||
| } | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.