mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 02:53:01 +08:00
Merge pull request #29502 from peppy/no-duck-when-zero-sample-volume
Don't duck music when effect volume is set to zero
This commit is contained in:
commit
4351de7abf
@ -60,6 +60,8 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private RealmAccess realm { get; set; } = null!;
|
private RealmAccess realm { get; set; } = null!;
|
||||||
|
|
||||||
|
private BindableNumber<double> sampleVolume = null!;
|
||||||
|
|
||||||
private readonly BindableDouble audioDuckVolume = new BindableDouble(1);
|
private readonly BindableDouble audioDuckVolume = new BindableDouble(1);
|
||||||
|
|
||||||
private AudioFilter audioDuckFilter = null!;
|
private AudioFilter audioDuckFilter = null!;
|
||||||
@ -69,6 +71,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
AddInternal(audioDuckFilter = new AudioFilter(audio.TrackMixer));
|
||||||
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, audioDuckVolume);
|
||||||
|
sampleVolume = audio.VolumeSample.GetBoundCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
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>
|
/// <returns>A <see cref="IDisposable"/> which will restore the duck operation when disposed.</returns>
|
||||||
public IDisposable Duck(DuckParameters? parameters = null)
|
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();
|
parameters ??= new DuckParameters();
|
||||||
|
|
||||||
duckOperations.Add(parameters);
|
duckOperations.Add(parameters);
|
||||||
@ -302,6 +309,10 @@ namespace osu.Game.Overlays
|
|||||||
/// <param name="parameters">Parameters defining the ducking operation.</param>
|
/// <param name="parameters">Parameters defining the ducking operation.</param>
|
||||||
public void DuckMomentarily(double delayUntilRestore, DuckParameters? parameters = null)
|
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();
|
parameters ??= new DuckParameters();
|
||||||
|
|
||||||
IDisposable duckOperation = Duck(parameters);
|
IDisposable duckOperation = Duck(parameters);
|
||||||
|
Loading…
Reference in New Issue
Block a user