Fix MIDI PR files
This commit is contained in:
parent
e52af4f58a
commit
4d1f9e487e
16
docs/midi.md
16
docs/midi.md
@ -8,11 +8,11 @@ keyboard.modules.append(MidiKeys())
|
||||
```
|
||||
## Keycodes
|
||||
|
||||
|Key |Description |
|
||||
|-----------------|------------------------------------------------------------------------|
|
||||
|`KC.MIDI_CC()` |Sends a ControlChange message; accepts two integer arguments of `0`-`15`(controller number) then `0`-`127`(control value) |
|
||||
|`KC.MIDI_NOTE()` |Sends a Note message with both 'On' and 'Off' segments; accepts two integer arguments of `0`-`127`(note number) and `0`-`127`(velocity) |
|
||||
|`KC.MIDI_PB()` |Sends a Pitch Wheel message; accepts a single integer argument of `0`-`16383`, centered on `8192` |
|
||||
|`KC.MIDI_PC()` |Sends a Program Change message; accepts a single integer argument of `0`-`127`(program number) |
|
||||
|`KC.MIDI_START()` |Sends a Start message; accepts no arguments |
|
||||
|`KC.MIDI_STOP()` |Sends a Stop message; accepts no arguments |
|
||||
|Key |Description |
|
||||
|-------------------------------|----------------------------------------------------------|
|
||||
|`KC.MIDI_CC(ctrl, val)` |Sends a ControlChange message |
|
||||
|`KC.MIDI_NOTE(note, velo)` |Sends a Note message |
|
||||
|`KC.MIDI_PB(val)` |Sends a Pitch Wheel message |
|
||||
|`KC.MIDI_PC(program)` |Sends a Program Change message |
|
||||
|`KC.MIDI_START()` |Sends a Start message |
|
||||
|`KC.MIDI_STOP()` |Sends a Stop message |
|
@ -1,11 +1,5 @@
|
||||
# Originally put together by xs5871 on the KMK Firmware Discord/Matrix channel
|
||||
|
||||
import adafruit_midi
|
||||
import usb_midi
|
||||
|
||||
from kmk.modules import Module
|
||||
from kmk.keys import make_argumented_key
|
||||
|
||||
import adafruit_midi
|
||||
from adafruit_midi.control_change import ControlChange
|
||||
from adafruit_midi.note_off import NoteOff
|
||||
from adafruit_midi.note_on import NoteOn
|
||||
@ -14,6 +8,9 @@ from adafruit_midi.program_change import ProgramChange
|
||||
from adafruit_midi.start import Start
|
||||
from adafruit_midi.stop import Stop
|
||||
|
||||
from kmk.keys import make_argumented_key
|
||||
from kmk.modules import Module
|
||||
|
||||
|
||||
class midiNoteValidator:
|
||||
def __init__(self, note=69, velocity=64, channel=None):
|
||||
@ -25,46 +22,44 @@ class midiNoteValidator:
|
||||
class MidiKeys(Module):
|
||||
def __init__(self):
|
||||
make_argumented_key(
|
||||
names=('MIDI_CC',),
|
||||
validator=ControlChange,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
names=('MIDI_CC',),
|
||||
validator=ControlChange,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
|
||||
make_argumented_key(
|
||||
names=('MIDI_NOTE',),
|
||||
validator=midiNoteValidator,
|
||||
on_press=self.note_on,
|
||||
on_release=self.note_off,
|
||||
)
|
||||
names=('MIDI_NOTE',),
|
||||
validator=midiNoteValidator,
|
||||
on_press=self.note_on,
|
||||
on_release=self.note_off,
|
||||
)
|
||||
|
||||
make_argumented_key(
|
||||
names=('MIDI_PB',),
|
||||
validator=PitchBend,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
names=('MIDI_PB',),
|
||||
validator=PitchBend,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
|
||||
make_argumented_key(
|
||||
names=('MIDI_PC',),
|
||||
validator=ProgramChange,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
names=('MIDI_PC',),
|
||||
validator=ProgramChange,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
|
||||
make_argumented_key(
|
||||
names=('MIDI_START',),
|
||||
validator=Start,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
names=('MIDI_START',),
|
||||
validator=Start,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
|
||||
make_argumented_key(
|
||||
names=('MIDI_STOP',),
|
||||
validator=Stop,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
names=('MIDI_STOP',),
|
||||
validator=Stop,
|
||||
on_press=self.on_press,
|
||||
)
|
||||
|
||||
try:
|
||||
self.midi = adafruit_midi.MIDI(
|
||||
midi_out=usb_midi.ports[1], out_channel=0
|
||||
)
|
||||
self.midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0)
|
||||
except IndexError:
|
||||
self.midi = None
|
||||
# if debug_enabled:
|
||||
|
Loading…
Reference in New Issue
Block a user