text: !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.midibus=n.midibus||{})}(this,function(n){"use strict";function e(n){return n=n||Object.create(null),{on:function(e,t){(n[e]||(n[e]=[])).push(t)},off:function(e,t){var o=n[e]||(n[e]=[]);o.splice(o.indexOf(t)>>>0,1)},emit:function(e,t){(n[e]||[]).map(function(n){n(t)}),(n["*"]||[]).map(function(n){n(e,t)})}}}function t(n,e,t){return{channel:n,pitch:e,velocity:t}}function o(n,e){function o(n){var e=n.data[0]>>4,o=t(15&n.data[0],n.data[1],n.data[2]);8===e||9===e&&0===o.velocity?f.emit("noteOff",o):9===e?f.emit("noteOn",o):11===e?f.emit("controllerChange",o):f.emit("sysex",n)}function i(n,t){e&&e.send([r[n]?r[n]+t.channel:t.channel,t.pitch,t.velocity])}function s(){n&&(n.onmidimessage=void 0),n=void 0,e=void 0,f.on=void 0,f.off=void 0,f.emit=void 0,f=void 0}if(!c)return null;if(!n&&!e)throw new Error("A bus needs a least an input or an output device");var f=u();return n&&(n.onmidimessage=o),f.send=i,f.destroy=s,f}function i(n){return c?s?n(null):void navigator.requestMIDIAccess().then(function(e){e.inputs.forEach(function(n){return f.push(n)}),e.outputs.forEach(function(n){return a.push(n)}),s=!0,n(null)},function(){n(new Error("No access to your midi devices."))}):null}var u=e,c=!!navigator.requestMIDIAccess,r={noteOn:128,noteOff:144},s=!1,f=[],a=[];n.supported=c,n.inputs=f,n.outputs=a,n.access=i,n.bus=o,n.message=t,Object.defineProperty(n,"__esModule",{value:!0})});