mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Initial sample + samplechannel rework
This commit is contained in:
@ -3,11 +3,11 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
@ -19,14 +19,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
public void TestSlidingSampleStopsOnSeek()
|
||||
{
|
||||
DrawableSlider slider = null;
|
||||
DrawableSample[] loopingSamples = null;
|
||||
DrawableSample[] onceOffSamples = null;
|
||||
SkinnableSound[] loopingSamples = null;
|
||||
SkinnableSound[] onceOffSamples = null;
|
||||
|
||||
AddStep("get first slider", () =>
|
||||
{
|
||||
slider = Editor.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First();
|
||||
onceOffSamples = slider.ChildrenOfType<DrawableSample>().Where(s => !s.Looping).ToArray();
|
||||
loopingSamples = slider.ChildrenOfType<DrawableSample>().Where(s => s.Looping).ToArray();
|
||||
onceOffSamples = slider.ChildrenOfType<SkinnableSound>().Where(s => !s.Looping).ToArray();
|
||||
loopingSamples = slider.ChildrenOfType<SkinnableSound>().Where(s => s.Looping).ToArray();
|
||||
});
|
||||
|
||||
AddStep("start playback", () => EditorClock.Start());
|
||||
@ -36,15 +36,15 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
if (!slider.Tracking.Value)
|
||||
return false;
|
||||
|
||||
if (!loopingSamples.Any(s => s.Playing))
|
||||
if (!loopingSamples.Any(s => s.IsPlaying))
|
||||
return false;
|
||||
|
||||
EditorClock.Seek(20000);
|
||||
return true;
|
||||
});
|
||||
|
||||
AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.Played || s.Playing));
|
||||
AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.Played && !s.Playing));
|
||||
AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.IsPlayed || s.IsPlaying));
|
||||
AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.IsPlayed && !s.IsPlaying));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Audio;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
@ -20,14 +19,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
public void TestAllSamplesStopDuringSeek()
|
||||
{
|
||||
DrawableSlider slider = null;
|
||||
DrawableSample[] samples = null;
|
||||
SkinnableSound[] samples = null;
|
||||
ISamplePlaybackDisabler sampleDisabler = null;
|
||||
|
||||
AddUntilStep("get variables", () =>
|
||||
{
|
||||
sampleDisabler = Player;
|
||||
slider = Player.ChildrenOfType<DrawableSlider>().OrderBy(s => s.HitObject.StartTime).FirstOrDefault();
|
||||
samples = slider?.ChildrenOfType<DrawableSample>().ToArray();
|
||||
samples = slider?.ChildrenOfType<SkinnableSound>().ToArray();
|
||||
|
||||
return slider != null;
|
||||
});
|
||||
@ -37,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
if (!slider.Tracking.Value)
|
||||
return false;
|
||||
|
||||
if (!samples.Any(s => s.Playing))
|
||||
if (!samples.Any(s => s.IsPlaying))
|
||||
return false;
|
||||
|
||||
Player.ChildrenOfType<GameplayClockContainer>().First().Seek(40000);
|
||||
|
@ -298,7 +298,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
}
|
||||
@ -321,7 +321,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException();
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
public Sample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();
|
||||
|
||||
|
@ -43,70 +43,52 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestStoppedSoundDoesntResumeAfterPause()
|
||||
{
|
||||
DrawableSample sample = null;
|
||||
AddStep("start sample with looping", () =>
|
||||
{
|
||||
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
|
||||
AddStep("start sample with looping", () => skinnableSound.Looping = true);
|
||||
|
||||
skinnableSound.Looping = true;
|
||||
skinnableSound.Play();
|
||||
});
|
||||
|
||||
AddUntilStep("wait for sample to start playing", () => sample.Playing);
|
||||
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("stop sample", () => skinnableSound.Stop());
|
||||
|
||||
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
|
||||
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
|
||||
|
||||
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
|
||||
|
||||
AddWaitStep("wait a bit", 5);
|
||||
AddAssert("sample not playing", () => !sample.Playing);
|
||||
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoopingSoundResumesAfterPause()
|
||||
{
|
||||
DrawableSample sample = null;
|
||||
AddStep("start sample with looping", () =>
|
||||
{
|
||||
skinnableSound.Looping = true;
|
||||
skinnableSound.Play();
|
||||
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
|
||||
});
|
||||
AddStep("start sample with looping", () => skinnableSound.Looping = true);
|
||||
|
||||
AddUntilStep("wait for sample to start playing", () => sample.Playing);
|
||||
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
|
||||
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
|
||||
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
|
||||
AddUntilStep("wait for sample to start playing", () => sample.Playing);
|
||||
AddUntilStep("wait for sample to start playing", () => skinnableSound.IsPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNonLoopingStopsWithPause()
|
||||
{
|
||||
DrawableSample sample = null;
|
||||
AddStep("start sample", () =>
|
||||
{
|
||||
skinnableSound.Play();
|
||||
sample = skinnableSound.ChildrenOfType<DrawableSample>().First();
|
||||
});
|
||||
AddStep("start sample", () => skinnableSound.Play());
|
||||
|
||||
AddAssert("sample playing", () => sample.Playing);
|
||||
AddAssert("sample playing", () => skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
|
||||
|
||||
AddUntilStep("sample not playing", () => !sample.Playing);
|
||||
AddUntilStep("sample not playing", () => !skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
|
||||
|
||||
AddAssert("sample not playing", () => !sample.Playing);
|
||||
AddAssert("sample not playing", () => !sample.Playing);
|
||||
AddAssert("sample not playing", () => !sample.Playing);
|
||||
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
||||
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
||||
AddAssert("sample not playing", () => !skinnableSound.IsPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -119,10 +101,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
sample = skinnableSound.ChildrenOfType<DrawableSample>().Single();
|
||||
});
|
||||
|
||||
AddAssert("sample playing", () => sample.Playing);
|
||||
AddAssert("sample playing", () => skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("disable sample playback", () => skinSource.SamplePlaybackDisabled.Value = true);
|
||||
AddUntilStep("wait for sample to stop playing", () => !sample.Playing);
|
||||
AddUntilStep("wait for sample to stop playing", () => !skinnableSound.IsPlaying);
|
||||
|
||||
AddStep("trigger skin change", () => skinSource.TriggerSourceChanged());
|
||||
|
||||
@ -133,11 +115,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
return sample != oldSample;
|
||||
});
|
||||
|
||||
AddAssert("new sample stopped", () => !sample.Playing);
|
||||
AddAssert("new sample stopped", () => !skinnableSound.IsPlaying);
|
||||
AddStep("enable sample playback", () => skinSource.SamplePlaybackDisabled.Value = false);
|
||||
|
||||
AddWaitStep("wait a bit", 5);
|
||||
AddAssert("new sample not played", () => !sample.Playing);
|
||||
AddAssert("new sample not played", () => !skinnableSound.IsPlaying);
|
||||
}
|
||||
|
||||
[Cached(typeof(ISkinSource))]
|
||||
@ -155,7 +137,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component) => source?.GetDrawableComponent(component);
|
||||
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source?.GetTexture(componentName, wrapModeS, wrapModeT);
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
|
||||
public Sample GetSample(ISampleInfo sampleInfo) => source?.GetSample(sampleInfo);
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source?.GetConfig<TLookup, TValue>(lookup);
|
||||
|
||||
public void TriggerSourceChanged()
|
||||
|
Reference in New Issue
Block a user