-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (63 loc) · 2.37 KB
/
main.py
File metadata and controls
75 lines (63 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys,os
parent_folder_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(parent_folder_path)
sys.path.append(os.path.join(parent_folder_path, 'lib'))
from flowlauncher import FlowLauncher
import voicemeeterlib
class VoicemeeterDevices(FlowLauncher):
def __init__(self):
self.vm = None
super().__init__()
def connect_voicemeeter(self):
try:
if self.vm is None:
self.vm = voicemeeterlib.api("potato")
self.vm.login()
return True
except:
return False
def list_wdm_devices(self):
try:
if not self.connect_voicemeeter():
return []
wdm_devices = []
for i in range(self.vm.device.outs):
device_info = self.vm.device.output(i)
if device_info["type"].lower() == "wdm":
wdm_devices.append(device_info["name"])
if not wdm_devices:
return [{
"Title": "No WDM output devices detected",
"SubTitle": "Ensure WDM output devices are active in Voicemeeter.",
"IcoPath": "assets/error.png"
}]
return [
{
"Title": device,
"SubTitle": f"Set A1 Bus to {device}",
"IcoPath": "assets/device.png",
"JsonRPCAction": {
"method": "select_wdm_device",
"parameters": [device],
"dontHideAfterAction": False
}
}
for device in wdm_devices
]
except:
return [{"Title": "Error", "SubTitle": "Failed to list WDM devices.", "IcoPath": "assets/error.png"}]
def select_wdm_device(self, device_name):
try:
if not self.connect_voicemeeter():
return False
self.vm.bus[0].device.wdm = device_name
return [{
"Title": "Success!",
"SubTitle": f"Device '{device_name}' set for A1 Bus (WDM).",
}]
except:
return [{"Title": "Error", "SubTitle": "Failed to set WDM device.", "IcoPath": "assets/error.png"}]
def query(self, query):
return self.list_wdm_devices()
if __name__ == "__main__":
VoicemeeterDevices()