1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 08:12:56 +08:00

Add visual tests for Filter

This commit is contained in:
Jamie Taylor 2021-09-29 19:20:05 +09:00
parent 2608d193a9
commit 909f8d1d98
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -0,0 +1,95 @@
// 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.
using ManagedBass.Fx;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Game.Audio.Effects;
using osu.Game.Beatmaps;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Audio
{
public class TestSceneFilter : OsuTestScene
{
[Resolved]
private AudioManager audio { get; set; }
private WorkingBeatmap testBeatmap;
private Filter lowPassFilter;
private Filter highPassFilter;
private Filter bandPassFilter;
[BackgroundDependencyLoader]
private void load()
{
testBeatmap = new WaveformTestBeatmap(audio);
AddRange(new Drawable[]
{
lowPassFilter = new Filter(audio.TrackMixer)
{
FilterType = BQFType.LowPass,
SweepCutoffStart = 2000,
SweepCutoffEnd = 150,
SweepDuration = 1000
},
highPassFilter = new Filter(audio.TrackMixer)
{
FilterType = BQFType.HighPass,
SweepCutoffStart = 150,
SweepCutoffEnd = 2000,
SweepDuration = 1000
},
bandPassFilter = new Filter(audio.TrackMixer)
{
FilterType = BQFType.BandPass,
SweepCutoffStart = 150,
SweepCutoffEnd = 20000,
SweepDuration = 1000
},
});
}
[Test]
public void TestLowPass()
{
testFilter(lowPassFilter);
}
[Test]
public void TestHighPass()
{
testFilter(highPassFilter);
}
[Test]
public void TestBandPass()
{
testFilter(bandPassFilter);
}
private void testFilter(Filter filter)
{
AddStep("Prepare Track", () =>
{
testBeatmap = new WaveformTestBeatmap(audio);
testBeatmap.LoadTrack();
});
AddStep("Play Track", () =>
{
testBeatmap.Track.Start();
});
AddWaitStep("Let track play", 10);
AddStep("Enable Filter", filter.Enable);
AddWaitStep("Let track play", 10);
AddStep("Disable Filter", filter.Disable);
AddWaitStep("Let track play", 10);
AddStep("Stop Track", () =>
{
testBeatmap.Track.Stop();
});
}
}
}