-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm_path.py
More file actions
97 lines (80 loc) · 3.08 KB
/
Copy pathvm_path.py
File metadata and controls
97 lines (80 loc) · 3.08 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""VoiceMeeter path detection — finds DLL and EXE regardless of install location.
Searches the Windows registry, then falls back to common paths.
Supports VoiceMeeter Basic, Banana, and Potato.
"""
import winreg
from pathlib import Path
# Process names for each VoiceMeeter variant (in priority order)
VM_PROCESS_NAMES = [
"voicemeeterpro.exe", # Banana
"voicemeeter8x64.exe", # Potato (64-bit)
"voicemeeter8.exe", # Potato (32-bit)
"voicemeeter.exe", # Basic
]
# Default install paths (fallback if registry fails)
_DEFAULT_DIRS = [
Path(r"C:\Program Files (x86)\VB\Voicemeeter"),
Path(r"C:\Program Files\VB\Voicemeeter"),
]
DLL_NAME = "VoicemeeterRemote64.dll"
def _find_from_registry() -> Path | None:
"""Try to find VoiceMeeter install dir from the Windows registry."""
# VoiceMeeter registers its install path under Uninstall keys
uninstall_key = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
for hive in (winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER):
try:
with winreg.OpenKey(hive, uninstall_key) as key:
i = 0
while True:
try:
subkey_name = winreg.EnumKey(key, i)
i += 1
if "voicemeeter" not in subkey_name.lower() \
and "VB:" not in subkey_name:
continue
with winreg.OpenKey(key, subkey_name) as subkey:
try:
loc, _ = winreg.QueryValueEx(
subkey, "UninstallString")
# UninstallString is like
# "C:\Program Files (x86)\VB\Voicemeeter\uninst..."
p = Path(loc).parent
if (p / DLL_NAME).exists():
return p
except OSError:
pass
except OSError:
break
except OSError:
continue
return None
def find_dll() -> Path | None:
"""Find VoicemeeterRemote64.dll."""
# Try registry first
reg_dir = _find_from_registry()
if reg_dir:
dll = reg_dir / DLL_NAME
if dll.exists():
return dll
# Fallback to default paths
for d in _DEFAULT_DIRS:
dll = d / DLL_NAME
if dll.exists():
return dll
return None
def find_exe() -> Path | None:
"""Find the VoiceMeeter executable (Banana > Potato > Basic)."""
# Try registry first
reg_dir = _find_from_registry()
dirs = ([reg_dir] if reg_dir else []) + _DEFAULT_DIRS
for d in dirs:
for name in VM_PROCESS_NAMES:
exe = d / name
if exe.exists():
return exe
return None
def is_vm_process(process_name: str) -> bool:
"""Check if a process name is any VoiceMeeter variant."""
if not process_name:
return False
return process_name.lower() in VM_PROCESS_NAMES