mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 23:02:56 +08:00
Don't duck music when effect volume is set to zero
Addresses https://github.com/ppy/osu/discussions/28984.
This commit is contained in:
parent
510f2c8ce2
commit
4a3f4c3a55
@ -60,6 +60,8 @@ namespace osu.Game.Overlays
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
private BindableNumber<double> sampleVolume = null!;
|
||||
|
||||
private readonly BindableDouble audioDuckVolume = new BindableDouble(1);
|
||||
|
||||
private AudioFilter audioDuckFilter = null!;
|
||||
@ -69,6 +71,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
||||
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
||||
sampleVolume = audio.VolumeSample.GetBoundCopy();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -269,6 +272,10 @@ namespace osu.Game.Overlays
|
||||
/// <returns>A <see cref="IDisposable"/> which will restore the duck operation when disposed.</returns>
|
||||
public IDisposable Duck(DuckParameters? parameters = null)
|
||||
{
|
||||
// Don't duck if samples have no volume, it sounds weird.
|
||||
if (sampleVolume.Value == 0)
|
||||
return new InvokeOnDisposal(() => { });
|
||||
|
||||
parameters ??= new DuckParameters();
|
||||
|
||||
duckOperations.Add(parameters);
|
||||
@ -302,6 +309,10 @@ namespace osu.Game.Overlays
|
||||
/// <param name="parameters">Parameters defining the ducking operation.</param>
|
||||
public void DuckMomentarily(double delayUntilRestore, DuckParameters? parameters = null)
|
||||
{
|
||||
// Don't duck if samples have no volume, it sounds weird.
|
||||
if (sampleVolume.Value == 0)
|
||||
return;
|
||||
|
||||
parameters ??= new DuckParameters();
|
||||
|
||||
IDisposable duckOperation = Duck(parameters);
|
||||
|
Loading…
Reference in New Issue
Block a user