diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-02 09:34:37 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-02 14:39:24 +0100 |
commit | 430466b0e3a4dd762d8c4a44403437691d9d6118 (patch) | |
tree | 6666fa004d6cc48f9fa52af10c4fdd30744e59ba /midi.py | |
parent | ab49963447a3f6ba16fe0a13b3b4761b54b556f4 (diff) |
Added basic LED support for launchpad, removed old MIDI code
Diffstat (limited to 'midi.py')
-rw-r--r-- | midi.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/midi.py b/midi.py deleted file mode 100644 index 7eca87e..0000000 --- a/midi.py +++ /dev/null @@ -1,50 +0,0 @@ -import mido - -lp_key = [[j for j in range(i * 16, i * 16 + 8)] for i in range(0,8)] - -GREEN = 124 -YELLOW = 126 -RED = 3 - -_light_ctrl_msg = mido.Message('note_on', channel=0) -_inport = None -_outport = None - -_callbacks_on_press = dict() -_callbacks_on_release = dict() - -_debug = False - -def midi_init(device_name="Launchpad Mini MIDI 1"): - global _inport, _outport - _inport = mido.open_input(device_name) - _outport = mido.open_output(device_name) - - _inport.callback = _callback - -def button_on(button, colour): - if _debug: print(f"outport: {_outport}") - - if _outport: - msg = _light_ctrl_msg.copy(note=button, velocity=colour) - if _debug: print(f"sending {msg}") - _outport.send(msg) - -def button_off(button): - if _outport: - msg = _light_ctrl_msg.copy(note=button, velocity=0) - _outport.send(msg) - -def on_press(button, function): - _callbacks_on_press[button] = function - -def on_release(button, function): - _callbacks_on_release[button] = function - -def _callback(msg): - if msg.velocity == 0: - if msg.note in _callbacks_on_release: - _callbacks_on_release[msg.note]() - elif msg.velocity == 127: - if msg.note in _callbacks_on_press: - _callbacks_on_press[msg.note]() |