112 lines
3.7 KiB
AutoHotkey
112 lines
3.7 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", "")
|
|
}
|
|
}
|
|
|
|
ProcessPC(device, channel, note, velocity) {
|
|
|
|
}
|
|
|
|
ProcessPitchBend(device, channel, value) {
|
|
|
|
} |