Slight logic changes

This commit is contained in:
David Daily 2022-03-14 10:29:56 -05:00
parent aba5e85d32
commit dd4b8fd4df
1 changed files with 153 additions and 80 deletions

233
VB.ahk
View File

@ -63,43 +63,71 @@ if (login_result == 1) {
#Include, MIDI\MidiRules.ahk ; this file contains: Rules for manipulating midi input then sending modified midi output. #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. #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.
; Cases explained so you don't have to go into the korg software:
; Faders (Control Channel 1-8, left to right)
; 0 = Fader
; 1 = Dial
; 2 = S
; 3 = M
; 4 = R
; Other buttons (Control Channel 10)
; 1 = Track <
; 2 = Track >
; 3 = Cycle
; 4 = Marker Set
; 5 = Marker <
; 6 = Marker >
; 7 = <<
; 8 = >>
; 9 = Stop
; 10 = Play
; 11 = Record
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))
Switch chan Switch chan
{ {
Case 1: ; The first fader: Work Laptop Receive Case 1: ; The first fader: Work Laptop
Switch cc Switch cc
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[0].Gain", Lvl) adjustVolLvl("Strip[0].Gain", Lvl) ; WL Receive
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[0].Pan_x", Lvl) adjustVolLvl("Bus[2].Gain", Lvl) ; WL Send, hardly ever needs adjusted
Return
Case 2: Case 2:
adjustToggle("Strip[0].Solo", val) adjustToggle("Strip[0].Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[0].Mute", val) adjustToggle("Bus[2].Mute", val) ; WL Send mute, if I need to mute it I can just use the fader
flag("WLsend", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[0].B2", val) adjustToggle("Strip[0].A4", val)
Return Return
Default: Default:
Return Return
} }
Case 2: ; The second fader: Work Laptop Send Case 2: ; The second fader: Phone
Switch cc Switch cc
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[2].Gain", Lvl) adjustVolLvl("Bus[3].Gain", Lvl)
Return Return
Case 2, 3, 4: Case 1:
adjustToggle("Bus[2].Mute", val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[2].Gain", Lvl)
Case 3:
adjustToggle("Bus[3].Mute", val)
adjustToggle("Strip[2].Mute", val)
Return Return
Default: Default:
Return Return
@ -109,70 +137,74 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[3].Gain", Lvl) adjustVolLvl("Strip[5].Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := dial_to_pan(val)
adjustVolLvl("Strip[3].Pan_x", Lvl) adjustVolLvl("Strip[5].Pan_x", Lvl)
Case 2: Case 2:
adjustToggle("Strip[3].Solo", val) adjustToggle("Strip[5].Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[3].Mute", val) adjustToggle("Strip[5].Mute", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[3].B2", val) adjustToggle("Strip[5].A4", val)
Return Return
Default: Default:
Return Return
} }
Case 4: ; The third fader: Comms Send Case 4: ; The fourth fader: Comms Receive
Switch cc Switch cc
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Bus[3].Gain", Lvl) adjustVolLvl("Strip[6].Gain", Lvl)
Return Return
Case 2: ; PTT Case 1:
if !(val){ Lvl := dial_to_pan(val)
cSendMute := Round(readParam("Bus[3].Mute")) adjustVolLvl("Strip[6].Pan_x", Lvl)
adjustToggle("Bus[3].Mute", False) Case 2:
} else { adjustToggle("Strip[6].Solo", val)
adjustToggle("Bus[3].Mute", cSendMute)
}
Return Return
Case 3: Case 3:
adjustToggle("Bus[3].Mute", val) adjustToggle("Strip[6].Mute", val)
Return Return
Case 4: ; Push to mute Case 4:
if !(val){ adjustToggle("Strip[6].A4", val)
cSendMute := Round(readParam("Bus[3].Mute"))
adjustToggle("Bus[3].Mute", True)
} else {
adjustToggle("Bus[3].Mute", cSendMute)
}
Return Return
Default: Default:
Return Return
} }
Case 5: ; The fifth fader: Comms Receive Case 5: ; The fifth fader: Comms Send
Switch cc Switch cc
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[4].Gain", Lvl) adjustVolLvl("Bus[5].Gain", Lvl)
Return Return
Case 1: Case 2: ; Push to Talk/Mute
Lvl := dial_to_pan(val) if (Round(readParam("Bus[5].Mute"))){
adjustVolLvl("Strip[4].Pan_x", Lvl) adjustToggle("Bus[5].Mute", False)
Case 2: } else {
adjustToggle("Strip[4].Solo", val) adjustToggle("Bus[5].Mute", True)
}
Return Return
Case 3: Case 3:
adjustToggle("Strip[4].Mute", val) adjustToggle("Bus[5].Mute", val)
flag("Csend",val)
Return Return
Case 4: Case 4: ; Send music to Discord
adjustToggle("Strip[4].B1", val)
adjustToggle("Strip[4].B2", val) adjustToggle("Strip[4].B2", val)
if (val)
{
Send {F22} ; Toggle PTT/Voice Activity (Shows up as UNK133 in discord)
Send {F23 down} ; PTT button (Shows up as UNK134 in discord)
} else {
Send {F23 up}
Send {F22} ; Toggle PTT/Voice Activity
}
Return Return
Default: Default:
Return Return
@ -202,7 +234,7 @@ midiCCin:
adjustToggle("Bus[1].Mute", val) adjustToggle("Bus[1].Mute", val)
Return Return
Case 4: Case 4:
adjustToggle("Strip[1].B2", val) adjustToggle("Strip[1].A4", val)
Return Return
Default: Default:
Return Return
@ -212,33 +244,24 @@ midiCCin:
{ {
Case 0: Case 0:
Lvl := fader_to_fader(val) Lvl := fader_to_fader(val)
adjustVolLvl("Strip[2].Gain", Lvl) adjustVolLvl("Strip[4].Gain", Lvl)
Return Return
Case 1: Case 1:
Lvl := dial_to_pan(val) Lvl := dial_to_pan(val)
adjustVolLvl("Strip[2].Pan_x", Lvl) adjustVolLvl("Strip[4].Pan_x", Lvl)
Case 2: Case 2:
adjustToggle("Strip[2].Solo", val) adjustToggle("Strip[4].Solo", val)
Return Return
Case 3: Case 3:
adjustToggle("Strip[2].Mute", val) adjustToggle("Strip[4].Mute", val)
Return Return
Case 4: ; Send audio to Comms out & record Case 4:
adjustToggle("Strip[2].B1", val) adjustToggle("Strip[4].A4", val)
adjustToggle("Strip[2].B2", val)
if (val)
{
Send {F22} ; Toggle PTT/Voice Activity (Shows up as UNK133 in discord)
Send {F23 down} ; PTT button (Shows up as UNK134 in discord)
} else {
Send {F23 up}
Send {F22} ; Toggle PTT/Voice Activity
}
Return Return
Default: Default:
Return Return
} }
Case 10: ; VoiceMeeter recorder controls Case 10: ; Buttons on the left
Switch cc Switch cc
{ {
Case 1: ; Media Previous Case 1: ; Media Previous
@ -254,7 +277,7 @@ midiCCin:
} }
Return Return
Case 3: ; Media Play/Pause Case 3: ; Media Play/Pause
If (WinActive("Netflix|YouTube",, "Music")) If (WinActive("Netflix|YouTube|Corridor",, "Music"))
{ {
Send, {Space} Send, {Space}
} Else } Else
@ -262,17 +285,17 @@ midiCCin:
Send, {Media_Play_Pause} Send, {Media_Play_Pause}
} }
Return Return
Case 4: ; Set button / death sound Case 4: ; Set button
if (val) if (val)
{ {
Send {F22} ; Toggle PTT/Voice Activity Send {F22} ; Toggle PTT/Voice Activity
Send {F23 down} Send {F23 down}
adjustToggle("Recorder.Play", True) ; Temp fix until file loading works adjustToggle("Recorder.Play", True)
} else { } else {
Send {F23 up} Send {F23 up}
Send {F22} Send {F22}
adjustToggle("Recorder.Stop", True) adjustToggle("Recorder.Stop", True)
Sleep, 250 ; Makes sure the playback is reset to the beginning, temp until loading files is possible Sleep, 250
adjustToggle("Recorder.Stop", True) adjustToggle("Recorder.Stop", True)
} }
Return Return
@ -326,13 +349,13 @@ Return
; == HOTKEYS == ; == HOTKEYS ==
; ============= ; =============
; (untested)
Volume_Mute:: Volume_Mute::
b0M := Round(readParam("Bus[0].Mute")) ; Speakers b0M := readParam("Bus[0].Mute") ; Speakers
b1M := Round(readParam("Bus[1].Mute")) ; Headphones b1M := readParam("Bus[1].Mute") ; Headphones
b2M := Round(readParam("Bus[2].Mute")) ; Work Laptop Send b2M := readParam("Bus[2].Mute") ; Work Laptop Send
b3M := Round(readParam("Bus[3].Mute")) ; Comms Send b3M := readParam("Bus[3].Mute") ; Comms Send
b4M := Round(readParam("Bus[4].Mute")) ; Recording b4M := readParam("Bus[4].Mute") ; Recording
cM := b0M + b1M + b2M + b3M + b4M cM := b0M + b1M + b2M + b3M + b4M
if (cM = "5") if (cM = "5")
@ -342,7 +365,6 @@ Volume_Mute::
adjustToggle("Bus[2].Mute", b2Ms) ; Work Laptop Send adjustToggle("Bus[2].Mute", b2Ms) ; Work Laptop Send
adjustToggle("Bus[3].Mute", b3Ms) ; Comms Send adjustToggle("Bus[3].Mute", b3Ms) ; Comms Send
adjustToggle("Bus[4].Mute", b4Ms) ; Recording adjustToggle("Bus[4].Mute", b4Ms) ; Recording
Run %A_AhkPath% "flag.ahk" "off"
} else { } else {
adjustToggle("Bus[0].Mute", True) ; Speakers adjustToggle("Bus[0].Mute", True) ; Speakers
adjustToggle("Bus[1].Mute", True) ; Headphones adjustToggle("Bus[1].Mute", True) ; Headphones
@ -354,12 +376,12 @@ Volume_Mute::
b2Ms := b2M b2Ms := b2M
b3Ms := b3M b3Ms := b3M
b4Ms := b4M b4Ms := b4M
Run %A_AhkPath% "flag.ahk" "s" "red"
} }
Return Return
Volume_Up:: Volume_Up::
cM := Round(readParam("Strip[3].Mute")) cM := readParam("Strip[3].Mute")
if !(cM) if !(cM)
{ {
@ -373,7 +395,7 @@ Volume_Up::
Return Return
Volume_Down:: Volume_Down::
cM := Round(readParam("Strip[3].Mute")) cM := readParam("Strip[3].Mute")
if !(cM) if !(cM)
{ {
@ -388,7 +410,48 @@ Return
; == Functions == ; == Functions ==
; =============== ; ===============
readParam(loc){
flag(loc, val)
{
Switch loc
{
Case "Csend": ; Comms send
If !(val) ; Unmuted
{
If !(readParam("Bus[2].Mute")) ; WLsend unmuted
{
data := "blink/red"
} Else
{
data := "on/green"
}
} Else
{
data := "off"
}
Case "WLsend": ; WL send
If !(val) ; Unmuted
{
If (readParam("Bus[5].Mute")) ; Comms muted
{
data := "blink/red"
} Else
{
data := "on/green"
}
} Else
{
data := "off"
}
Default:
Return
}
run %A_AhkPath% "flag.ahk" %data%
Return
}
readParam(loc)
{
Loop Loop
{ {
pDirty := DLLCall(VMR_FUNCTIONS["IsParametersDirty"]) ;Check if parameters have changed. pDirty := DLLCall(VMR_FUNCTIONS["IsParametersDirty"]) ;Check if parameters have changed.
@ -404,27 +467,33 @@ readParam(loc){
tParamVal := 0.0 tParamVal := 0.0
NumPut(0.0, tParamVal, 0, "Float") NumPut(0.0, tParamVal, 0, "Float")
statusLvl := DllCall(VMR_FUNCTIONS["GetParameterFloat"], "AStr", loc, "Ptr", &tParamVal, "Int") statusLvl := DllCall(VMR_FUNCTIONS["GetParameterFloat"], "AStr", loc, "Ptr", &tParamVal, "Int")
tParamVal := NumGet(tParamVal, 0, "Float") tParamVal := Round(NumGet(tParamVal, 0, "Float")) ; This wasn't originally rounded, which would return 1.000 instead of 1, which is just silly
if (statusLvl < 0) if (statusLvl < 0)
return "" return ""
else else
return tParamVal return tParamVal
} }
adjustVolLvl(loc, tVol) { adjustVolLvl(loc, tVol)
{
if (tVol > 12.0) if (tVol > 12.0)
tVol := 12.0 tVol := 12.0
else if (tVol < -60.0) else if (tVol < -60.0)
tVol := -60.0 tVol := -60.0
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", loc, "Float", tVol, "Int") DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", loc, "Float", tVol, "Int")
Return
} }
adjustToggle(func, togg) { adjustToggle(func, togg)
{
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "Float", togg, "Int") DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "Float", togg, "Int")
Return
} }
adjustString(func, str) { adjustString(func, str)
{
DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "AStr", str, "Str") DllCall(VMR_FUNCTIONS["SetParameterFloat"], "AStr", func, "AStr", str, "Str")
Return
} }
fader_to_fader(val) ; Translates MIDI fader values to the VoiceMeeter software faders fader_to_fader(val) ; Translates MIDI fader values to the VoiceMeeter software faders
@ -434,6 +503,7 @@ fader_to_fader(val) ; Translates MIDI fader values to the VoiceMeeter software f
nval := Round(((val / 127) * 72) - 60) nval := Round(((val / 127) * 72) - 60)
Return nval Return nval
} }
; Formula: ((value / max value) * total range) - negative part of range ; Formula: ((value / max value) * total range) - negative part of range
dial_to_pan(val) dial_to_pan(val)
{ {
@ -442,19 +512,22 @@ dial_to_pan(val)
} }
add_vmr_function(func_name) { add_vmr_function(func_name)
{
VMR_FUNCTIONS[func_name] := DllCall("GetProcAddress", "Ptr", VMR_MODULE, "AStr", "VBVMR_" . func_name, "Ptr") VMR_FUNCTIONS[func_name] := DllCall("GetProcAddress", "Ptr", VMR_MODULE, "AStr", "VBVMR_" . func_name, "Ptr")
if (ErrorLevel || VMR_FUNCTIONS[func_name] == 0) if (ErrorLevel || VMR_FUNCTIONS[func_name] == 0)
die("Failed to register VMR function " . func_name . ".") die("Failed to register VMR function " . func_name . ".")
} }
cleanup_before_exit(exit_reason, exit_code) { cleanup_before_exit(exit_reason, exit_code)
{
DllCall(VMR_FUNCTIONS["Logout"], "Int") DllCall(VMR_FUNCTIONS["Logout"], "Int")
; OnExit functions must return 0 to allow the app to exit. ; OnExit functions must return 0 to allow the app to exit.
return 0 return 0
} }
die(die_string:="UNSPECIFIED FATAL ERROR.", exit_status:=254) { die(die_string:="UNSPECIFIED FATAL ERROR.", exit_status:=254)
{
MsgBox 16, FATAL ERROR, %die_string% MsgBox 16, FATAL ERROR, %die_string%
ExitApp exit_status ExitApp exit_status
} }