Skip to content

Instantly share code, notes, and snippets.

@Sg4Dylan
Last active January 27, 2022 13:53
Show Gist options
  • Save Sg4Dylan/c3d8ec024c03109ea06e5b966c2ae4cb to your computer and use it in GitHub Desktop.
Save Sg4Dylan/c3d8ec024c03109ea06e5b966c2ae4cb to your computer and use it in GitHub Desktop.
Sync Voicemeeter's gain control to Windows volume control

Install

pip install psutil pycaw future toml
git clone https://github.com/Freemanium/voicemeeter-remote-python
cd voicemeeter-remote-python
pip install .

Modify line 16 of voicemeeter/remote.py

self.delay = 0.015 if delay is None else delay

Modify lines in sync.py

# target voicemeeter edition ('basic', 'banana' or 'potato')
vb_kind = 'banana'
# target input device index (left to right, start with 0)
ch_idx = 4
# Define mapping range (default: -60 ~ +12 dB)
vb_vo = max(min(round(sys_vo*72-60),72),-60)

Run

python sync.py

Demo

demo

#!/usr/bin/env python
#coding:utf-8
# Author: Sg4Dylan --<sg4dylan#gmail.com>
# Created: 12/24/2020
from ctypes import POINTER, cast
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
import voicemeeter
import time
vb_kind = 'banana' # target voicemeeter edition ('basic', 'banana' or 'potato')
ch_idx = 4 # target input device index (left to right, start with 0)
voicemeeter.launch(vb_kind)
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(
IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
def get_system_volume():
return volume.GetMasterVolumeLevelScalar()
with voicemeeter.remote(vb_kind) as vmr:
last_vo = None
while True:
sys_vo = get_system_volume()
vb_vo = max(min(round(sys_vo*72-60),72),-60)
if vb_vo != last_vo:
vmr.inputs[ch_idx].gain = vb_vo
last_vo = vb_vo
time.sleep(1)
@MarshallVisions
Copy link

in 'pip install psutils pycaw future toml' it should be psutil instead of psutils. Other than that, it works!

also for other people trying to get this working, set ch_idx = 0 on line 14 (just like it says to do in the sync.py, which I missed at first) and then go up one at a time till it's syncing the right device (2 was the magic number for me!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment