#NoEnv
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir% ; Until here, this is the default script template
; Get handle to this running script instance
Gui +LastFound
hWnd := WinExist()
; just for convenience, you also could use the "magic numbers" directly
global oscTypeNone := 1
global oscTypeInt := 2
global oscTypeFloat := 4
global oscTypeString := 8
global oscTypeAll := 0xffffffff
; configuration
global GPListenPort := 51345
global RMEListenPort := 41345
global GPSendPort := 51000
global RMESendPort := 42000
global IP := "127.0.0.1"
global MasterVolume := 0.0
global TempVolume := 0.0
global Muted := 0
global ANA2Active := 0.0
; Load DLL and open listener port for RME
DllCall("LoadLibrary", "Str", "OSC2AHK.dll", "Ptr")
DllCall("OSC2AHK.dll\open", UInt, hWnd, UInt, RMEListenPort)
; Get new master volume value when it is dragged in TotalMix
DllCall("OSC2AHK.dll\addListener", AStr, "/1/mastervolume", UInt, 0x1001, UInt, oscTypeFloat)
OnMessage(0x1001,"updateVolume")
; Check to see if GP is running, and launch it if it isn't
Process, Exist, GigPerformer4.exe
if (!errorLevel)
{
; Loads GigPerformer
Run,%A_ProgramFiles%\Gig Performer 4\GigPerformer4.exe
}
else
{
MsgBox,"GP4 already running"
return
}
return
updateVolume(oscType, data, msgID, hwnd)
{
if(oscType = oscTypeFloat)
{
VarSetCapacity(buf, 4, 0)
NumPut(data, buf)
MasterVolume := NumGet(buf,"Float")
; TempVolume := MasterVolume
; Muted := 0
}
}
sendVolume()
{
DllCall("OSC2AHK.dll\sendOscMessageFloat", AStr, IP, UInt, RMESendPort, AStr, "/1/mastervolume", Float, MasterVolume)
}
toggleMute(p_Muted)
{
if (p_Muted = 0)
{
TempVolume := MasterVolume
MasterVolume := 0.0
sendVolume()
; MsgBox,Output muted
Muted = 1
return
} else
{
MasterVolume := TempVolume
sendVolume()
; MsgBox,Output unmuted
Muted = 0
return
}
}
^F1::
DllCall("OSC2AHK.dll\sendOscMessageInt", AStr, IP, UInt, GPSendPort, AStr, "/GigPerformer/SwitchToRack", UInt, 0)
TrayTip,Room Correction,IIR Correction enabled (0ms delay)
return
^F2::
DllCall("OSC2AHK.dll\sendOscMessageInt", AStr, IP, UInt, GPSendPort, AStr, "/GigPerformer/SwitchToRack", UInt, 1)
TrayTip,Room Correction,IIR Natural Phase enabled (7.3ms delay)
return
^F3::
DllCall("OSC2AHK.dll\sendOscMessageInt", AStr, IP, UInt, GPSendPort, AStr, "/GigPerformer/SwitchToRack", UInt, 2)
TrayTip,Room Correction,FIR Correction enabled (131ms delay)
return
; Mute function
^F5::
toggleMute(Muted)
return
; Full volume function
^F6::
MasterVolume := 0.765
sendVolume()
; Increase volume function
^F7::
if (MasterVolume < 1.0)
{
MasterVolume := MasterVolume+0.01
Muted = 0
sendVolume()
}
return
; Decrease volume function
^F8::
if (MasterVolume > 0.0)
{
MasterVolume := MasterVolume-0.01
Muted = 0
sendVolume()
}
return
; Shutdown the script with Shift+ESC
+Esc::
msgbox,OSC functions disabled.
DllCall("OSC2AHK.dll\close",UInt,1)
ExitApp