As I wanted to test receiving MIDI pitchbend messages, I added the following lines to micropython/usb/usb-device-midi/usb/device/midi.py:
def on_midi_event(self, cin, midi0, midi1, midi2):
ch = midi0 & 0x0F
if cin == _CIN_NOTE_ON:
self.on_note_on(ch, midi1, midi2)
elif cin == _CIN_NOTE_OFF:
self.on_note_off(ch, midi1, midi2)
elif cin == _CIN_CONTROL_CHANGE:
self.on_control_change(ch, midi1, midi2)
elif cin == _CIN_PITCH_BEND: # <------------ Added these 4 lines
# Pitch bend combines two 7-bit values into a 14-bit unsigned integer
value = midi1 | (midi2 << 7)
self.on_pitch_bend(ch, value)
and
def on_pitch_bend(self, channel, value):
pass
To micropython/usb/examples/device/midi_example.py I added these lines:
def on_pitch_bend(self, ch, value):
"""Called when Pitch Bend is received. Value is an integer from 0 to 16383 (8192 is center)."""
normalized = value - 8192
print(f"PitchBend| Ch: {ch:<2} Raw: {value:<5} Relative to center: {normalized}")
Now when I move the pitchbend on my Arturia MiniLab MKII, it spits out a lot of pitchbend messages (every ~1ms). On a serial monitor, I see this:
After this, the Raspberry Pi Pico 2 hangs and I have to hit Thonny's "Stop/Restart backend" button twice to return/reset the Pico to the REPL.
It seems the rapid messages overflow a queue?
Paul
As I wanted to test receiving MIDI pitchbend messages, I added the following lines to micropython/usb/usb-device-midi/usb/device/midi.py:
and
To micropython/usb/examples/device/midi_example.py I added these lines:
Now when I move the pitchbend on my Arturia MiniLab MKII, it spits out a lot of pitchbend messages (every ~1ms). On a serial monitor, I see this:
After this, the Raspberry Pi Pico 2 hangs and I have to hit Thonny's "Stop/Restart backend" button twice to return/reset the Pico to the REPL.
It seems the rapid messages overflow a queue?
Paul