-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
44 lines (33 loc) · 1.16 KB
/
__main__.py
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
import voicemeeter
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import time
from PIL import Image
import pystray
import threading
import pkgutil
kind = 'banana'
voicemeeter.launch(kind)
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
VOLUME_DB_SHIFT = -15
def control_voicemeeter_volume():
with voicemeeter.remote(kind) as vmr:
while True:
time.sleep(0.1) # in seconds
new_volume = volume.GetMasterVolumeLevel() + VOLUME_DB_SHIFT
vmr.outputs[0].gain = new_volume # Output A1
vmr.outputs[2].gain = new_volume # Output A3
def exit_app():
icon.stop()
TRAY_TOOLTIP = 'Voicemeeter Volume Control'
TRAY_ICON = 'tray_icon.png'
icon = pystray.Icon(TRAY_TOOLTIP, Image.open(TRAY_ICON), menu=pystray.Menu(
pystray.MenuItem('Exit ' + TRAY_TOOLTIP, exit_app)
))
control_thread = threading.Thread(target=control_voicemeeter_volume, daemon=True)
if __name__ == '__main__':
control_thread.start()
icon.run()