mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:13:18 +08:00
Change SamplePlaybackWithRateMods to use rate calulated from the sample
Replace hardcoded numbers
This commit is contained in:
parent
dbde47fe94
commit
f6d3cd6413
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
@ -90,6 +91,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
|
||||
{
|
||||
GameplayClockContainer gameplayContainer = null;
|
||||
StoryboardSampleInfo sampleInfo = null;
|
||||
TestDrawableStoryboardSample sample = null;
|
||||
|
||||
Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;
|
||||
@ -117,7 +119,7 @@ namespace osu.Game.Tests.Gameplay
|
||||
Child = beatmapSkinSourceContainer
|
||||
});
|
||||
|
||||
beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
|
||||
beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(sampleInfo = new StoryboardSampleInfo("test-sample", 1, 1))
|
||||
{
|
||||
Clock = gameplayContainer.GameplayClock
|
||||
});
|
||||
@ -125,7 +127,10 @@ namespace osu.Game.Tests.Gameplay
|
||||
|
||||
AddStep("start", () => gameplayContainer.Start());
|
||||
|
||||
AddAssert("sample playback rate matches mod rates", () => sample.ChildrenOfType<DrawableSample>().First().AggregateFrequency.Value == expectedRate);
|
||||
AddAssert("sample playback rate matches mod rates", () =>
|
||||
testedMod != null && Precision.AlmostEquals(
|
||||
sample.ChildrenOfType<DrawableSample>().First().AggregateFrequency.Value,
|
||||
((IApplicableToRate)testedMod).ApplyToRate(sampleInfo.StartTime)));
|
||||
}
|
||||
|
||||
private class TestSkin : LegacySkin
|
||||
|
@ -49,10 +49,10 @@ namespace osu.Game.Rulesets.Mods
|
||||
public ModWindDown()
|
||||
{
|
||||
InitialRate.BindValueChanged(val =>
|
||||
FinalRate.Value = Math.Min(FinalRate.Value, val.NewValue - 0.01));
|
||||
FinalRate.Value = Math.Min(FinalRate.Value, val.NewValue - FinalRate.Precision));
|
||||
|
||||
FinalRate.BindValueChanged(val =>
|
||||
InitialRate.Value = Math.Max(InitialRate.Value, val.NewValue + 0.01));
|
||||
InitialRate.Value = Math.Max(InitialRate.Value, val.NewValue + InitialRate.Precision));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,10 @@ namespace osu.Game.Rulesets.Mods
|
||||
public ModWindUp()
|
||||
{
|
||||
InitialRate.BindValueChanged(val =>
|
||||
FinalRate.Value = Math.Max(FinalRate.Value, val.NewValue + 0.01));
|
||||
FinalRate.Value = Math.Max(FinalRate.Value, val.NewValue + FinalRate.Precision));
|
||||
|
||||
FinalRate.BindValueChanged(val =>
|
||||
InitialRate.Value = Math.Min(InitialRate.Value, val.NewValue - 0.01));
|
||||
InitialRate.Value = Math.Min(InitialRate.Value, val.NewValue - InitialRate.Precision));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user