File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -256,13 +256,17 @@ def _keys_and_pixels(
256256 self ._mouse = None
257257
258258 # Define MIDI:
259- self ._midi = adafruit_midi .MIDI (
260- midi_in = usb_midi .ports [0 ],
261- # MIDI uses channels 1-16. CircuitPython uses 0-15. Ergo -1.
262- in_channel = midi_in_channel - 1 ,
263- midi_out = usb_midi .ports [1 ],
264- out_channel = midi_out_channel - 1 ,
265- )
259+ try :
260+ self ._midi = adafruit_midi .MIDI (
261+ midi_in = usb_midi .ports [0 ],
262+ # MIDI uses channels 1-16. CircuitPython uses 0-15. Ergo -1.
263+ in_channel = midi_in_channel - 1 ,
264+ midi_out = usb_midi .ports [1 ],
265+ out_channel = midi_out_channel - 1 ,
266+ )
267+ except IndexError :
268+ # No MIDI ports available.
269+ self ._midi = None
266270
267271 Keycode = Keycode
268272 """
You can’t perform that action at this time.
0 commit comments