Change IApplicableToTrack to receive adjustable component instead

This commit is contained in:
Salman Ahmed 2022-05-10 18:01:15 +03:00
parent bbbecbb6b7
commit 4f5001704e
7 changed files with 10 additions and 16 deletions

View File

@ -1,7 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Audio.Track; using osu.Framework.Audio;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Mods
/// </summary> /// </summary>
public interface IApplicableToTrack : IApplicableMod public interface IApplicableToTrack : IApplicableMod
{ {
void ApplyToTrack(ITrack track); void ApplyToTrack(IAdjustableAudioComponent track);
} }
} }

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Audio;
using osu.Framework.Utils; using osu.Framework.Utils;
@ -79,7 +78,7 @@ namespace osu.Game.Rulesets.Mods
// Apply a fixed rate change when missing, allowing the player to catch up when the rate is too fast. // Apply a fixed rate change when missing, allowing the player to catch up when the rate is too fast.
private const double rate_change_on_miss = 0.95d; private const double rate_change_on_miss = 0.95d;
private ITrack track; private IAdjustableAudioComponent track;
private double targetRate = 1d; private double targetRate = 1d;
/// <summary> /// <summary>
@ -141,7 +140,7 @@ namespace osu.Game.Rulesets.Mods
AdjustPitch.BindValueChanged(adjustPitchChanged); AdjustPitch.BindValueChanged(adjustPitchChanged);
} }
public void ApplyToTrack(ITrack track) public void ApplyToTrack(IAdjustableAudioComponent track)
{ {
this.track = track; this.track = track;
@ -210,7 +209,6 @@ namespace osu.Game.Rulesets.Mods
private void adjustPitchChanged(ValueChangedEvent<bool> adjustPitchSetting) private void adjustPitchChanged(ValueChangedEvent<bool> adjustPitchSetting)
{ {
track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange); track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange); track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
} }

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -27,7 +26,7 @@ namespace osu.Game.Rulesets.Mods
}, true); }, true);
} }
public override void ApplyToTrack(ITrack track) public override void ApplyToTrack(IAdjustableAudioComponent track)
{ {
// base.ApplyToTrack() intentionally not called (different tempo adjustment is applied) // base.ApplyToTrack() intentionally not called (different tempo adjustment is applied)
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust); track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);

View File

@ -3,7 +3,6 @@
using System.Linq; using System.Linq;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -71,7 +70,7 @@ namespace osu.Game.Rulesets.Mods
InverseMuting.BindValueChanged(i => MuteComboCount.MinValue = i.NewValue ? 1 : 0, true); InverseMuting.BindValueChanged(i => MuteComboCount.MinValue = i.NewValue ? 1 : 0, true);
} }
public void ApplyToTrack(ITrack track) public void ApplyToTrack(IAdjustableAudioComponent track)
{ {
track.AddAdjustment(AdjustableProperty.Volume, mainVolumeAdjust); track.AddAdjustment(AdjustableProperty.Volume, mainVolumeAdjust);
} }

View File

@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Mods
}, true); }, true);
} }
public override void ApplyToTrack(ITrack track) public override void ApplyToTrack(IAdjustableAudioComponent track)
{ {
// base.ApplyToTrack() intentionally not called (different tempo adjustment is applied) // base.ApplyToTrack() intentionally not called (different tempo adjustment is applied)
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust); track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);

View File

@ -3,7 +3,6 @@
using System; using System;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Audio;
@ -15,7 +14,7 @@ namespace osu.Game.Rulesets.Mods
public abstract BindableNumber<double> SpeedChange { get; } public abstract BindableNumber<double> SpeedChange { get; }
public virtual void ApplyToTrack(ITrack track) public virtual void ApplyToTrack(IAdjustableAudioComponent track)
{ {
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange); track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
} }

View File

@ -4,7 +4,6 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -46,7 +45,7 @@ namespace osu.Game.Rulesets.Mods
Precision = 0.01, Precision = 0.01,
}; };
private ITrack track; private IAdjustableAudioComponent track;
protected ModTimeRamp() protected ModTimeRamp()
{ {
@ -55,7 +54,7 @@ namespace osu.Game.Rulesets.Mods
AdjustPitch.BindValueChanged(applyPitchAdjustment); AdjustPitch.BindValueChanged(applyPitchAdjustment);
} }
public void ApplyToTrack(ITrack track) public void ApplyToTrack(IAdjustableAudioComponent track)
{ {
this.track = track; this.track = track;