From 93eb385dd40e3d745691c09d8e4376354ae40bd8 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 8 Jul 2021 20:01:39 +0900 Subject: [PATCH 1/2] Add sound for switching between volume controls --- osu.Game/Overlays/Volume/VolumeMeter.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index eed6f5c2f3..4822f411c5 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; +using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -42,7 +43,8 @@ namespace osu.Game.Overlays.Volume private Container selectedGlowContainer; - private Sample sample; + private Sample hoverSample; + private Sample notchSample; private double sampleLastPlaybackTime; public event Action StateChanged; @@ -78,7 +80,8 @@ namespace osu.Game.Overlays.Volume [BackgroundDependencyLoader] private void load(OsuColour colours, AudioManager audio) { - sample = audio.Samples.Get(@"UI/notch-tick"); + hoverSample = audio.Samples.Get($"UI/{HoverSampleSet.Button.GetDescription()}-hover"); + notchSample = audio.Samples.Get(@"UI/notch-tick"); sampleLastPlaybackTime = Time.Current; Color4 backgroundColour = colours.Gray1; @@ -274,7 +277,7 @@ namespace osu.Game.Overlays.Volume if (Time.Current - sampleLastPlaybackTime <= tick_debounce_time) return; - var channel = sample.GetChannel(); + var channel = notchSample.GetChannel(); channel.Frequency.Value = 0.99f + RNG.NextDouble(0.02f) + displayVolume * 0.1f; @@ -395,6 +398,8 @@ namespace osu.Game.Overlays.Volume selectedGlowContainer.FadeOut(transition_length, Easing.OutExpo); break; } + + hoverSample?.Play(); } } } From 8746ef0ba9c3924c09eb6881b05af3b36a011b3c Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 8 Jul 2021 20:36:25 +0900 Subject: [PATCH 2/2] Avoid double playback of sample --- osu.Game/Overlays/Volume/VolumeMeter.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 4822f411c5..f4cbbf5a00 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -391,6 +391,7 @@ namespace osu.Game.Overlays.Volume case SelectionState.Selected: this.ScaleTo(1.04f, transition_length, Easing.OutExpo); selectedGlowContainer.FadeIn(transition_length, Easing.OutExpo); + hoverSample?.Play(); break; case SelectionState.NotSelected: @@ -398,8 +399,6 @@ namespace osu.Game.Overlays.Volume selectedGlowContainer.FadeOut(transition_length, Easing.OutExpo); break; } - - hoverSample?.Play(); } } }