diff --git a/osu.Game/Audio/Effects/AudioFilter.cs b/osu.Game/Audio/Effects/AudioFilter.cs index 682ca4ca7be0..c8673372d7f7 100644 --- a/osu.Game/Audio/Effects/AudioFilter.cs +++ b/osu.Game/Audio/Effects/AudioFilter.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using ManagedBass.Fx; using osu.Framework.Audio.Mixing; +using osu.Framework.Caching; using osu.Framework.Graphics; namespace osu.Game.Audio.Effects @@ -22,6 +23,8 @@ public partial class AudioFilter : Component, ITransformableFilter private bool isAttached; + private readonly Cached filterApplication = new Cached(); + private int cutoff; /// @@ -36,7 +39,7 @@ public int Cutoff return; cutoff = value; - updateFilter(cutoff); + filterApplication.Invalidate(); } } @@ -61,6 +64,17 @@ public AudioFilter(AudioMixer mixer, BQFType type = BQFType.LowPass) Cutoff = getInitialCutoff(type); } + protected override void Update() + { + base.Update(); + + if (!filterApplication.IsValid) + { + updateFilter(cutoff); + filterApplication.Validate(); + } + } + private int getInitialCutoff(BQFType type) { switch (type)