2019-03-12 18:14:41 +09:00
|
|
|
// 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.
|
|
|
|
|
2019-12-09 19:41:31 +09:00
|
|
|
using osu.Framework.Audio;
|
2019-12-09 17:34:04 +09:00
|
|
|
using osu.Framework.Audio.Track;
|
2019-12-09 19:41:31 +09:00
|
|
|
using osu.Framework.Bindables;
|
2020-09-29 14:09:51 +09:00
|
|
|
using osu.Framework.Graphics.Audio;
|
2019-03-12 18:14:41 +09:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
{
|
2021-01-31 17:43:16 +01:00
|
|
|
public abstract class ModRateAdjust : Mod, IApplicableToRate
|
2019-03-12 18:14:41 +09:00
|
|
|
{
|
2019-12-09 19:41:31 +09:00
|
|
|
public abstract BindableNumber<double> SpeedChange { get; }
|
2019-03-12 18:14:41 +09:00
|
|
|
|
2020-08-06 18:25:34 +09:00
|
|
|
public virtual void ApplyToTrack(ITrack track)
|
2019-03-12 18:14:41 +09:00
|
|
|
{
|
2020-08-12 01:41:21 +09:00
|
|
|
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
|
2019-03-12 18:14:41 +09:00
|
|
|
}
|
2020-03-22 22:57:46 -04:00
|
|
|
|
2020-09-29 14:09:51 +09:00
|
|
|
public virtual void ApplyToSample(DrawableSample sample)
|
2020-06-16 14:58:23 +01:00
|
|
|
{
|
|
|
|
sample.AddAdjustment(AdjustableProperty.Frequency, SpeedChange);
|
|
|
|
}
|
|
|
|
|
2021-01-31 17:43:16 +01:00
|
|
|
public double ApplyToRate(double time, double rate) => rate * SpeedChange.Value;
|
|
|
|
|
2020-03-22 23:08:00 -04:00
|
|
|
public override string SettingDescription => SpeedChange.IsDefault ? string.Empty : $"{SpeedChange.Value:N2}x";
|
2019-03-12 18:14:41 +09:00
|
|
|
}
|
|
|
|
}
|