Skip to content

Instantly share code, notes, and snippets.

@Perlence
Last active March 17, 2019 13:31
Show Gist options
  • Save Perlence/4a48a49c62f5871b6c40ce9d9c42d513 to your computer and use it in GitHub Desktop.
Save Perlence/4a48a49c62f5871b6c40ce9d9c42d513 to your computer and use it in GitHub Desktop.
FreePIE: Map MIDI notes to keyboard presses
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])
@666noda
Copy link

666noda commented Mar 17, 2019

After Pressing Midi, code worked once and then nothin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment