2022-03-11 11:02:02 -06:00
SetWorkingDir , A_MyDocuments \D3K
2020-04-24 22:22:48 -05:00
#SingleInstance force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#UseHook
2020-05-11 22:34:22 -05:00
#Persistent
2020-04-24 22:22:48 -05:00
ListLines Off
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
2021-12-10 08:38:52 -06:00
SetTitleMatchMode , RegEx
StringCaseSense Off
OnExit ( "cleanup_before_exit" )
SetFormat , Float , 0.3
global VMR_FUNCTIONS := {}
global VMR_DLL_DRIVE := "C:"
global VMR_DLL_DIRPATH := "Program Files (x86)\VB\Voicemeeter"
global VMR_DLL_FILENAME_32 := "VoicemeeterRemote.dll"
global VMR_DLL_FILENAME_64 := "VoicemeeterRemote64.dll"
global VMR_DLL_FULL_PATH := VMR_DLL_DRIVE . "\" . VMR_DLL_DIRPATH . "\"
Sleep , 500
if ( A_Is64bitOS ) {
VMR_DLL_FULL_PATH .= VMR_DLL_FILENAME_64
} else {
VMR_DLL_FULL_PATH .= VMR_DLL_FILENAME_32
}
2022-06-21 12:04:45 -05:00
2021-12-10 08:38:52 -06:00
; == START OF EXECUTION ==
; ========================
; Load the VoicemeeterRemote DLL:
; This returns a module handle
global VMR_MODULE := DllCall ( "LoadLibrary" , "Str" , VMR_DLL_FULL_PATH , "Ptr" )
if ( ErrorLevel || VMR_MODULE == 0 )
die ( "Attempt to load VoiceMeeter Remote DLL failed." )
; Populate VMR_FUNCTIONS
add_vmr_function ( "Login" )
add_vmr_function ( "Logout" )
add_vmr_function ( "RunVoicemeeter" )
add_vmr_function ( "SetParameterFloat" )
add_vmr_function ( "GetParameterFloat" )
add_vmr_function ( "IsParametersDirty" )
; "Login" to Voicemeeter, by calling the function in the DLL named 'VBVMR_Login()'...
login_result := DllCall ( VMR_FUNCTIONS [ "Login" ], "Int" )
if ( ErrorLevel || login_result < 0 )
die ( "VoiceMeeter Remote login failed." )
; If the login returns 1, that apparently means that Voicemeeter isn't running,
; so we start it; pass 1 to run Voicemeeter, or 2 for Voicemeeter Banana:
if ( login_result == 1 ) {
DllCall ( VMR_FUNCTIONS [ "RunVoicemeeter" ], "Int" , 2 , "Int" )
if ( ErrorLevel )
die ( "Attempt to run VoiceMeeter failed." )
Sleep 2000
}
2022-06-21 12:04:45 -05:00
Switch A_Args [ 1 ]
{
Case "restart" :
adjustToggle ( "Command.Restart" , "1" )
2023-03-03 23:09:25 -06:00
Reload ; It doesn't like processing MIDI after we send commands to VM ¯\_(ツ)_/¯
2022-06-21 12:04:45 -05:00
Return
Case "show" :
adjustToggle ( "Command.Show" , "1" )
2023-03-03 23:09:25 -06:00
Reload ; It doesn't like processing MIDI after we send commands to VM ¯\_(ツ)_/¯
2022-06-21 12:04:45 -05:00
Return
}
2021-12-10 08:38:52 -06:00
; == 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.
2022-03-14 10:29:56 -05:00
; 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
2021-12-10 08:38:52 -06:00
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))
2022-06-21 12:04:45 -05:00
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]."
2023-03-03 23:09:25 -06:00
;empty := "Strip[3]."
2022-06-21 12:04:45 -05:00
Music := "Strip[4]."
Desktop := "Strip[5]."
CommsR := "Strip[6]."
2023-03-03 23:09:25 -06:00
AlissaR := "Strip[7]."
2022-06-21 12:04:45 -05:00
MicS := "Bus[0]."
Speakers := "Bus[1]."
2023-03-03 23:09:25 -06:00
;empty := "Bus[2]."
2022-06-21 12:04:45 -05:00
PhoneS := "Bus[3]."
2023-03-03 23:09:25 -06:00
WorkLapS := "Bus[4]."
2022-06-21 12:04:45 -05:00
CommsS := "Bus[5]."
2023-03-03 23:09:25 -06:00
AlissaS := "Bus[6]."
2021-12-10 08:38:52 -06:00
Switch chan
{
2022-03-14 10:29:56 -05:00
Case 1 : ; The first fader: Work Laptop
2021-12-10 08:38:52 -06:00
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( WorkLapR "Gain" , Lvl )
2023-03-03 23:09:25 -06:00
adjustVolLvl ( AlissaR "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
Case 1 :
2022-03-14 10:29:56 -05:00
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( WorkLapS "Gain" , Lvl ) ; WL Send, hardly ever needs adjusted
2023-03-03 23:09:25 -06:00
adjustVolLvl ( AlissaS "Gain" , Lvl ) ; Audio sent to Alissa
2022-03-14 10:29:56 -05:00
Return
2021-12-10 08:38:52 -06:00
Case 2 :
2022-06-21 12:04:45 -05:00
adjustToggle ( WorkLapR "Solo" , val )
2023-03-03 23:09:25 -06:00
adjustToggle ( AlissaR "Solo" , val )
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( WorkLapS "Mute" , val ) ; WL Send mute, if I need to mute it I can just use the fader
2022-03-14 10:29:56 -05:00
flag ( "WLsend" , val )
2021-12-10 08:38:52 -06:00
Return
Case 4 :
2023-03-03 23:09:25 -06:00
adjustToggle ( WorkLapR "A4" , val ) ; Sends audio to phone VBAN stream
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
2022-03-14 10:29:56 -05:00
Case 2 : ; The second fader: Phone
2021-12-10 08:38:52 -06:00
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( PhoneS "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
2022-03-14 10:29:56 -05:00
Case 1 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
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
2022-03-14 10:29:56 -05:00
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( PhoneS "Mute" , val )
adjustToggle ( PhoneR "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
Case 3 : ; The third fader: Desktop Audio
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( Desktop "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
Case 1 :
Lvl := dial_to_pan ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( Desktop "Pan_x" , Lvl )
2021-12-10 08:38:52 -06:00
Case 2 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Desktop "Solo" , val )
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Desktop "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
Case 4 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Desktop "A4" , val )
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
2022-03-14 10:29:56 -05:00
Case 4 : ; The fourth fader: Comms Receive
2021-12-10 08:38:52 -06:00
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( CommsR "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
2022-03-14 10:29:56 -05:00
Case 1 :
Lvl := dial_to_pan ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( CommsR "Pan_x" , Lvl )
; make Telegram go in the opposite direction
Lvl := dial_to_rev_pan ( val )
2023-03-03 23:09:25 -06:00
adjustVolLvl ( AlissaR "Pan_x" , Lvl )
2022-03-14 10:29:56 -05:00
Case 2 :
2022-06-21 12:04:45 -05:00
adjustToggle ( CommsR "Solo" , val )
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( CommsR "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
2023-03-03 23:09:25 -06:00
Case 4 : ; sends Comms recieve and Alissa to Phone
2022-06-21 12:04:45 -05:00
adjustToggle ( CommsR "A4" , val )
2023-03-03 23:09:25 -06:00
adjustToggle ( AlissaR "A4" , val )
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
2022-03-14 10:29:56 -05:00
Case 5 : ; The fifth fader: Comms Send
2021-12-10 08:38:52 -06:00
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( CommsS "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
2022-03-14 10:29:56 -05:00
Case 2 : ; Push to Talk/Mute
2022-06-21 12:04:45 -05:00
if ( readParam ( CommsS "Mute" ))
{
adjustToggle ( CommsS "Mute" , False )
2023-03-03 23:09:25 -06:00
flag ( "Csend" , False )
2022-03-14 10:29:56 -05:00
} else {
2022-06-21 12:04:45 -05:00
adjustToggle ( CommsS "Mute" , True )
2023-03-03 23:09:25 -06:00
flag ( "Csend" , True )
2022-03-14 10:29:56 -05:00
}
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( CommsS "Mute" , val )
2022-03-14 10:29:56 -05:00
flag ( "Csend" , val )
2021-12-10 08:38:52 -06:00
Return
2022-06-21 12:04:45 -05:00
Case 4 : ; Send music to Discord & Work
adjustToggle ( Music "B1" , val )
adjustToggle ( Music "B2" , val )
2023-03-03 23:09:25 -06:00
adjustToggle ( Music "A5" , val )
2022-03-14 10:29:56 -05:00
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
}
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
Case 6 : ; The sixth fader: Speakers
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( Speakers "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
2023-03-03 23:09:25 -06:00
Case 1 :
Lvl := fader_to_fader ( val )
adjustVolLvl ( AlissaR "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Speakers "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
2023-03-03 23:09:25 -06:00
Case 4 :
adjustToggle ( AlissaR "Mute" , val )
adjustToggle ( AlissaS "Mute" , val )
Return
2021-12-10 08:38:52 -06:00
Default:
Return
}
Case 7 : ; The seventh fader: Mic
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( MicS "Gain" , Lvl )
Return
Case 2 :
adjustToggle ( MicR "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( MicR "Mute" , val )
adjustToggle ( MicS "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
Case 4 :
2022-06-21 12:04:45 -05:00
adjustToggle ( MicR "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
Case 8 : ; The eighth fader: Music
Switch cc
{
Case 0 :
Lvl := fader_to_fader ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( Music "Gain" , Lvl )
2021-12-10 08:38:52 -06:00
Return
Case 1 :
Lvl := dial_to_pan ( val )
2022-06-21 12:04:45 -05:00
adjustVolLvl ( Music "Pan_x" , Lvl )
2021-12-10 08:38:52 -06:00
Case 2 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Music "Solo" , val )
2021-12-10 08:38:52 -06:00
Return
Case 3 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Music "Mute" , val )
2021-12-10 08:38:52 -06:00
Return
2022-03-14 10:29:56 -05:00
Case 4 :
2022-06-21 12:04:45 -05:00
adjustToggle ( Music "A4" , val )
2021-12-10 08:38:52 -06:00
Return
Default:
Return
}
2022-03-14 10:29:56 -05:00
Case 10 : ; Buttons on the left
2021-12-10 08:38:52 -06:00
Switch cc
{
Case 1 : ; Media Previous
if ( val )
{
2022-06-21 12:04:45 -05:00
If ( WinActive ( nonmusic ,, "Music" ))
{
Send , { j } ; Skip back
} Else
{
Send , { Media_Prev }
}
2021-12-10 08:38:52 -06:00
}
Return
Case 2 : ; Media Next
if ( val )
{
2022-06-21 12:04:45 -05:00
If ( WinActive ( nonmusic ,, "Music" ))
{
Send , { l } ; skip forward
} Else
{
Send , { Media_Next }
}
2021-12-10 08:38:52 -06:00
}
Return
Case 3 : ; Media Play/Pause
2022-06-21 12:04:45 -05:00
If ( WinActive ( nonmusic ,, "Music" ))
2021-12-10 08:38:52 -06:00
{
Send , { Space }
} Else
{
Send , { Media_Play_Pause }
}
Return
2022-03-14 10:29:56 -05:00
Case 4 : ; Set button
2021-12-10 08:38:52 -06:00
if ( val )
{
2022-06-21 12:04:45 -05:00
if ( readParam ( CommsS "Mute" ))
{
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
2022-03-14 10:29:56 -05:00
adjustToggle ( "Recorder.Play" , True )
2021-12-10 08:38:52 -06:00
} else {
2022-06-21 12:04:45 -05:00
if ( remuteC )
{
adjustToggle ( CommsS "Mute" , True )
remuteC := ""
}
if ( remuteW )
{
adjustToggle ( WorkLapS "Mute" , True )
remuteW := ""
}
Send { F23 up } ; PTT
Send { F22 } ; Toggle PTT/Voice Activity
2021-12-10 08:38:52 -06:00
adjustToggle ( "Recorder.Stop" , True )
2022-03-14 10:29:56 -05:00
Sleep , 250
2021-12-10 08:38:52 -06:00
adjustToggle ( "Recorder.Stop" , True )
}
Return
Case 5 : ; <- under Marker / dislike song
if ! ( val )
{
Send { F20 }
}
Return
Case 6 : ; -> under Marker / like song
if ! ( val )
{
Send { F21 }
}
Return
Case 7 : ; Rewind
if ( val )
{
adjustToggle ( "Recorder.REW" , True )
} else {
adjustToggle ( "Recorder.Play" , True )
}
Return
Case 8 : ; Fast Forward
if ( val )
{
adjustToggle ( "Recorder.FF" , True )
} else {
adjustToggle ( "Recorder.Play" , True )
}
Return
Case 9 :
adjustToggle ( "Recorder.Stop" , val )
Return
Case 10 :
adjustToggle ( "Recorder.Play" , val )
Return
Case 11 :
adjustToggle ( "Recorder.Record" , val )
Return
Default:
Gosub , SendCC
Return
}
Default:
Gosub , SendCC
Return
}
Return
; == HOTKEYS ==
; =============
2022-06-21 12:04:45 -05:00
; (untested cause I don't use them)
2021-12-10 08:38:52 -06:00
Volume_Mute::
2022-06-21 12:04:45 -05:00
b0M := readParam ( Speakers "Mute" ) ; Speakers
b1M := readParam ( MicS "Mute" ) ; Headphones
b2M := readParam ( WorkLapS "Mute" ) ; Work Laptop Send
b3M := readParam ( PhoneS "Mute" ) ; Comms Send
2023-03-03 23:09:25 -06:00
b4M := readParam ( AlissaS "Mute" ) ; Recording
2021-12-10 08:38:52 -06:00
cM := b0M + b1M + b2M + b3M + b4M
if ( cM = "5" )
{ ; Unmute the ones that were unmuted before
2022-06-21 12:04:45 -05:00
adjustToggle ( Speakers "Mute" , b0Ms ) ; Speakers
adjustToggle ( MicS "Mute" , b1Ms ) ; Headphones
adjustToggle ( WorkLapS "Mute" , b2Ms ) ; Work Laptop Send
adjustToggle ( PhoneS "Mute" , b3Ms ) ; Comms Send
2023-03-03 23:09:25 -06:00
adjustToggle ( AlissaS "Mute" , b4Ms ) ; Recording
2021-12-10 08:38:52 -06:00
} else {
2022-06-21 12:04:45 -05:00
adjustToggle ( Speakers "Mute" , True ) ; Speakers
adjustToggle ( MicS "Mute" , True ) ; Headphones
adjustToggle ( WorkLapS "Mute" , True ) ; Work Laptop Send
adjustToggle ( PhoneS "Mute" , True ) ; Comms Send
2023-03-03 23:09:25 -06:00
adjustToggle ( AlissaS "Mute" , True ) ; Recording
2021-12-10 08:38:52 -06:00
b0Ms := b0M
b1Ms := b1M
b2Ms := b2M
b3Ms := b3M
b4Ms := b4M
2022-03-14 10:29:56 -05:00
2021-12-10 08:38:52 -06:00
}
Return
; == Functions ==
; ===============
2022-03-14 10:29:56 -05:00
2022-06-21 12:04:45 -05:00
; I need to redo this function...
2022-03-14 10:29:56 -05:00
flag ( loc , val )
{
Switch loc
{
Case "Csend" : ; Comms send
If ! ( val ) ; Unmuted
{
2022-06-21 12:04:45 -05:00
If ( readParam ( WorkLapS "Mute" )) ; WLsend unmuted
2022-03-14 10:29:56 -05:00
{
data := "blink/red"
} Else
{
data := "on/green"
}
} Else
{
data := "off"
}
Case "WLsend" : ; WL send
If ! ( val ) ; Unmuted
{
2022-06-21 12:04:45 -05:00
If ! ( readParam ( CommsS "Mute" )) ; Comms muted
2022-03-14 10:29:56 -05:00
{
data := "blink/red"
} Else
{
data := "on/green"
}
} Else
{
data := "off"
}
Default:
Return
}
2022-06-21 12:04:45 -05:00
Run %A_AhkPath% "flag.ahk" %data%
2022-03-14 10:29:56 -05:00
Return
}
readParam ( loc )
{
2021-12-10 08:38:52 -06:00
Loop
{
pDirty := DLLCall ( VMR_FUNCTIONS [ "IsParametersDirty" ]) ;Check if parameters have changed.
if ( pDirty == 0 ) ;0 = no new paramters.
break
else if ( pDirty < 0 ) ;-1 = error, -2 = no server
return ""
else ;1 = New parameters -> update your display. (this only applies if YOU have a display, couldn't find any code to update VM display which can get off sometimes)
if A_Index > 200
return ""
sleep , 20
}
tParamVal := 0.0
NumPut ( 0.0 , tParamVal , 0 , "Float" )
statusLvl := DllCall ( VMR_FUNCTIONS [ "GetParameterFloat" ], "AStr" , loc , "Ptr" , & tParamVal , "Int" )
2022-03-14 10:29:56 -05:00
tParamVal := Round ( NumGet ( tParamVal , 0 , "Float" )) ; This wasn't originally rounded, which would return 1.000 instead of 1, which is just silly
2021-12-10 08:38:52 -06:00
if ( statusLvl < 0 )
return ""
else
return tParamVal
}
2022-03-14 10:29:56 -05:00
adjustVolLvl ( loc , tVol )
{
2021-12-10 08:38:52 -06:00
if ( tVol > 12.0 )
tVol := 12.0
else if ( tVol < - 60.0 )
tVol := - 60.0
DllCall ( VMR_FUNCTIONS [ "SetParameterFloat" ], "AStr" , loc , "Float" , tVol , "Int" )
2022-03-14 10:29:56 -05:00
Return
2021-12-10 08:38:52 -06:00
}
2022-03-14 10:29:56 -05:00
adjustToggle ( func , togg )
{
2021-12-10 08:38:52 -06:00
DllCall ( VMR_FUNCTIONS [ "SetParameterFloat" ], "AStr" , func , "Float" , togg , "Int" )
2022-06-21 12:04:45 -05:00
; transition flag logic here?
2022-03-14 10:29:56 -05:00
Return
2021-12-10 08:38:52 -06:00
}
2022-03-14 10:29:56 -05:00
adjustString ( func , str )
{
2021-12-10 08:38:52 -06:00
DllCall ( VMR_FUNCTIONS [ "SetParameterFloat" ], "AStr" , func , "AStr" , str , "Str" )
2022-03-14 10:29:56 -05:00
Return
2021-12-10 08:38:52 -06:00
}
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 ) * 72 ) - 60 )
Return nval
}
2022-03-14 10:29:56 -05:00
2021-12-10 08:38:52 -06:00
; Formula: ((value / max value) * total range) - negative part of range
dial_to_pan ( val )
{
nval := Round (( val / 127 ) - 0.5 , 2 )
Return nval
}
2020-05-11 22:34:22 -05:00
2022-06-21 12:04:45 -05:00
dial_to_rev_pan ( val ) ; Pans in the opposite direction
{
val := Round (( val / 127 ) - 0.5 , 2 )
val := - val
Return val
}
2020-05-11 22:34:22 -05:00
2022-03-14 10:29:56 -05:00
add_vmr_function ( func_name )
{
2020-04-24 22:22:48 -05:00
VMR_FUNCTIONS [ func_name ] := DllCall ( "GetProcAddress" , "Ptr" , VMR_MODULE , "AStr" , "VBVMR_" . func_name , "Ptr" )
if ( ErrorLevel || VMR_FUNCTIONS [ func_name ] == 0 )
die ( "Failed to register VMR function " . func_name . "." )
}
2022-03-14 10:29:56 -05:00
cleanup_before_exit ( exit_reason , exit_code )
{
2020-04-24 22:22:48 -05:00
DllCall ( VMR_FUNCTIONS [ "Logout" ], "Int" )
; OnExit functions must return 0 to allow the app to exit.
return 0
}
2022-03-14 10:29:56 -05:00
die ( die_string := "UNSPECIFIED FATAL ERROR." , exit_status := 254 )
{
2020-04-24 22:22:48 -05:00
MsgBox 16 , FATAL ERROR , %die_string%
ExitApp exit_status
2020-10-14 19:14:37 -05:00
}