!function(e,t){"object"==typeofexports&&"object"==typeofmodule?module.exports=t():"function"==typeofdefine&&define.amd?define([],t):"object"==typeofexports?exports.Keyboard=t():e.Keyboard=t()}(this,function(){returnfunction(e){functiont(r){if(n[r])returnn[r].exports;vari=n[r]={exports:{},id:r,loaded:!1};returne[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}varn={};returnt.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";functionr(e){returne&&e.__esModule?e:{default:e}}functioni(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}functiono(e,t){if(!e)thrownewReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeoft&&"function"!=typeoft?e:t}functions(e,t){if("function"!=typeoft&&null!==t)thrownewTypeError("Super expression must either be null or a function, not "+typeoft);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}vara=function(){functione(e,t){for(varn=0;n<t.length;n++){varr=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}returnfunction(t,n,r){returnn&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(5),c=r(u),h=n(1),l=r(h),p=n(2),f=n(3),d=function(e){functiont(e){varn=arguments.length>1&&void0!==arguments[1]?arguments[1]:36,r=arguments.length>2&&void0!==arguments[2]?arguments[2]:4;i(this,t);vars=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));returns._lowest=n,s._octaves=r,s._audioKeys=newc.default({polyphony:88,rows:1,octaveControls:!1}),s._audioKeys.down(function(e){s.keyDown(e.note),s.emit("keyDown",e.note)}),s._audioKeys.up(function(e){s.keyUp(e.note),s.emit("keyUp",e.note)}),s._keyboardInterface=newp.KeyboardElement(e,48,2),s._keyboardInterface.on("keyDown",function(e){s.keyDown(e),s.emit("keyDown",e)}),s._keyboardInterface.on("keyUp",function(e){s.keyUp(e),s.emit("keyUp",e)}),window.addEventListener("resize",s._resize.bind(s)),s._resize(),s._midi=newf.Midi,s._midi.on("keyDown",function(e){s.keyDown(e),s.emit("keyDown",e)}),s._midi.on("keyUp",function(e){s.keyUp(e),s.emit("keyUp",e)}),s}returns(t,e),a(t,[{key:"keyDown",value:function(e){this._keyboardInterface.keyDown(e)}},{key:"keyUp",value:function(e){this._keyboardInterface.keyUp(e)}},{key:"_resize",value:function(){this._keyboardInterface.resize(this._lowest,this._octaves)}},{key:"octaves",get:function(){returnthis._octaves},set:function(e){this._octaves=e,this._resize()}},{key:"rootNote",get:function(){returnthis._rootNote},set:function(e){this._lowest=e,this._resize()}}]),t}(l.default.EventEmitter);e.exports=d},function(e,t){functionn(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functionr(e){return"function"==typeofe}functioni(e){return"number"==typeofe}functiono(e){return"object"==typeofe&&null!==e}functions(e){returnvoid0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void0,n.prototype._maxListeners=void0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||e<0||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},n.prototype.emit=function(e){vart,n,i,a,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],tinstanceofError)throwt;varh=newError('Uncaught, unspecified "error" event. ('+t+")");throwh.context=t,h}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case1:n.call(this);break;case2:n.call(this,arguments[1]);break;case3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}elseif(o(n))for(a=Array.prototype.slice.call(arguments,1),c=n.slice(),i=c.length,u=0;u<i;u++)c[u].apply(this,a);return!0},n.prototype.addListener=function(e,t){vari;if(!r(t))throwTypeError("listener must be a function");returnthis._events||(this._events={}),this._events.new
varr=this;if(void0!==n&&"function"!=typeofn)thrownewTypeError("The 'listener' parameter must be a function.");if(void0===t&&(t="all"),t.constructor!==Array&&(t=[t]),u.MIDI_SYSTEM_MESSAGES[e])if(void0===n)this._userHandlers.system[e]=[];elsefor(vari=0;i<this._userHandlers.system[e].length;i++)this._userHandlers.system[e][i]===n&&this._userHandlers.system[e].splice(i,1);elseif(u.MIDI_CHANNEL_MESSAGES[e]){if(t.indexOf("all")>-1){t=[];for(varo=1;16>=o;o++)t.push(o)}if(!this._userHandlers.channel[e])returnthis;t.forEach(function(t){vari=r._userHandlers.channel[e][t];if(i)if(void0===n)r._userHandlers.channel[e][t]=[];elsefor(varo=0;o<i.length;o++)i[o]===n&&i.splice(o,1)})}else{if(void0!==e)thrownewTypeError("The specified event type is not supported.");this._initializeUserHandlers()}returnthis},s.prototype._initializeUserHandlers=function(){for(vareinu.MIDI_CHANNEL_MESSAGES)u.MIDI_CHANNEL_MESSAGES.hasOwnProperty(e)&&(this._userHandlers.channel[e]={});for(vartinu.MIDI_SYSTEM_MESSAGES)u.MIDI_SYSTEM_MESSAGES.hasOwnProperty(t)&&(this._userHandlers.system[t]=[])},s.prototype._onMidiMessage=function(e){e.data[0]<240?this._parseChannelEvent(e):e.data[0]<=255&&this._parseSystemEvent(e)},s.prototype._parseChannelEvent=function(e){vart,n,r=e.data[0]>>4,i=(15&e.data[0])+1;e.data.length>1&&(t=e.data[1],n=e.data.length>2?e.data[2]:void0);varo={target:this,data:e.data,timestamp:e.timeStamp,channel:i};r===u.MIDI_CHANNEL_MESSAGES.noteoff||r===u.MIDI_CHANNEL_MESSAGES.noteon&&0===n?(o.type="noteoff",o.note={number:t,name:u._notes[t%12],octave:Math.floor(t/12-1)-3},o.velocity=n/127,o.rawVelocity=n):r===u.MIDI_CHANNEL_MESSAGES.noteon?(o.type="noteon",o.note={number:t,name:u._notes[t%12],octave:Math.floor(t/12-1)-3},o.velocity=n/127,o.rawVelocity=n):r===u.MIDI_CHANNEL_MESSAGES.keyaftertouch?(o.type="keyaftertouch",o.note={number:t,name:u._notes[t%12],octave:Math.floor(t/12-1)-3},o.value=n/127):r===u.MIDI_CHANNEL_MESSAGES.controlchange&&t>=0&&119>=t?(o.type="controlchange",o.controller={number:t,name:this.getCcNameByNumber(t)},o.value=n):r===u.MIDI_CHANNEL_MESSAGES.channelmode&&t>=120&&127>=t?(o.type="channelmode",o.controller={number:t,name:this.getChannelModeByNumber(t)},o.value=n):r===u.MIDI_CHANNEL_MESSAGES.programchange?(o.type="programchange",o.value=t):r===u.MIDI_CHANNEL_MESSAGES.channelaftertouch?(o.type="channelaftertouch",o.value=t/127):r===u.MIDI_CHANNEL_MESSAGES.pitchbend?(o.type="pitchbend",o.value=((n<<7)+t-8192)/8192):o.type="unknownchannelmessage",this._userHandlers.channel[o.type]&&this._userHandlers.channel[o.type][i]&&this._userHandlers.channel[o.type][i].forEach(function(e){e(o)})},s.prototype.getCcNameByNumber=function(e){if(e=parseInt(e),!(e>=0&&119>=e))thrownewRangeError("The control change number must be between 0 and 119.");for(vartinu.MIDI_CONTROL_CHANGE_MESSAGES)if(e===u.MIDI_CONTROL_CHANGE_MESSAGES[t])returnt},s.prototype.getChannelModeByNumber=function(e){if(e=parseInt(e),!(e>=120&&status<=127))thrownewRangeError("The control change number must be between 120 and 127.");for(vartinu.MIDI_CHANNEL_MODE_MESSAGES)if(e===u.MIDI_CHANNEL_MODE_MESSAGES[t])returnt},s.prototype._parseSystemEvent=function(e){vart=e.data[0],n={target:this,data:e.data,timestamp:e.timeStamp};t===u.MIDI_SYSTEM_MESSAGES.sysex?n.type="sysex":t===u.MIDI_SYSTEM_MESSAGES.timecode?n.type="timecode":t===u.MIDI_SYSTEM_MESSAGES.songposition?n.type="songposition":t===u.MIDI_SYSTEM_MESSAGES.songselect?(n.type="songselect",n.song=e.data[1]):t===u.MIDI_SYSTEM_MESSAGES.tuningrequest?n.type="tuningrequest":t===u.MIDI_SYSTEM_MESSAGES.clock?n.type="clock":t===u.MIDI_SYSTEM_MESSAGES.start?n.type="start":t===u.MIDI_SYSTEM_MESSAGES.continue?n.type="continue":t===u.MIDI_SYSTEM_MESSAGES.stop?n.type="stop":t===u.MIDI_SYSTEM_MESSAGES.activesensing?n.type="activesensing":t===u.MIDI_SYSTEM_MESSAGES.reset?n.type="reset":n.type="unknownsystemmessage",this._userHandlers.system[n.type]&&this._userHandlers.system[n.type].forEach(function(e){e(n)})},a.prototype.send=function(e,t,n){if(!(e>=128&&255>=e))thrownewRangeError("Thestatusbytem