Permalink
Browse files

Updated README, timestamp -> receivedTime

  • Loading branch information...
1 parent f116b2b commit d340fb17e92c439e13492f06de0691e9f3f23555 @cwilso committed Jul 2, 2013
Showing with 10 additions and 12 deletions.
  1. +8 −9 README.md
  2. +1 −1 WebMIDIAPI.js
  3. +1 −2 index.html
View
17 README.md
@@ -4,31 +4,30 @@ This JS library is a prototype polyfill and shim for the [Web MIDI API](https://
I'm currently using this polyfill to test usability of the API itself, but it's also useful to enable MIDI scenarios.
-This polyfill now supports multiple simultaneous inputs and outputs, and sending and receiving long messages (sysem exclusive). It also properly dispatches events. Timestamps on send and receive should be properly implemented now, although of course timing will not be very precise on send.
+This polyfill now supports multiple simultaneous inputs and outputs, and sending and receiving long messages (sysem exclusive). It also properly dispatches events. Timestamps on send and receive should be properly implemented now, although of course timing will not be very precise on either.
-Jazz doesn't expose the version number or manufacturer, so these are always "<not supported>".
+Jazz doesn't expose the version number or manufacturer, so these are always null.
##Usage
1. Copy the WebMIDIAPI.js file from /lib/ into your project.
2. Add "<script src='lib/WebMIDIAPI.js'></script>" to your code.
-Now you can use the Web MIDI API as captured in the specification (except for the exceptions noted above) - it will automatically check to see if the Web MIDI API is already implemented, and if not it will insert itself.
+You can use the Web MIDI API as captured in the specification - the polyfill will automatically check to see if the Web MIDI API is already implemented, and if not it will insert itself.
So, some sample usage:
var m = null; // m = MIDIAccess object for you to make calls on
- navigator.requestMIDIAccess( onsuccesscallback, onerrorcallback );
+ navigator.requestMIDIAccess().then( onsuccesscallback, onerrorcallback );
function onsuccesscallback( access ) {
m = access;
// Things you can do with the MIDIAccess object:
- var inputs = m.enumerateInputs(); // inputs = array of MIDIPorts
- var outputs = m.enumerateOutputs(); // outputs = array of MIDIPorts
- var i = m.getInput( inputs[0] ); // grab first input device. You can also just call getInput( index );
- i.onmessage = myMIDIMessagehandler; // onmessage( event ), event.data & event.timestamp are populated
- var o = m.getOutput( 0 ); // grab first output device
+ var inputs = m.inputs(); // inputs = array of MIDIPorts
+ var outputs = m.outputs(); // outputs = array of MIDIPorts
+ inputs[0].onmidimessage = myMIDIMessagehandler; // onmidimessage( event ), event.data & event.receivedTime are populated
+ var o = m.outputs()[0]; // grab first output device
o.send( [ 0x90, 0x45, 0x7f ] ); // full velocity note on A4 on channel zero
o.send( [ 0x80, 0x45, 0x7f ], window.performance.now() + 1000 ); // full velocity A4 note off in one second.
};
View
2 WebMIDIAPI.js
@@ -307,7 +307,7 @@
}
var evt = document.createEvent( "Event" );
evt.initEvent( "midimessage", false, false );
- evt.timestamp = parseFloat( timestamp.toString()) + this._jazzInstance._perfTimeZero;
+ evt.receivedTime = parseFloat( timestamp.toString()) + this._jazzInstance._perfTimeZero;
if (isSysexMessage || this._inLongSysexMessage) {
evt.data = new Uint8Array( this._sysexBuffer );
this._sysexBuffer.length = 0;
View
3 index.html
@@ -27,7 +27,6 @@ <h2 id="project_tagline">This is a polyfill using the <a href="http://jazz-soft.
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
- <h2>Forewarning: the spec has recently changed to use Futures. I have not updated the polyfill yet.</h2>
<h3>To use the Web MIDI API Polyfill</h3>
<p>Just include</p>
<pre>&lt;script src='http://cwilso.github.com/WebMIDIAPIShim/WebMIDIAPI.js'&gt;&lt;/script&gt;</pre>
@@ -103,7 +102,7 @@ <h2 id="project_tagline">This is a polyfill using the <a href="http://jazz-soft.
}
function failure( error ) {
- alert( "Oh oh! Did you forget to install the Jazz plugin?");
+ alert( "MIDI failed to start. Did you forget to install the Jazz plugin?");
}
</script>
</body>

0 comments on commit d340fb1

Please sign in to comment.