Fix mixer visualiser stealing audio output from global mixer

This commit is contained in:
Bartłomiej Dach
2023-12-26 18:12:17 +01:00
parent 7798dcaecf
commit 28eb229896

View File

@@ -4,7 +4,9 @@
using System;
using ManagedBass;
using ManagedBass.Mix;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
@@ -28,6 +30,7 @@ namespace osu.Framework.Graphics.Visualisation.Audio
private float maxPeak = float.MinValue;
private double lastMaxPeakTime;
private readonly bool isOutputChannel;
private IBindable<bool> usingGlobalMixer = null!;
public AudioChannelDisplay(int channelHandle, bool isOutputChannel = false)
{
@@ -100,13 +103,19 @@ namespace osu.Framework.Graphics.Visualisation.Audio
};
}
[BackgroundDependencyLoader]
private void load(AudioManager audioManager)
{
usingGlobalMixer = audioManager.UsingGlobalMixer.GetBoundCopy();
}
protected override void Update()
{
base.Update();
float[] levels = new float[2];
if (isOutputChannel)
if (isOutputChannel && !usingGlobalMixer.Value)
Bass.ChannelGetLevel(ChannelHandle, levels, 1 / 1000f * sample_window, LevelRetrievalFlags.Stereo);
else
BassMix.ChannelGetLevel(ChannelHandle, levels, 1 / 1000f * sample_window, LevelRetrievalFlags.Stereo);