mirror of https://github.com/ppy/osu
Allow multiple ducks with same parameters
This commit is contained in:
parent
aa36a844be
commit
3650f3c479
|
@ -56,6 +56,45 @@ public void TestMultipleDucks()
|
|||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucksSameParameters()
|
||||
{
|
||||
var duckParameters = new DuckParameters
|
||||
{
|
||||
DuckVolumeTo = 0.5,
|
||||
};
|
||||
|
||||
IDisposable duckOp1 = null!;
|
||||
IDisposable duckOp2 = null!;
|
||||
|
||||
double normalVolume = 1;
|
||||
|
||||
AddStep("get initial volume", () =>
|
||||
{
|
||||
normalVolume = Game.Audio.Tracks.AggregateVolume.Value;
|
||||
});
|
||||
|
||||
AddStep("duck one", () =>
|
||||
{
|
||||
duckOp1 = Game.MusicController.Duck(duckParameters);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("duck two", () =>
|
||||
{
|
||||
duckOp2 = Game.MusicController.Duck(duckParameters);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("restore two", () => duckOp2.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||
|
||||
AddStep("restore one", () => duckOp1.Dispose());
|
||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDucksReverseOrder()
|
||||
{
|
||||
|
|
|
@ -268,9 +268,6 @@ public IDisposable Duck(DuckParameters? parameters = null)
|
|||
{
|
||||
parameters ??= new DuckParameters();
|
||||
|
||||
if (duckOperations.Contains(parameters))
|
||||
throw new ArgumentException("Ducking has already been applied for the provided parameters.", nameof(parameters));
|
||||
|
||||
duckOperations.Add(parameters);
|
||||
|
||||
DuckParameters volumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo)!;
|
||||
|
|
Loading…
Reference in New Issue