deckerego / Macropad_4chord_MIDI

A take on the 4chord MIDI project with the Adafruit Macropad
Mozilla Public License 2.0
47 stars 4 forks source link

Notes out of order for 7th chord played autochord mode within Hookpad #42

Closed deckerego closed 1 year ago

deckerego commented 1 year ago

On maybe the 10th measure of a short melody in Hookpad, attempted to send a 7th chord to Hookpad as notes for the melody line. Rather than being recorded in octave order they were recorded randomly (a different sequence after repeated attempts).

No arpeggio delay was configured.

deckerego commented 1 year ago

The lack of arpeggio delay may have done this, since each note would have its own MIDI send command transmitted in rapid succession and would be sent all within a single tick.

Need to confirm we have guaranteed order on the autochord note queue so things are at least transmitted in the correct order on each tick.

deckerego commented 1 year ago

It appears that Python's sort does retain ordering when sorting items of equal value, we were just appending to the queue instead of inserting into the queue (LIFO instead of FIFO). Changed the append to an insert at the head of the list and now MIDI commands seem to be sent in order:

14:08:06.372    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   F2  96
14:08:06.389    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   C3  96
14:08:06.389    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   F3  96
14:08:06.389    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   A3  96
14:08:06.389    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   C4  96
14:08:06.389    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note On 1   D♯4 96
14:08:13.229    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   F2  96
14:08:13.238    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   C3  96
14:08:13.238    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   F3  96
14:08:13.238    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   A3  96
14:08:13.238    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   C4  96
14:08:13.238    From Macropad RP2040 CircuitPython usb_midi.ports[0]    Note Off    1   D♯4 96

Hookpad seems to be happy as well:

image