Last active 1746051107

aly's Avatar aly revised this gist 1746051107. Go to revision

1 file changed, 23 insertions

vmpoll.py(file created)

@@ -0,0 +1,23 @@
1 + #!/usr/bin/env python
2 + import voicemeeterlib # pip install voicemeeter-lib
3 + from subprocess import check_output
4 + from time import sleep
5 + DEBUG = False
6 + DEVICE = "Headphones (Bose QuietComfort 35 Series 2 Stereo)" # TODO update with your device name
7 + CMD = "Get-PnpDevice -presentonly | Where-Object FriendlyName -eq '{}'"
8 + def debug(*msg):
9 + if DEBUG: print(*msg)
10 + while True:
11 + with voicemeeterlib.api('banana') as vm:
12 + bus_device = vm.bus[1].device.name == DEVICE
13 + debug()
14 + debug(bus_device)
15 + if check_output(["powershell", "-Command", CMD.format(DEVICE)]):
16 + if not bus_device: vm.bus[1].device.wdm = DEVICE
17 + debug(True, bus_device)
18 + else:
19 + if bus_device: vm.bus[1].device.wdm = ""
20 + debug(False, bus_device)
21 + bus_device = vm.bus[1].device.name == DEVICE
22 + debug(bus_device)
23 + sleep(1)
Newer Older