- Move sub-routines out of MidiRules, into Midi_In_and_GuiMonitor.
- Add ConvertCCValueToAxis and ConvertCCValue functions.
This commit is contained in:
parent
fec32c6b82
commit
b450a06cc6
|
@ -5,7 +5,7 @@
|
|||
|
||||
/*
|
||||
The MidiRules section is for modifying midi input from some other source.
|
||||
Alter the ProcessNote, ProcessCC, or ProcessPC functions as desired.
|
||||
Alter these functions as required.
|
||||
*/
|
||||
|
||||
; *** New rule handler functions ***
|
||||
|
@ -28,47 +28,16 @@ ProcessNote(device, channel, note, velocity, isNoteOn) {
|
|||
ProcessCC(device, channel, cc, value) {
|
||||
global AxisMax_X, max_cc_val, iInterface, HID_USAGE_X
|
||||
if (cc == 7) {
|
||||
tmp_axis_val := Floor((value / max_cc_val) * AxisMax_X)
|
||||
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_X)
|
||||
DisplayOutput("Axis X", value)
|
||||
new_axis_value := ConvertCCValueToAxis(value, 127, AxisMax_X)
|
||||
VJoy_SetAxis(new_axis_value, iInterface, HID_USAGE_X)
|
||||
DisplayOutput("Axis X", ConvertCCValue(value, 127))
|
||||
}
|
||||
}
|
||||
|
||||
ProcessPC(device, channel, note, velocity) {
|
||||
}
|
||||
|
||||
MidiRules:
|
||||
if (statusbyte between 128 and 143) { ; Note off
|
||||
ProcessNote(0, statusbyte - 127, byte1, byte2, false)
|
||||
}
|
||||
if (statusbyte between 144 and 159) { ; Note on
|
||||
ProcessNote(0, statusbyte - 127, byte1, byte2, true)
|
||||
}
|
||||
if (statusbyte between 176 and 191) { ; CC
|
||||
ProcessCC(0, statusbyte - 175, byte1, byte2)
|
||||
}
|
||||
if (statusbyte between 192 and 208) { ; PC
|
||||
ProcessPC(0, statusbyte - 191, byte1, byte2)
|
||||
}
|
||||
; Maybe TODO: Key aftertouch, channel aftertouch, pitch wheel
|
||||
Return
|
||||
|
||||
;*************************************************
|
||||
;* MIDI OUTPUT LABELS TO CALL
|
||||
;*************************************************
|
||||
|
||||
SendNote: ;(h_midiout,Note) ; send out note messages ; this should probably be a funciton
|
||||
note = %byte1% ; this var is added to allow transpostion of a note
|
||||
midiOutShortMsg(h_midiout, statusbyte, note, byte2) ; call the midi funcitons with these params.
|
||||
gosub, ShowMidiOutMessage
|
||||
Return
|
||||
|
||||
SendCC:
|
||||
midiOutShortMsg(h_midiout, statusbyte, cc, byte2)
|
||||
Return
|
||||
|
||||
SendPC:
|
||||
gosub, ShowMidiOutMessage
|
||||
midiOutShortMsg(h_midiout, statusbyte, pc, byte2)
|
||||
Return
|
||||
ProcessPitchBend(device, channel, value) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -92,4 +92,45 @@ Gui,14:Add, ListView, x5 r11 w220 Backgroundblack caqua Count10 vIn1, EventType
|
|||
gui,14:Add, ListView, x+5 r11 w220 Backgroundblack cyellow Count10 vOut1, Event|Value|
|
||||
gui,14:Show, autosize xcenter y5, MidiMonitor
|
||||
|
||||
Return
|
||||
Return
|
||||
|
||||
|
||||
;*************************************************
|
||||
;* MIDI OUTPUT LABELS TO CALL
|
||||
;*************************************************
|
||||
|
||||
SendNote: ;(h_midiout,Note) ; send out note messages ; this should probably be a funciton
|
||||
note = %byte1% ; this var is added to allow transpostion of a note
|
||||
midiOutShortMsg(h_midiout, statusbyte, note, byte2) ; call the midi funcitons with these params.
|
||||
gosub, ShowMidiOutMessage
|
||||
Return
|
||||
|
||||
SendCC:
|
||||
midiOutShortMsg(h_midiout, statusbyte, cc, byte2)
|
||||
Return
|
||||
|
||||
SendPC:
|
||||
gosub, ShowMidiOutMessage
|
||||
midiOutShortMsg(h_midiout, statusbyte, pc, byte2)
|
||||
Return
|
||||
|
||||
; MIDI Rules dispatcher
|
||||
|
||||
MidiRules:
|
||||
if (statusbyte between 128 and 143) { ; Note off
|
||||
ProcessNote(0, chan, byte1, byte2, false)
|
||||
}
|
||||
if (statusbyte between 144 and 159) { ; Note on
|
||||
ProcessNote(0, chan, byte1, byte2, true)
|
||||
}
|
||||
if (statusbyte between 176 and 191) { ; CC
|
||||
ProcessCC(0, chan, byte1, byte2)
|
||||
}
|
||||
if (statusbyte between 192 and 208) { ; PC
|
||||
ProcessPC(0, chan, byte1, byte2)
|
||||
}
|
||||
if (statusbyte between 224 and 239) { ; Pitch bend
|
||||
ProcessPitchBend(0, chan, pitchb)
|
||||
}
|
||||
; Maybe TODO: Key aftertouch, channel aftertouch,
|
||||
Return
|
||||
|
|
|
@ -12,4 +12,15 @@ DisplayOutput(event, value) {
|
|||
{
|
||||
LV_Delete(1)
|
||||
}
|
||||
}
|
||||
|
||||
ConvertCCValueToAxis(value, maximum_value, maximum_axis_value) {
|
||||
return Floor(ConvertCCValue(value, maximum_value) * maximum_axis_value)
|
||||
}
|
||||
|
||||
ConvertCCValue(value, maximum_value) {
|
||||
if (value > maximum_value) {
|
||||
value := maximum_value
|
||||
}
|
||||
return (value / maximum_value)
|
||||
}
|
Loading…
Reference in New Issue
Block a user