231 lines
8.1 KiB
AutoHotkey
231 lines
8.1 KiB
AutoHotkey
;*************************************************
|
|
;* RULES - MIDI FILTERS
|
|
;*************************************************
|
|
|
|
/*
|
|
The MidiRules section is for mapping MIDI input to actions.
|
|
Alter these functions as required.
|
|
*/
|
|
|
|
ProcessNote(device, channel, note, velocity, isNoteOn) {
|
|
|
|
}
|
|
|
|
ProcessCC(device, channel, cc, value) {
|
|
|
|
;*************************************************
|
|
;* Rotary Knob 1 (Master Volume Control) *
|
|
;*************************************************
|
|
|
|
if (cc = 21) {
|
|
scaled_value := ConvertCCValueToScale(value, 7, 120)
|
|
vol := Round(scaled_value * 100) ; Scale to percentage
|
|
SoundSet, vol, MASTER
|
|
; Minimizing feedback to optimize speed
|
|
DisplayOutput("Volume", vol)
|
|
}
|
|
|
|
if (cc = 0 and value = 1) {
|
|
SoundSet, 1, MASTER, MUTE ; Unmute
|
|
DisplayOutput("Volume Unmuted", "")
|
|
} else if (cc = 0 and value = 0) {
|
|
SoundSet, 0, MASTER, MUTE ; Mute
|
|
DisplayOutput("Volume Muted", "")
|
|
}
|
|
|
|
;*************************************************
|
|
;* Rotary Knob 2 (Mozilla Firefox Volume Control)*
|
|
;*************************************************
|
|
|
|
if (cc = 22) {
|
|
scaled_value := ConvertCCValueToScale(value, 7, 120)
|
|
vol := Round(scaled_value, 2) ; Scale to the range used by nircmd
|
|
; Adjust Firefox volume using nircmd
|
|
Run, nircmd setappvolume firefox.exe %vol%
|
|
; Minimizing feedback to optimize speed
|
|
scaled_value := ConvertCCValueToScale(vol, 0, 127)
|
|
percentage := Round(vol * 100) ; Scale to percentage
|
|
DisplayOutput("Firefox Volume", percentage)
|
|
}
|
|
|
|
if (cc = 1 and value = 1) {
|
|
; Mute Mozilla Firefox
|
|
Run, nircmd muteappvolume firefox.exe 1
|
|
DisplayOutput("Firefox Muted", "")
|
|
} else if (cc = 1 and value = 0) {
|
|
; Unmute Mozilla Firefox
|
|
Run, nircmd muteappvolume firefox.exe 0
|
|
DisplayOutput("Firefox Unmuted", "")
|
|
}
|
|
|
|
;*************************************************
|
|
;* Rotary Knob 3 (Games Volume Control) *
|
|
;*************************************************
|
|
|
|
if (cc = 23) {
|
|
scaled_value := ConvertCCValueToScale(value, 7, 120)
|
|
vol := Round(scaled_value, 2) ; Scale to the range used by nircmd
|
|
; Read the list of game executables from the file
|
|
FileRead, gameList, game_exe_list.txt
|
|
Loop, Parse, gameList, `n, `r
|
|
{
|
|
if (A_LoopField != "") {
|
|
; Adjust game volume using nircmd
|
|
Run, nircmd setappvolume %A_LoopField% %vol%
|
|
}
|
|
}
|
|
; Minimizing feedback to optimize speed
|
|
scaled_value := ConvertCCValueToScale(vol, 0, 127)
|
|
percentage := Round(vol * 100) ; Scale to percentage
|
|
DisplayOutput("Games Volume", percentage)
|
|
}
|
|
|
|
if (cc = 2 and value = 1) {
|
|
; Mute all games
|
|
FileRead, gameList, game_exe_list.txt
|
|
Loop, Parse, gameList, `n, `r
|
|
{
|
|
if (A_LoopField != "") {
|
|
Run, nircmd muteappvolume %A_LoopField% 1
|
|
}
|
|
}
|
|
DisplayOutput("Games Muted", "")
|
|
} else if (cc = 2 and value = 0) {
|
|
; Unmute all games
|
|
FileRead, gameList, game_exe_list.txt
|
|
Loop, Parse, gameList, `n, `r
|
|
{
|
|
if (A_LoopField != "") {
|
|
Run, nircmd muteappvolume %A_LoopField% 0
|
|
}
|
|
}
|
|
DisplayOutput("Games Unmuted", "")
|
|
}
|
|
|
|
; Get the PID of OBS directly
|
|
Process, Exist, obs64.exe
|
|
obsPID := ErrorLevel
|
|
|
|
;*************************************************
|
|
;* Start / Stop Streaming Button (Play Icon) *
|
|
;*************************************************
|
|
|
|
if (cc = 115 && value = 127) {
|
|
DisplayOutput("Streaming Started / Stopped", "")
|
|
PostMessage, 0x100, 0x7D, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F14
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7D, 0, , ahk_pid %obsPID% ; WM_KEYUP F14
|
|
}
|
|
|
|
;**************************************************************
|
|
;* Stop Streaming - Discarding Delay (Stop Solo Mute Button) *
|
|
;**************************************************************
|
|
|
|
if (cc = 105 && value = 127) {
|
|
DisplayOutput("Streaming Started / Stopped", "")
|
|
PostMessage, 0x100, 0x7E, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F15
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7E, 0, , ahk_pid %obsPID% ; WM_KEYUP F15
|
|
}
|
|
|
|
;*************************************************
|
|
;* Start / Stop Recording Button (Record Icon) *
|
|
;*************************************************
|
|
|
|
if (cc = 117 && value = 127) {
|
|
DisplayOutput("Streaming Started / Stopped", "")
|
|
PostMessage, 0x100, 0x7C, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F13
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7C, 0, , ahk_pid %obsPID% ; WM_KEYUP F13
|
|
}
|
|
|
|
;*************************************************
|
|
;* Change Scene All Screens *
|
|
;*************************************************
|
|
|
|
if (cc = 8 && value = 0) {
|
|
DisplayOutput("Changing Scene", "All Screens (With Brainrot)")
|
|
; Press Shift key using Send
|
|
Send, {Shift Down}
|
|
; Press F13 key using PostMessage
|
|
PostMessage, 0x100, 0x7C, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F13
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7C, 0, , ahk_pid %obsPID% ; WM_KEYUP F13
|
|
; Release Shift key using Send
|
|
Send, {Shift Up}
|
|
}
|
|
|
|
;*************************************************
|
|
;* Change Scene Main Screen Only *
|
|
;*************************************************
|
|
|
|
if (cc = 9 && value = 0) {
|
|
DisplayOutput("Changing Scene", "All Screens (No Brainrot)")
|
|
; Press Shift key using Send
|
|
Send, {Shift Down}
|
|
; Press F14 key using PostMessage
|
|
PostMessage, 0x100, 0x7D, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F14
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7D, 0, , ahk_pid %obsPID% ; WM_KEYUP F14
|
|
; Release Shift key using Send
|
|
Send, {Shift Up}
|
|
}
|
|
|
|
;*************************************************
|
|
;* Change Scene Top Left Only *
|
|
;*************************************************
|
|
|
|
if (cc = 10 && value = 0) {
|
|
DisplayOutput("Changing Scene", "Be Right Back")
|
|
; Press Shift key using Send
|
|
Send, {Shift Down}
|
|
; Press F15 key using PostMessage
|
|
PostMessage, 0x100, 0x7E, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F15
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7E, 0, , ahk_pid %obsPID% ; WM_KEYUP F15
|
|
; Release Shift key using Send
|
|
Send, {Shift Up}
|
|
}
|
|
|
|
;*************************************************
|
|
;* Change Scene Bottom Left Only *
|
|
;*************************************************
|
|
|
|
if (cc = 11 && value = 0) {
|
|
DisplayOutput("Changing Scene", "Be Right Back")
|
|
; Press Shift key using Send
|
|
Send, {Shift Down}
|
|
; Press F16 key using PostMessage
|
|
PostMessage, 0x100, 0x7F, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F16
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x7F, 0, , ahk_pid %obsPID% ; WM_KEYUP F16
|
|
; Release Shift key using Send
|
|
Send, {Shift Up}
|
|
}
|
|
|
|
;*************************************************
|
|
;* Change Scene Be Right Back *
|
|
;*************************************************
|
|
|
|
if (cc = 15 && value = 0) {
|
|
DisplayOutput("Changing Scene", "Be Right Back")
|
|
; Press Shift key using Send
|
|
Send, {Shift Down}
|
|
; Press F20 key using PostMessage
|
|
PostMessage, 0x100, 0x84, 0, , ahk_pid %obsPID% ; WM_KEYDOWN F20
|
|
Sleep, 10
|
|
PostMessage, 0x101, 0x84, 0, , ahk_pid %obsPID% ; WM_KEYUP F20
|
|
; Release Shift key using Send
|
|
Send, {Shift Up}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
ProcessPC(device, channel, note, velocity) {
|
|
|
|
}
|
|
|
|
ProcessPitchBend(device, channel, value) {
|
|
|
|
} |