mirror of https://github.com/ppy/osu
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.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 @@ public void TestSamplePlaybackAtZero()
|
|||
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 @@ public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate
|
|||
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 @@ public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate
|
|||
|
||||
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 @@ public class ModWindDown : ModTimeRamp
|
|||
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 @@ public class ModWindUp : ModTimeRamp
|
|||
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