1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:33:21 +08:00

Add filter effect to beatmap loading

This commit is contained in:
Jamie Taylor 2021-10-07 14:15:16 +09:00
parent 99fb86878e
commit 5c48340520
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -15,6 +15,7 @@ using osu.Framework.Graphics.Transforms;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Audio.Effects;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -63,6 +64,8 @@ namespace osu.Game.Screens.Play
private readonly BindableDouble volumeAdjustment = new BindableDouble(1); private readonly BindableDouble volumeAdjustment = new BindableDouble(1);
private Filter lpFilter;
protected bool BackgroundBrightnessReduction protected bool BackgroundBrightnessReduction
{ {
set set
@ -127,7 +130,7 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(SessionStatics sessionStatics) private void load(SessionStatics sessionStatics, AudioManager audio)
{ {
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce); muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce); batteryWarningShownOnce = sessionStatics.GetBindable<bool>(Static.LowBatteryNotificationShownOnce);
@ -159,7 +162,8 @@ namespace osu.Game.Screens.Play
new InputSettings() new InputSettings()
} }
}, },
idleTracker = new IdleTracker(750) idleTracker = new IdleTracker(750),
lpFilter = new Filter(audio.TrackMixer)
}); });
if (Beatmap.Value.BeatmapInfo.EpilepsyWarning) if (Beatmap.Value.BeatmapInfo.EpilepsyWarning)
@ -191,6 +195,7 @@ namespace osu.Game.Screens.Play
epilepsyWarning.DimmableBackground = b; epilepsyWarning.DimmableBackground = b;
}); });
lpFilter.CutoffTo(500, 100, Easing.OutCubic);
Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment); Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
content.ScaleTo(0.7f); content.ScaleTo(0.7f);
@ -229,6 +234,7 @@ namespace osu.Game.Screens.Play
// stop the track before removing adjustment to avoid a volume spike. // stop the track before removing adjustment to avoid a volume spike.
Beatmap.Value.Track.Stop(); Beatmap.Value.Track.Stop();
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
lpFilter.CutoffTo(lpFilter.MaxCutoff);
} }
public override bool OnExiting(IScreen next) public override bool OnExiting(IScreen next)
@ -242,6 +248,7 @@ namespace osu.Game.Screens.Play
BackgroundBrightnessReduction = false; BackgroundBrightnessReduction = false;
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
lpFilter.CutoffTo(lpFilter.MaxCutoff, 100, Easing.InCubic);
return base.OnExiting(next); return base.OnExiting(next);
} }