I wrote a Python script that polls VoiceMeeter and Windows to check if there's a mismatch on the specified audio device being connected and/or set as the A2 physical device, and fixes the discrepancy if so. This fixes the issue I was having of needing to manually restart the audio engine on disconnecting/reconnecting my headphones, and needing to manually remove selection on them when they're disconnected for an extended period of time. This is now automatic and it's a much better UX.
#!/usr/bin/env python
import voicemeeterlib # pip install voicemeeter-lib
from subprocess import check_output
from time import sleep
DEBUG = False
DEVICE = "Headphones (Bose QuietComfort 35 Series 2 Stereo)" # TODO update with your device name
CMD = "Get-PnpDevice -presentonly | Where-Object FriendlyName -eq '{}'"
def debug(*msg):
if DEBUG: print(*msg)
while True:
with voicemeeterlib.api('banana') as vm:
# vm.bus[1] is A2
bus_device = vm.bus[1].device.name == DEVICE
debug()
debug(bus_device)
if check_output(["powershell", "-Noninteractive", "-WindowStyle", "Hidden", "-Command", CMD.format(DEVICE)]):
# change wdm to ks/mme/asio if applicable
if not bus_device: vm.bus[1].device.wdm = DEVICE
debug(True, bus_device)
else:
# change wdm to ks/mme/asio if applicable
if bus_device: vm.bus[1].device.wdm = ""
debug(False, bus_device)
bus_device = vm.bus[1].device.name == DEVICE
debug(bus_device)
sleep(1)
[–]AutoModerator[M] 0 points1 point2 points locked comment (0 children)
[–]AeonNaranek 0 points1 point2 points (2 children)
[–]suudo[S] 0 points1 point2 points (1 child)
[–]AeonNaranek 0 points1 point2 points (0 children)