From 5c48340520cb5b8df5ae8852f01c0b1f0239aa43 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 7 Oct 2021 14:15:16 +0900 Subject: [PATCH] Add filter effect to beatmap loading --- osu.Game/Screens/Play/PlayerLoader.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 969527a758..4168dda867 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Framework.Screens; using osu.Framework.Threading; +using osu.Game.Audio.Effects; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -63,6 +64,8 @@ namespace osu.Game.Screens.Play private readonly BindableDouble volumeAdjustment = new BindableDouble(1); + private Filter lpFilter; + protected bool BackgroundBrightnessReduction { set @@ -127,7 +130,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load(SessionStatics sessionStatics) + private void load(SessionStatics sessionStatics, AudioManager audio) { muteWarningShownOnce = sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce); batteryWarningShownOnce = sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce); @@ -159,7 +162,8 @@ namespace osu.Game.Screens.Play new InputSettings() } }, - idleTracker = new IdleTracker(750) + idleTracker = new IdleTracker(750), + lpFilter = new Filter(audio.TrackMixer) }); if (Beatmap.Value.BeatmapInfo.EpilepsyWarning) @@ -191,6 +195,7 @@ namespace osu.Game.Screens.Play epilepsyWarning.DimmableBackground = b; }); + lpFilter.CutoffTo(500, 100, Easing.OutCubic); Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment); content.ScaleTo(0.7f); @@ -229,6 +234,7 @@ namespace osu.Game.Screens.Play // stop the track before removing adjustment to avoid a volume spike. Beatmap.Value.Track.Stop(); Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); + lpFilter.CutoffTo(lpFilter.MaxCutoff); } public override bool OnExiting(IScreen next) @@ -242,6 +248,7 @@ namespace osu.Game.Screens.Play BackgroundBrightnessReduction = false; Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); + lpFilter.CutoffTo(lpFilter.MaxCutoff, 100, Easing.InCubic); return base.OnExiting(next); }