justinlatimer / node-midi

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

Lost contemporary MIDI message from controller #237

Open glitched0xff opened 6 months ago

glitched0xff commented 6 months ago

Hi folks Thanks for your work. I'm using midi 2.0 npm in nodejs v20.10. I'm having some trouble with this simple code. Seem like that i lost comtemporary message coming from MIDI controller. For example moving modwheel and press a note on keyboard i usually lost the noteOn if the event is in the same time. I try some different controller and the result is the same Here is the simple code bring from documentation

const midi = require('midi');

// Set up a new input.
const input = new midi.Input();

let last
// Count the available input ports.
let inputs=input.getPortCount();
console.log(inputs)
// Get the name of a specified input port.
input.getPortName(0);
for (let i = 0; i < inputs; i++) {
    let name=input.getPortName(i);
    console.log(name)
}

// Configure a callback.
input.on('message',async (deltaTime, message) => {
  if (message!=banMessage[0]){
    console.log(`m: ${message} d: ${deltaTime}`);
    last=message
  }

});

input.openPort(0);
input.ignoreTypes(false, false, false);