Last active
March 17, 2019 13:31
-
-
Save Perlence/4a48a49c62f5871b6c40ce9d9c42d513 to your computer and use it in GitHub Desktop.
FreePIE: Map MIDI notes to keyboard presses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NOTE_TO_KEY = { | |
36: Key.Q, | |
38: Key.W, | |
40: Key.E, | |
41: Key.R, | |
} | |
def update(midi): | |
data = midi.data | |
if data.status not in (MidiStatus.NoteOn, MidiStatus.NoteOff): | |
return | |
note, velocity = data.buffer | |
key = NOTE_TO_KEY.get(note) | |
if key is None: | |
return | |
pressed = data.status == MidiStatus.NoteOn | |
keyboard.setKey(key, pressed) | |
if starting: | |
midi[0].update += lambda: update(midi[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After Pressing Midi, code worked once and then nothin.