Closed abudaan closed 9 years ago
Update jazz-midi package to the latest version. It now works with both node.js 0.10.* and 0.12.*
I have tested with version 1.4.2, that is the lateste version right? This is how I tested it on OSX:
npm install jazz-midi
cd node_modules/jazz-midi
node test.js
Works fine on my Mac. Let's move this discussion to http://jazz-soft.org - it's a kind of off-topic here.
Okay let's move this discussion to your forum, although it is not completely off-topic since we want the WebMIDIAPIShim to work with both the browser plugin and the nodejs version of Jazz.
If you move to http://jazz-soft.org, could you leave a link to the topic (or its title) here? Thanks.
James, you can start a new branch or use http://jazz-soft.org/bb/viewtopic.php?f=2&t=898
Sorry it's taken me a few days to get to review this. Thanks for all your work!
No problem, thanks for merging!
Changes
MIDIInput
andMIDIOutput
:id
: now a 64 character string containing hexadecimal charactersstate
: "connected" or "disconnected"connection
: "closed", "pending" or "open"onstatechange
: handler for MIDIConnectionEvent -> opens the device implicitlyaddEventListener("statechange")
: handler for MIDIConnectionEventopen()
: opens the device explicitly -> dispatches MIDIConnectionEventclose()
: closes the device explicitly -> dispatches MIDIConnectionEventMIDIAccess
:onstatechange
: handler for MIDIConnectionEventaddEventListener("statechange")
: handler for MIDIConnectionEventWhen a device is connected or disconnected a
MIDIConnectionEvent
is dispatched from both theMIDIAccess
and theMIDIInput
orMIDIOutput
that has been connected or disconnected.The dispatched events are no longer instances of the generic
Event
, they are instances of the classesMIDIMessageEvent
orMIDIConnectionEvent
.NPM
The polyfill has been setup in es6 modules for better maintainability. I have created a npm package that contains the necessary build tools and scripts. This package updates the web-midi-api package that Sema made earlier; it would be great if Sema updates his version after the merge and then push the updated version to npm. Or maybe it is handier to update the npm package directly from Chris' repository if that is possible?
The jazz-midi package has been added to the dependencies and the primary entry point for the web-midi-api package (index.js) has been updated and moved to the /lib folder. The test.js file has moved to the /examples/nodejs folder. It worked on Linux (Ubuntu 15.04 64bits) but not on OSX and Windows. Also the test script of the jazz-midi package failed on OSX and Windows.
On OSX 10.10.3 with nodejs 0.12.2 I got this error:
On Windows 8.1 with nodejs 0.12.2 I got this error:
Caveats
The methods
open()
andclose()
ofMIDIInput
andMIDIOutput
callMidiInClose()
andMidiOutClose()
respectively on the Jazz instance. On Linux this resulted in a lot of crashes of the plugin, so I decided to open the device upon initialization and leave it open whenclose()
is called. Only the value ofconnection
gets updated whenclose()
oropen()
are called. I got the impression that the plugin crashes a bit more often on Windows as well, so maybe we should implement the same trick for Windows.To keep track of devices being connecting and disconnected I use
OnConnectMidiIn
,OnConnectMidiOut
,OnDisconnectMidiIn
andOnDisconnectMidiOut
. But in the documentation of the Jazz plugin it says: "Monitoring MIDI connections may be a resource-consuming operation. Don't use it unless you really need it.". We might consider polling theMIDIAccess.inputs
andMIDIAccess.outputs
by requestAnimationFrame or setInterval instead.Updates
Currently the
MIDIConnectionEventInit
andMIDIOutput.clear()
are not yet implemented, I will add these as soon as Chrome has implemented them.