Skip to content

Instantly share code, notes, and snippets.

@dcragusa
Created August 6, 2019 01:19
Show Gist options
  • Save dcragusa/f3ab67ba1ed692cb628d1ef45dc9fac1 to your computer and use it in GitHub Desktop.
Save dcragusa/f3ab67ba1ed692cb628d1ef45dc9fac1 to your computer and use it in GitHub Desktop.
Various hotkeys to control Voicemeeter Banana
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
WinWait, ahk_exe voicemeeterpro.exe ; wait for voicemeeter
DllLoad := DllCall("LoadLibrary", "Str", "C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")
VMLogin()
OnExit("VMLogout")
; set initial state
global headphone_out = 1
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Bus[0].Gain", "Float", 0.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Bus[1].Gain", "Float", 0.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A1", "Float", 1.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A2", "Float", 0.0)
VMLogin() {
Login := DllCall("VoicemeeterRemote64\VBVMR_Login")
}
VMLogout() {
Logout := DllCall("VoicemeeterRemote64\VBVMR_Logout")
}
ApplyVolume(vol_lvl) {
if (vol_lvl > 12.0){
vol_lvl = 12.0
} else if (vol_lvl < -60.0) {
vol_lvl = -60.0
}
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Bus[0].Gain", "Float", vol_lvl)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Bus[1].Gain", "Float", vol_lvl)
DllCall("VoicemeeterRemote64\VBVMR_IsParametersDirty")
}
; redirect mic 1 to main output, mute mic 2
~V::
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[0].B1", "Float", 1.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[1].Mute", "Float", 1.0)
return
~V Up::
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[0].B1", "Float", 0.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[1].Mute", "Float", 0.0)
return
Volume_Up::
DllCall("VoicemeeterRemote64\VBVMR_IsParametersDirty")
Result := DllCall("VoicemeeterRemote64\VBVMR_GetParameterFloat", "AStr", "Bus[0].Gain", "Ptr", &vol_lvl)
vol_lvl := NumGet(vol_lvl, 0, "Float")
vol_lvl += 1.0
ApplyVolume(vol_lvl)
return
Volume_Down::
DllCall("VoicemeeterRemote64\VBVMR_IsParametersDirty")
Result := DllCall("VoicemeeterRemote64\VBVMR_GetParameterFloat", "AStr", "Bus[0].Gain", "Ptr", &vol_lvl)
vol_lvl := NumGet(vol_lvl, 0, "Float")
vol_lvl -= 1.0
ApplyVolume(vol_lvl)
return
; switch audio devices
XButton2::
if (headphone_out = 1){
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A1", "Float", 0.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A2", "Float", 1.0)
headphone_out = 0
} else {
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A1", "Float", 1.0)
Result := DllCall("VoicemeeterRemote64\VBVMR_SetParameterFloat", "AStr", "Strip[3].A2", "Float", 0.0)
headphone_out = 1
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment