Fix: desktop audio slider now controls system volume (WYSIWYG audio)
Push GameAudioVolume to MMDevice.AudioEndpointVolume.MasterVolumeLevelScalar on every change. The slider now controls what Windows sends to the headphones, so the creator hears exactly what the stream carries (minus mic — monitored via meters only, no feedback). 207 tests, 0 warnings.
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using NAudio.CoreAudioApi;
|
||||||
using ytLive.Helpers;
|
using ytLive.Helpers;
|
||||||
using ytLive.Models;
|
using ytLive.Models;
|
||||||
using ytLive.Services;
|
using ytLive.Services;
|
||||||
@@ -612,6 +613,17 @@ public class MainViewModel : ViewModelBase
|
|||||||
_musicPlayer.LocalGain = GameMuted ? 0f : (float)(GameAudioVolume * 0.2);
|
_musicPlayer.LocalGain = GameMuted ? 0f : (float)(GameAudioVolume * 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PushSystemVolume(double volume)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var enumerator = new MMDeviceEnumerator();
|
||||||
|
using var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
|
||||||
|
device.AudioEndpointVolume.MasterVolumeLevelScalar = (float)volume;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Live desktop/game input level (0..1), fed by the mixer's loopback
|
/// <summary>Live desktop/game input level (0..1), fed by the mixer's loopback
|
||||||
/// capture. Read by the game meter, scaled by GameAudioVolume.</summary>
|
/// capture. Read by the game meter, scaled by GameAudioVolume.</summary>
|
||||||
public double GameAudioLevel
|
public double GameAudioLevel
|
||||||
@@ -702,6 +714,7 @@ public class MainViewModel : ViewModelBase
|
|||||||
OnPropertyChanged(nameof(GameMeterFillWidth));
|
OnPropertyChanged(nameof(GameMeterFillWidth));
|
||||||
OnPropertyChanged(nameof(GameMeterBrush));
|
OnPropertyChanged(nameof(GameMeterBrush));
|
||||||
UpdateTraxLocalGain();
|
UpdateTraxLocalGain();
|
||||||
|
PushSystemVolume(clamped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user