circuitpython: USB MIDI sending extra malformed 1-byte messages in CP 7.x

Firmware

- Adafruit CircuitPython 7.0.0-alpha.3 on 2021-06-03; Adafruit QT Py M0 Haxpress with samd21e18
- Adafruit CircuitPython 7.0.0-alpha.3 on 2021-06-03; Raspberry Pi Pico with rp2040

Code/REPL

import time, usb_midi, adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff
midi = adafruit_midi.MIDI( midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1] )
while True:
    midi.send(NoteOn("A4",10))
    time.sleep(1)
    midi.send(NoteOff("A4"))
    time.sleep(1)

Behavior

Extra “invalid” truncated MIDI message sent for every midi.send().
CircuitPython 6.3.0 does not emit this extra message.

Description

Originally reported in #help-with-circuitpython discord and @dhalbert asked me to submit issue.

In MIDI Monitor on MacOS (11.4 Big Sur), the error looks like this:

This does not appear to affect most MIDI-consuming programs, and some other MIDI listeners like Pocket MIDI do not display the extra truncated messages.

Additional Info

CircuitPython 6.3.0 does not emit this extra message.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I verify this issue was present in 7.0.0-alpha.4 and is now fixed in the CI builds. Tested with RP2040 and SAMD21 builds. Thanks @hathach!

This almost looks like an off-by-one error on a send buffer. Most MIDI USB packets are 4-bytes (cable number, midi status, data1, data2) but it’s like it’s got an extra byte in there that’s being sent out with pre-existing cable number and status byte

If you’re on Windows, MIDI-OX is a good MIDI Monitor. It also will show the issue, in potentially more clarity than MIDI Monitor. It prints out:

90 45 0A
90 0A 00
80 45 00
80 00 00

as seen in the screenshot below. midiox-cp7-midi-issue