MidiToMacro/MidiRules.ahk

71 lines
2.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", "")
}
}
ProcessPC(device, channel, note, velocity) {
}
ProcessPitchBend(device, channel, value) {
}