lots of updating

This commit is contained in:
David Daily 2022-06-21 12:04:45 -05:00
parent 8e3fc209aa
commit 4375fa11d5

248
VB.ahk
View File

@ -25,6 +25,7 @@ if (A_Is64bitOS) {
VMR_DLL_FULL_PATH .= VMR_DLL_FILENAME_32 VMR_DLL_FULL_PATH .= VMR_DLL_FILENAME_32
} }
; == START OF EXECUTION == ; == START OF EXECUTION ==
; ======================== ; ========================
@ -56,6 +57,17 @@ if (login_result == 1) {
Sleep 2000 Sleep 2000
} }
Switch A_Args[1]
{
Case "restart":
adjustToggle("Command.Restart", "1")
Reload ; It doesn't like processing MIDI after we restart VM ¯\_(ツ)_/¯
Return
Case "show":
adjustToggle("Command.Show", "1")
Return
}
; == MIDI == ; == MIDI ==
; ========== ; ==========
#Include, MIDI\MidiStart.ahk #Include, MIDI\MidiStart.ahk
@ -88,6 +100,25 @@ if (login_result == 1) {
midiCCin: midiCCin:
cc := byte1 ; The Control Channel 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)) val := byte2 ; The value (0-127 for faders, 0 or 1 for buttons (that part is set with the software))
nonmusic := "Netflix|YouTube|Corridor" ; Windows to control media in instead of music
; Definitions for the virtual faders
WorkLapR := "Strip[0]."
MicR := "Strip[1]."
PhoneR := "Strip[2]."
;empty := "Strip[3]."
Music := "Strip[4]."
Desktop := "Strip[5]."
CommsR := "Strip[6]."
TelegramR := "Strip[7]."
MicS := "Bus[0]."
Speakers := "Bus[1]."
WorkLapS := "Bus[2]."
PhoneS := "Bus[3]."
TelegramS := "Bus[4]."
CommsS := "Bus[5]."
Switch chan Switch chan
{ {
@ -96,21 +127,21 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[0].Gain", Lvl) ; WL Receive adjustVolLvl(WorkLapR "Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[2].Gain", Lvl) ; WL Send, hardly ever needs adjusted adjustVolLvl(WorkLapS "Gain", Lvl) ; WL Send, hardly ever needs adjusted
Return Return
Case 2: Case 2:
adjustToggle("Strip[0].Solo", val) adjustToggle(WorkLapR "Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Bus[2].Mute", val) ; WL Send mute, if I need to mute it I can just use the fader adjustToggle(WorkLapS "Mute", val) ; WL Send mute, if I need to mute it I can just use the fader
flag("WLsend", val) flag("WLsend", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[0].A4", val) adjustToggle(WorkLapR "A4", val)
Return Return
Default: Default:
Return Return
@ -120,14 +151,22 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[3].Gain", Lvl) adjustVolLvl(PhoneS "Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[2].Gain", Lvl) adjustVolLvl(PhoneR "Gain", Lvl)
Return
Case 2:
If (val)
{
adjustToggle("Command.Restart", val)
Reload ; It doesn't like processing MIDI after we restart VM ¯\_(ツ)_/¯
}
Return
Case 3: Case 3:
adjustToggle("Bus[3].Mute", val) adjustToggle(PhoneS "Mute", val)
adjustToggle("Strip[2].Mute", val) adjustToggle(PhoneR "Mute", val)
Return Return
Default: Default:
Return Return
@ -137,19 +176,19 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[5].Gain", Lvl) adjustVolLvl(Desktop "Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := dial_to_pan(val)
adjustVolLvl("Strip[5].Pan_x", Lvl) adjustVolLvl(Desktop "Pan_x", Lvl)
Case 2: Case 2:
adjustToggle("Strip[5].Solo", val) adjustToggle(Desktop "Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[5].Mute", val) adjustToggle(Desktop "Mute", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[5].A4", val) adjustToggle(Desktop "A4", val)
Return Return
Default: Default:
Return Return
@ -159,19 +198,23 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[6].Gain", Lvl) adjustVolLvl(CommsR "Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := dial_to_pan(val)
adjustVolLvl("Strip[6].Pan_x", Lvl) adjustVolLvl(CommsR "Pan_x", Lvl)
; make Telegram go in the opposite direction
Lvl := dial_to_rev_pan(val)
adjustVolLvl(TelegramR "Pan_x", Lvl)
Case 2: Case 2:
adjustToggle("Strip[6].Solo", val) adjustToggle(CommsR "Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[6].Mute", val) adjustToggle(CommsR "Mute", val)
Return Return
Case 4: Case 4: ; sends Comms recieve and Telegram to Phone
adjustToggle("Strip[6].A4", val) adjustToggle(CommsR "A4", val)
adjustToggle(TelegramR "A4", val)
Return Return
Default: Default:
Return Return
@ -181,22 +224,26 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[5].Gain", Lvl) adjustVolLvl(CommsS "Gain", Lvl)
Return Return
Case 2: ; Push to Talk/Mute Case 2: ; Push to Talk/Mute
if (Round(readParam("Bus[5].Mute"))){ if (readParam(CommsS "Mute"))
adjustToggle("Bus[5].Mute", False) {
adjustToggle(CommsS "Mute", False)
} else { } else {
adjustToggle("Bus[5].Mute", True) adjustToggle(CommsS "Mute", True)
} }
Return Return
Case 3: Case 3:
adjustToggle("Bus[5].Mute", val) adjustToggle(CommsS "Mute", val)
flag("Csend",val) flag("Csend",val)
Return Return
Case 4: ; Send music to Discord Case 4: ; Send music to Discord & Work
adjustToggle("Strip[4].B1", val) adjustToggle(Music "B1", val)
adjustToggle("Strip[4].B2", val) adjustToggle(Music "B2", val)
adjustToggle(Music "A3", val)
adjustToggle(MicR "Mute", val) ; Mic
adjustToggle(PhoneR "Mute", val) ; Phone
if (val) if (val)
{ {
Send {F22} ; Toggle PTT/Voice Activity (Shows up as UNK133 in discord) Send {F22} ; Toggle PTT/Voice Activity (Shows up as UNK133 in discord)
@ -214,10 +261,10 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[0].Gain", Lvl) adjustVolLvl(Speakers "Gain", Lvl)
Return Return
Case 3: Case 3:
adjustToggle("Bus[0].Mute", val) adjustToggle(Speakers "Mute", val)
Return Return
Default: Default:
Return Return
@ -227,14 +274,17 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[1].Gain", Lvl) adjustVolLvl(MicS "Gain", Lvl)
Return
Case 2:
adjustToggle(MicR "Mute", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[1].Mute", val) adjustToggle(MicR "Mute", val)
adjustToggle("Bus[1].Mute", val) adjustToggle(MicS "Mute", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[1].A4", val) adjustToggle(MicR "Mute", val)
Return Return
Default: Default:
Return Return
@ -244,19 +294,19 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[4].Gain", Lvl) adjustVolLvl(Music "Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := dial_to_pan(val)
adjustVolLvl("Strip[4].Pan_x", Lvl) adjustVolLvl(Music "Pan_x", Lvl)
Case 2: Case 2:
adjustToggle("Strip[4].Solo", val) adjustToggle(Music "Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[4].Mute", val) adjustToggle(Music "Mute", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[4].A4", val) adjustToggle(Music "A4", val)
Return Return
Default: Default:
Return Return
@ -267,17 +317,29 @@ midiCCin:
Case 1: ; Media Previous Case 1: ; Media Previous
if (val) if (val)
{ {
Send, {Media_Prev} If (WinActive(nonmusic,, "Music"))
{
Send, {j} ; Skip back
} Else
{
Send, {Media_Prev}
}
} }
Return Return
Case 2: ; Media Next Case 2: ; Media Next
if (val) if (val)
{ {
Send, {Media_Next} If (WinActive(nonmusic,, "Music"))
{
Send, {l} ; skip forward
} Else
{
Send, {Media_Next}
}
} }
Return Return
Case 3: ; Media Play/Pause Case 3: ; Media Play/Pause
If (WinActive("Netflix|YouTube|Corridor",, "Music")) If (WinActive(nonmusic,, "Music"))
{ {
Send, {Space} Send, {Space}
} Else } Else
@ -288,12 +350,32 @@ midiCCin:
Case 4: ; Set button Case 4: ; Set button
if (val) if (val)
{ {
Send {F22} ; Toggle PTT/Voice Activity if (readParam(CommsS "Mute"))
Send {F23 down} {
adjustToggle(CommsS "Mute", False)
remuteC := True
}
if (readParam(WorkLapS "Mute"))
{
adjustToggle(WorkLapS "Mute", False)
remuteW := True
}
Send {F22} ; Toggle PTT/Voice Activity
Send {F23 down} ; PTT
adjustToggle("Recorder.Play", True) adjustToggle("Recorder.Play", True)
} else { } else {
Send {F23 up} if (remuteC)
Send {F22} {
adjustToggle(CommsS "Mute", True)
remuteC := ""
}
if (remuteW)
{
adjustToggle(WorkLapS "Mute", True)
remuteW := ""
}
Send {F23 up} ; PTT
Send {F22} ; Toggle PTT/Voice Activity
adjustToggle("Recorder.Stop", True) adjustToggle("Recorder.Stop", True)
Sleep, 250 Sleep, 250
adjustToggle("Recorder.Stop", True) adjustToggle("Recorder.Stop", True)
@ -349,28 +431,28 @@ Return
; == HOTKEYS == ; == HOTKEYS ==
; ============= ; =============
; (untested) ; (untested cause I don't use them)
Volume_Mute:: Volume_Mute::
b0M := readParam("Bus[0].Mute") ; Speakers b0M := readParam(Speakers "Mute") ; Speakers
b1M := readParam("Bus[1].Mute") ; Headphones b1M := readParam(MicS "Mute") ; Headphones
b2M := readParam("Bus[2].Mute") ; Work Laptop Send b2M := readParam(WorkLapS "Mute") ; Work Laptop Send
b3M := readParam("Bus[3].Mute") ; Comms Send b3M := readParam(PhoneS "Mute") ; Comms Send
b4M := readParam("Bus[4].Mute") ; Recording b4M := readParam(TelegramS "Mute") ; Recording
cM := b0M + b1M + b2M + b3M + b4M cM := b0M + b1M + b2M + b3M + b4M
if (cM = "5") if (cM = "5")
{ ; Unmute the ones that were unmuted before { ; Unmute the ones that were unmuted before
adjustToggle("Bus[0].Mute", b0Ms) ; Speakers adjustToggle(Speakers "Mute", b0Ms) ; Speakers
adjustToggle("Bus[1].Mute", b1Ms) ; Headphones adjustToggle(MicS "Mute", b1Ms) ; Headphones
adjustToggle("Bus[2].Mute", b2Ms) ; Work Laptop Send adjustToggle(WorkLapS "Mute", b2Ms) ; Work Laptop Send
adjustToggle("Bus[3].Mute", b3Ms) ; Comms Send adjustToggle(PhoneS "Mute", b3Ms) ; Comms Send
adjustToggle("Bus[4].Mute", b4Ms) ; Recording adjustToggle(TelegramS "Mute", b4Ms) ; Recording
} else { } else {
adjustToggle("Bus[0].Mute", True) ; Speakers adjustToggle(Speakers "Mute", True) ; Speakers
adjustToggle("Bus[1].Mute", True) ; Headphones adjustToggle(MicS "Mute", True) ; Headphones
adjustToggle("Bus[2].Mute", True) ; Work Laptop Send adjustToggle(WorkLapS "Mute", True) ; Work Laptop Send
adjustToggle("Bus[3].Mute", True) ; Comms Send adjustToggle(PhoneS "Mute", True) ; Comms Send
adjustToggle("Bus[4].Mute", True) ; Recording adjustToggle(TelegramS "Mute", True) ; Recording
b0Ms := b0M b0Ms := b0M
b1Ms := b1M b1Ms := b1M
b2Ms := b2M b2Ms := b2M
@ -380,37 +462,11 @@ Volume_Mute::
} }
Return Return
Volume_Up::
cM := readParam("Strip[3].Mute")
if !(cM)
{
cLvl := readParam("Strip[3].Gain")
if (cLvl != "")
{
cLvl += 1
adjustVolLvl("Strip[3].Gain", cLvl)
}
}
Return
Volume_Down::
cM := readParam("Strip[3].Mute")
if !(cM)
{
cLvl := readParam("Strip[3].Gain")
if (cLvl != "")
{
cLvl -= 1
adjustVolLvl("Strip[3].Gain", cLvl)
}
}
Return
; == Functions == ; == Functions ==
; =============== ; ===============
; I need to redo this function...
flag(loc, val) flag(loc, val)
{ {
Switch loc Switch loc
@ -418,7 +474,7 @@ flag(loc, val)
Case "Csend": ; Comms send Case "Csend": ; Comms send
If !(val) ; Unmuted If !(val) ; Unmuted
{ {
If !(readParam("Bus[2].Mute")) ; WLsend unmuted If (readParam(WorkLapS "Mute")) ; WLsend unmuted
{ {
data := "blink/red" data := "blink/red"
} Else } Else
@ -432,7 +488,7 @@ flag(loc, val)
Case "WLsend": ; WL send Case "WLsend": ; WL send
If !(val) ; Unmuted If !(val) ; Unmuted
{ {
If (readParam("Bus[5].Mute")) ; Comms muted If !(readParam(CommsS "Mute")) ; Comms muted
{ {
data := "blink/red" data := "blink/red"
} Else } Else
@ -446,7 +502,7 @@ flag(loc, val)
Default: Default:
Return Return
} }
run %A_AhkPath% "flag.ahk" %data% Run %A_AhkPath% "flag.ahk" %data%
Return Return
} }
@ -487,6 +543,7 @@ adjustVolLvl(loc, tVol)
adjustToggle(func, togg) adjustToggle(func, togg)
{ {
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "Float", togg, "Int") DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "Float", togg, "Int")
; transition flag logic here?
Return Return
} }
@ -511,6 +568,13 @@ dial_to_pan(val)
Return nval Return nval
} }
dial_to_rev_pan(val) ; Pans in the opposite direction
{
val := Round((val / 127) - 0.5, 2)
val := -val
Return val
}
add_vmr_function(func_name) add_vmr_function(func_name)
{ {