mirror of
https://github.com/osukey/osukey.git
synced 2025-05-31 10:27:26 +09: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.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -90,6 +91,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
|
public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
|
||||||
{
|
{
|
||||||
GameplayClockContainer gameplayContainer = null;
|
GameplayClockContainer gameplayContainer = null;
|
||||||
|
StoryboardSampleInfo sampleInfo = null;
|
||||||
TestDrawableStoryboardSample sample = null;
|
TestDrawableStoryboardSample sample = null;
|
||||||
|
|
||||||
Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;
|
Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;
|
||||||
@ -117,7 +119,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Child = beatmapSkinSourceContainer
|
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
|
Clock = gameplayContainer.GameplayClock
|
||||||
});
|
});
|
||||||
@ -125,7 +127,10 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
AddStep("start", () => gameplayContainer.Start());
|
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
|
private class TestSkin : LegacySkin
|
||||||
|
@ -49,10 +49,10 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public ModWindDown()
|
public ModWindDown()
|
||||||
{
|
{
|
||||||
InitialRate.BindValueChanged(val =>
|
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 =>
|
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()
|
public ModWindUp()
|
||||||
{
|
{
|
||||||
InitialRate.BindValueChanged(val =>
|
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 =>
|
FinalRate.BindValueChanged(val =>
|
||||||
InitialRate.Value = Math.Min(InitialRate.Value, val.NewValue - 0.01));
|
InitialRate.Value = Math.Min(InitialRate.Value, val.NewValue - InitialRate.Precision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user