Add functionality for most buttons

This commit is contained in:
2020-05-11 22:34:22 -05:00
parent 32aac7868f
commit ab70c607d6
7 changed files with 1089 additions and 63 deletions

302
VB.ahk
View File

@@ -4,6 +4,7 @@
#HotkeyInterval 99000000
#KeyHistory 0
#UseHook
#Persistent
ListLines Off
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode RegEx
@@ -56,9 +57,203 @@ if (login_result == 1) {
Sleep 2000
}
; == MIDI ==
; ==========
#Include, MIDI\MidiStart.ahk
#Include, MIDI\Midi_In_and_GuiMonitor.ahk ; this file contains: the function to parse midi message into parts we can work with and a midi monitor.
#Include, MIDI\MidiRules.ahk ; this file contains: Rules for manipulating midi input then sending modified midi output.
#Include, MIDI\Midi_under_the_hood.ahk ; this file contains: (DO NOT EDIT THIS FILE) all the dialogs to set up midi ports and midi message handling.
midiCCin:
cc := byte1 ; The Control Channel
val := byte2 ; The value (0-127 for faders, 0 or 1 for buttons (that part is set with the software))
Switch chan
{
Case 1: ; The first fader: Work Laptop Out
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Strip[0]" . ".Gain", Lvl)
Return
Case 1:
Lvl := dial_to_pan(val)
adjustVolLvl("Strip[0]" . ".Pan_x", Lvl)
Case 2:
adjustToggle("Strip[0]" . ".Solo", val)
Return
Case 3:
adjustToggle("Strip[0]" . ".Mute", val)
Return
Case 4:
adjustToggle("Strip[0]" . ".B2", val)
Return
Default:
Return
}
Case 2: ; The second fader: Work Laptop In
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Bus[2]" . ".Gain", Lvl)
Return
Case 3:
adjustToggle("Bus[2]" . ".Mute", val)
Return
Default:
Return
}
Case 3: ; The third fader: Desktop Audio
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Strip[3]" . ".Gain", Lvl)
Return
Case 1:
Lvl := dial_to_pan(val)
adjustVolLvl("Strip[3]" . ".Pan_x", Lvl)
Case 2:
adjustToggle("Strip[3]" . ".Solo", val)
Return
Case 3:
adjustToggle("Strip[3]" . ".Mute", val)
Return
Case 4:
adjustToggle("Strip[3]" . ".B2", val)
Return
Default:
Return
}
Case 4: ; The third fader: Comms In
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Bus[3]" . ".Gain", Lvl)
Return
Case 3:
adjustToggle("Bus[3]" . ".Mute", val)
Return
Default:
Return
}
Case 5: ; The fifth fader: Comms Out
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Strip[4]" . ".Gain", Lvl)
Return
Case 1:
Lvl := dial_to_pan(val)
adjustVolLvl("Strip[4]" . ".Pan_x", Lvl)
Case 2:
adjustToggle("Strip[4]" . ".Solo", val)
Return
Case 3:
adjustToggle("Strip[4]" . ".Mute", val)
Return
Case 4:
adjustToggle("Strip[4]" . ".B2", val)
Return
Default:
Return
}
Case 6: ; The sixth fader: Speakers
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Bus[0]" . ".Gain", Lvl)
Return
Case 3:
adjustToggle("Bus[0]" . ".Mute", val)
Return
Default:
Return
}
Case 7: ; The seventh fader: Mic
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Bus[1]" . ".Gain", Lvl)
Return
Case 3:
adjustToggle("Bus[1]" . ".Mute", val)
Return
Default:
Return
}
Case 8: ; The eighth fader: Music
Switch cc
{
Case 0:
Lvl := fader_to_fader(val)
adjustVolLvl("Strip[2]" . ".Gain", Lvl)
Return
Case 1:
Lvl := dial_to_pan(val)
adjustVolLvl("Strip[2]" . ".Pan_x", Lvl)
Case 2:
adjustToggle("Strip[2]" . ".Solo", val)
Return
Case 3:
adjustToggle("Strip[2]" . ".Mute", val)
Return
Case 4:
adjustToggle("Strip[2]" . ".B1", val)
adjustToggle("Strip[2]" . ".B2", val)
Return
Default:
Return
}
Case 10: ; VoiceMeeter recorder controls
Switch cc
{
Case 7: ; Rewind
adjustToggle("Recorder" . ".REW", val)
Return
Case 8: ; Fast Forward
adjustToggle("Recorder" . ".FF", val)
Return
Case 9:
adjustToggle("Recorder" . ".Stop", val)
Return
Case 10:
adjustToggle("Recorder" . ".Play", val)
Return
Case 11:
adjustToggle("Recorder" . ".Record", val)
Return
Default:
Return
}
Default:
Return
}
Return
fader_to_fader(val) ; Translates MIDI fader values to the VoiceMeeter software faders
{
; The upper limit for faders in VM is 12.0
; The lower limit for the faders in VM that I would like is -40.0, how low it should go when the physical fader is all the way at the bottom
nval := Round(((val / 127) * 52) - 40)
Return nval
}
; Formula: ((value / max value) * total range) - negative part of range
dial_to_pan(val)
{
nval := Round((val / 127) - 0.5, 2)
Return nval
}
; == HOTKEYS ==
; =============
/*
Volume_Up::
If GetKeyState("ScrollLock", "T") ; Control music volume if scroll lock is on
{
@@ -130,51 +325,37 @@ Volume_Down::
}
}
return
*/
Volume_Mute::
If (GetKeyState("Media_Stop")) ; Mutes all output. Basically a kill switch
{
b0M := Round(readParam("Bus[0]" . ".Mute")) ; Speakers
b1M := Round(readParam("Bus[1]" . ".Mute")) ; Headphones
cM := b0M + b1M
b0M := Round(readParam("Bus[0]" . ".Mute")) ; Speakers
b1M := Round(readParam("Bus[1]" . ".Mute")) ; Headphones
cM := b0M + b1M
if (cM = "2")
{ ; Unmute the ones that were unmuted before
adjustMute("Bus[0]" . ".Mute", b0Ms) ; Speakers
adjustMute("Bus[1]" . ".Mute", b1Ms) ; Headphones
} else {
if !(b0M) ; Speakers
{
b0Ms := True
} else {
b0Ms := False
}
if !(b1M) ; Headphones
{
b1Ms := True
} else {
b1Ms := False
}
; Mute
adjustMute("Bus[0]" . ".Mute", "0") ; Speakers
adjustMute("Bus[1]" . ".Mute", "0") ; Headphones
}
Return
if (cM = "2")
{ ; Unmute the ones that were unmuted before
adjustToggle("Bus[0]" . ".Mute", b0Ms) ; Speakers
adjustToggle("Bus[1]" . ".Mute", b1Ms) ; Headphones
} else {
if !(b0M) ; Speakers
{
b0Ms := True
} else {
b0Ms := False
}
if !(b1M) ; Headphones
{
b1Ms := True
} else {
b1Ms := False
}
; Mute
adjustToggle("Bus[0]" . ".Mute", "0") ; Speakers
adjustToggle("Bus[1]" . ".Mute", "0") ; Headphones
}
cM := Round(readParam("Bus[1]" . ".Mute")) ; Toggles between the speakers and headphones being muted, normal operation
if (cM)
{
adjustMute("Bus[0]" . ".Mute", "0") ; Speakers
adjustMute("Bus[1]" . ".Mute", "1") ; Headphones
}
if !(cM)
{
adjustMute("Bus[0]" . ".Mute", "1") ; Speakers
adjustMute("Bus[1]" . ".Mute", "0") ; Headphones
}
return
Return
/*
!m:: ; Mute: No audio out
Send {F23}
b3M := Round(readParam("Bus[3]" . ".Mute")) ; Comms IN
@@ -182,16 +363,16 @@ return
If (s4M)
{
adjustMute("Bus[3]" . ".Mute", "1") ; Comms IN
adjustMute("Strip[4]" . ".Mute", "1") ; Comms OUT
adjustToggle("Bus[3]" . ".Mute", "1") ; Comms IN
adjustToggle("Strip[4]" . ".Mute", "1") ; Comms OUT
return
}
If !(b3M)
{
adjustMute("Bus[3]" . ".Mute", "0")
adjustToggle("Bus[3]" . ".Mute", "0")
} else {
adjustMute("Bus[3]" . ".Mute", "1")
adjustToggle("Bus[3]" . ".Mute", "1")
}
Return
@@ -201,12 +382,12 @@ Return
If (s4M)
{
adjustMute("Bus[3]" . ".Mute", "1") ; Comms IN
adjustMute("Strip[4]" . ".Mute", "1") ; Comms OUT
adjustToggle("Bus[3]" . ".Mute", "1") ; Comms IN
adjustToggle("Strip[4]" . ".Mute", "1") ; Comms OUT
} else {
adjustMute("Bus[3]" . ".Mute", "0") ; Comms IN
adjustToggle("Bus[3]" . ".Mute", "0") ; Comms IN
Sleep, 650 ; Delay so that the "deafened" sound from discord can play
adjustMute("Strip[4]" . ".Mute", "0") ; Comms OUT
adjustToggle("Strip[4]" . ".Mute", "0") ; Comms OUT
}
Return
@@ -216,21 +397,21 @@ Return
if (cM)
{
adjustMute("Bus[2]" . ".Mute", "1") ; Work Laptop
adjustMute("Bus[3]" . ".Mute", "0") ; Comms IN
adjustMute("Strip[3]" . ".Mute", "0") ; Desktop
adjustToggle("Bus[2]" . ".Mute", "1") ; Work Laptop
adjustToggle("Bus[3]" . ".Mute", "0") ; Comms IN
adjustToggle("Strip[3]" . ".Mute", "0") ; Desktop
Sleep, 650 ; Delay so that the "deafened" sound from discord can play
adjustMute("Strip[4]" . ".Mute", "0") ; Comms OUT
adjustToggle("Strip[4]" . ".Mute", "0") ; Comms OUT
}
if !(cM)
{
adjustMute("Bus[2]" . ".Mute", "0") ; Work Laptop
adjustMute("Bus[3]" . ".Mute", "1") ; Comms IN
adjustMute("Strip[4]" . ".Mute", "1") ; Comms OUT
adjustMute("Strip[3]" . ".Mute", "1") ; Desktop
adjustToggle("Bus[2]" . ".Mute", "0") ; Work Laptop
adjustToggle("Bus[3]" . ".Mute", "1") ; Comms IN
adjustToggle("Strip[4]" . ".Mute", "1") ; Comms OUT
adjustToggle("Strip[3]" . ".Mute", "1") ; Desktop
}
Return
*/
; == Functions ==
; ===============
@@ -265,7 +446,7 @@ adjustVolLvl(loc, tVol) {
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", loc, "Float", tVol, "Int")
}
adjustMute(loc, tM) {
adjustToggle(loc, tM) {
if (tM = 0)
tM := 1
else
@@ -273,6 +454,8 @@ adjustMute(loc, tM) {
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", loc, "Float", tM, "Int")
}
add_vmr_function(func_name) {
VMR_FUNCTIONS[func_name] := DllCall("GetProcAddress", "Ptr", VMR_MODULE, "AStr", "VBVMR_" . func_name, "Ptr")
if (ErrorLevel || VMR_FUNCTIONS[func_name] == 0)
@@ -289,4 +472,3 @@ die(die_string:="UNSPECIFIED FATAL ERROR.", exit_status:=254) {
MsgBox 16, FATAL ERROR, %die_string%
ExitApp exit_status
}