Skip to content

Commit

Permalink
Update all usages of IApplicableToTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed Feb 11, 2022
1 parent 872a3ca commit c500bcc
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 33 deletions.
4 changes: 3 additions & 1 deletion osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
Expand Down Expand Up @@ -81,8 +82,9 @@ public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod
[BackgroundDependencyLoader]
private void load()
{
var virtualMixer = new AudioMixerVirtual();
foreach (var mod in Mods.OfType<IApplicableToTrack>())
mod.ApplyToTrack(speedAdjustmentTrack);
mod.ApplyToTrack(speedAdjustmentTrack, virtualMixer);

bool isForCurrentRuleset = Beatmap.BeatmapInfo.Ruleset.Equals(Ruleset.RulesetInfo);

Expand Down
7 changes: 4 additions & 3 deletions osu.Game.Tests/Rulesets/Mods/ModTimeRampTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using NUnit.Framework;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void TestModWindUp(double time, double expectedRate)
var beatmap = createSingleSpinnerBeatmap();
var mod = new ModWindUp();
mod.ApplyToBeatmap(beatmap);
mod.ApplyToTrack(track);
mod.ApplyToTrack(track, new AudioMixerVirtual());

seekTrackAndUpdateMod(mod, time);

Expand All @@ -55,7 +56,7 @@ public void TestModWindDown(double time, double expectedRate)
FinalRate = { Value = 0.5 }
};
mod.ApplyToBeatmap(beatmap);
mod.ApplyToTrack(track);
mod.ApplyToTrack(track, new AudioMixerVirtual());

seekTrackAndUpdateMod(mod, time);

Expand All @@ -70,7 +71,7 @@ public void TestZeroDurationMap(double time, double expectedRate)
var beatmap = createSingleObjectBeatmap();
var mod = new ModWindUp();
mod.ApplyToBeatmap(beatmap);
mod.ApplyToTrack(track);
mod.ApplyToTrack(track, new AudioMixerVirtual());

seekTrackAndUpdateMod(mod, time);

Expand Down
5 changes: 4 additions & 1 deletion osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class TestScenePlayerLoader : ScreenTestScene
[Resolved]
private AudioManager audioManager { get; set; }

[Resolved]
private MusicController musicController { get; set; }

[Resolved]
private SessionStatics sessionStatics { get; set; }

Expand Down Expand Up @@ -100,7 +103,7 @@ private void prepareBeatmap()
Beatmap.Value = workingBeatmap;

foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
mod.ApplyToTrack(Beatmap.Value.Track);
mod.ApplyToTrack(Beatmap.Value.Track, musicController.TrackMixer);
}

[Test]
Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Overlays/MusicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ public void ResetTrackAdjustments()
if (allowTrackAdjustments)
{
foreach (var mod in mods.Value.OfType<IApplicableToTrack>())
mod.ApplyToTrack(CurrentTrack);
foreach (var mod in mods.Value.OfType<IApplicableToTrackMixer>())
mod.ApplyToTrackMixer(trackMixer);
mod.ApplyToTrack(CurrentTrack, trackMixer);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading;
using JetBrains.Annotations;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Beatmaps;
Expand Down Expand Up @@ -152,7 +153,8 @@ private void preProcess([NotNull] IEnumerable<Mod> mods, CancellationToken cance
: beatmap.GetPlayableBeatmap(ruleset, playableMods, cancellationToken);

var track = new TrackVirtual(10000);
playableMods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
var mixer = new AudioMixerVirtual();
playableMods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track, mixer));
clockRate = track.Rate;
}

Expand Down
4 changes: 3 additions & 1 deletion osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Linq;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Rulesets.Mods;
Expand Down Expand Up @@ -32,7 +33,8 @@ protected PerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes
protected virtual void ApplyMods(Mod[] mods)
{
var track = new TrackVirtual(10000);
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
var mixer = new AudioMixerVirtual();
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track, mixer));
TimeRate = track.Rate;
}

Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Mods/IApplicableToTrack.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.

using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;

namespace osu.Game.Rulesets.Mods
Expand All @@ -10,6 +11,6 @@ namespace osu.Game.Rulesets.Mods
/// </summary>
public interface IApplicableToTrack : IApplicableMod
{
void ApplyToTrack(ITrack track);
void ApplyToTrack(ITrack track, IAudioMixer mixer);
}
}
15 changes: 0 additions & 15 deletions osu.Game/Rulesets/Mods/IApplicableToTrackMixer.cs

This file was deleted.

3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Mods/ModDaycore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
Expand All @@ -27,7 +28,7 @@ protected ModDaycore()
}, true);
}

public override void ApplyToTrack(ITrack track)
public override void ApplyToTrack(ITrack track, IAudioMixer mixer)
{
// base.ApplyToTrack() intentionally not called (different tempo adjustment is applied)
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Mods/ModNightcore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected ModNightcore()
}, true);
}

public override void ApplyToTrack(ITrack track)
public override void ApplyToTrack(ITrack track, IAudioMixer mixer)
{
// base.ApplyToTrack() intentionally not called (different tempo adjustment is applied)
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Mods/ModRateAdjust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Audio;
Expand All @@ -13,7 +14,7 @@ public abstract class ModRateAdjust : Mod, IApplicableToRate
{
public abstract BindableNumber<double> SpeedChange { get; }

public virtual void ApplyToTrack(ITrack track)
public virtual void ApplyToTrack(ITrack track, IAudioMixer mixer)
{
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
}
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Rulesets/Mods/ModTimeRamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Mixing;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Audio;
Expand Down Expand Up @@ -53,7 +54,7 @@ protected ModTimeRamp()
AdjustPitch.BindValueChanged(applyPitchAdjustment);
}

public void ApplyToTrack(ITrack track)
public void ApplyToTrack(ITrack track, IAudioMixer mixer)
{
this.track = track;

Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,7 @@ public override void OnEntering(IScreen last)
// Todo: In the future, player will receive in a track and will probably not have to worry about this...
musicController.ResetTrackAdjustments();
foreach (var mod in GameplayState.Mods.OfType<IApplicableToTrack>())
mod.ApplyToTrack(musicController.CurrentTrack);
foreach (var mod in GameplayState.Mods.OfType<IApplicableToTrackMixer>())
mod.ApplyToTrackMixer(musicController.TrackMixer);
mod.ApplyToTrack(musicController.CurrentTrack, musicController.TrackMixer);

updateGameplayState();

Expand Down

0 comments on commit c500bcc

Please sign in to comment.