djipco / webmidi

Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Apache License 2.0
1.53k stars 115 forks source link

Refresh input devices when new device is plugin (Node.js) #271

Open djipco opened 2 years ago

djipco commented 2 years ago

Discussed in https://github.com/djipco/webmidi/discussions/257

Originally posted by **jdlee** May 2, 2022 I'm also having trouble getting this event to fire using the below code: ```js WebMidi.addListener("connected", e => { console.log(e.port.name); }); ``` I was assuming that simply plugging in my midi controller and turning it on would get it to trigger, but maybe i misunderstand?
djipco commented 2 years ago

WEBMIDI.js relies on the jazz-midi module to provide Web MIDI API support on the Node.js platform. It seems that jazz-midi does not dispatch statechange events as it should. We will have to wait for a fix in the dependency. Meanwhile, you can follow the relevant jazz-midi issue (#8) for updates.