justinlatimer / node-midi

A node.js wrapper for RtMidi providing MIDI I/O
MIT License
745 stars 118 forks source link

Invalid sendMessage behaviour with multiple messages on MacOs #227

Open avovetisa opened 2 years ago

avovetisa commented 2 years ago

Hi,

On macOS (BigSur, version 11.5.1, with M1 chip, node V16.15 midi V2.0.0), I have the following issue. When Im sending multiple events with sendMessage, some disappear of seems to be corrupted.

With is the code I use const noteOnCh10 = 0x99; const out2 = new midi.Output(); out2.openPort(1); out2.sendMessage([noteOnCh10, 36, 0x64]); out2.sendMessage([noteOnCh10, 38, 0x64]);

This is what I receive (with the debug tool Midi Monitor) 12:21:43.895 To USB20MIDI Note On 10 C1 100 12:21:43.895 To USB20MIDI Invalid 3 bytes

With more messages, I can see other invalid or corrupted messages. If I add a timeout of 3ms between each sendMessage, it solve the issue.

My midi device is a usb-midi to real midi converter, so it is a slow device My question is : Is the sendMessage method wait that the data sent before to send next data ?

Can we have a promise version of sendMessage that ensure that the message is sent before to send another message ?

Thanks you very much.