text: /*! wad 2015-09-13 */
  !function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.Wad=b()}):"object"==typeof exports?module.exports=b():a.Wad=b()}(this,function(){!function(a){var b="recorderWorker.js",c=function(a,c){var d=c||{},e=d.bufferLen||4096,f=d.numChannels||2;this.context=a.context,this.node=(this.context.createScriptProcessor||this.context.createJavaScriptNode).call(this.context,e,f,f);var g=new Worker(d.workerPath||b);g.postMessage({command:"init",config:{sampleRate:this.context.sampleRate,numChannels:f}});var h,i=!1;this.node.onaudioprocess=function(a){if(i){for(var b=[],c=0;f>c;c++)b.push(a.inputBuffer.getChannelData(c));g.postMessage({command:"record",buffer:b})}},this.configure=function(a){for(var b in a)a.hasOwnProperty(b)&&(d[b]=a[b])},this.record=function(){i=!0},this.stop=function(){i=!1},this.clear=function(){g.postMessage({command:"clear"})},this.getBuffer=function(a){h=a||d.callback,g.postMessage({command:"getBuffer"})},this.exportWAV=function(a,b){if(h=a||d.callback,b=b||d.type||"audio/wav",!h)throw new Error("Callback not set");g.postMessage({command:"exportWAV",type:b})},g.onmessage=function(a){var b=a.data;h(b)},a.connect(this.node),this.node.connect(this.context.destination)};c.forceDownload=function(b,c){var d=(a.URL||a.webkitURL).createObjectURL(b),e=a.document.createElement("a");e.href=d,e.download=c||"output.wav";var f=document.createEvent("Event");f.initEvent("click",!0,!0),e.dispatchEvent(f)},a.Recorder=c}(window);var a=window.AudioContext||window.webkitAudioContext,b=new a;getUserMedia=navigator.mozGetUserMedia||navigator.webkitGetUserMedia||navigator.getUserMedia,getUserMedia?getUserMedia=getUserMedia.bind(navigator):console.log("get user media is not supported");var c=function(){function a(a,b){var c=4,d=1e3,e=1e3,f=-1,g=0,h=0,i=!1;if(a.length<e+d-c)return-1;for(var j=0;e>j;j++){var k=(a[j]-128)/128;h+=k*k}if(h=Math.sqrt(h/e),.01>h)return-1;for(var l=1,m=c;d>=m;m++){for(var n=0,j=0;e>j;j++)n+=Math.abs((a[j]-128)/128-(a[j+m]-128)/128);if(n=1-n/e,n>.9&&n>l)i=!0;else if(i)return b/f;l=n,n>g&&(g=n,f=m)}return g>.01?b/f:-1}var c=function(){Math.seed=6,Math.seededRandom=function(a,b){a=a||1,b=b||0,Math.seed=(9301*Math.seed+49297)%233280;var c=Math.seed/233280;return b+c*(a-b)};for(var a=2*b.sampleRate,c=b.createBuffer(1,a,b.sampleRate),d=c.getChannelData(0),e=0;a>e;e++)d[e]=2*Math.seededRandom()-1;return c}(),d=function(a){return"[object Array]"===Object.prototype.toString.call(a)},e=function(a,b){a.env={attack:b.env?F(b.env.attack,1):0,decay:b.env?F(b.env.decay,0):0,sustain:b.env?F(b.env.sustain,1):1,hold:b.env?F(b.env.hold,3.14):3.14,release:b.env?F(b.env.release,0):0},a.defaultEnv={attack:b.env?F(b.env.attack,1):0,decay:b.env?F(b.env.decay,0):0,sustain:b.env?F(b.env.sustain,1):1,hold:b.env?F(b.env.hold,3.14):3.14,release:b.env?F(b.env.release,0):0}},f=function(a,b){b.filter?a.filter=d(b.filter)?b.filter.map(function(a){return{type:a.type||"lowpass",frequency:a.frequency||600,q:a.q||1,env:a.env||null}}):[{type:b.filter.type||"lowpass",frequency:b.filter.frequency||600,q:b.filter.q||1,env:b.filter.env||null}]:b.filter=null},g=function(a,c){var d=new XMLHttpRequest;d.open("GET",a.source,!0),d.responseType="arraybuffer",a.playable--,d.onload=function(){b.decodeAudioData(d.response,function(b){a.decodedBuffer=b,c&&c(a),a.playable++,a.playOnLoad&&a.play(a.playOnLoadArg)})},d.send()},h=function(a,b){a.vibrato=b.vibrato?{shape:F(b.vibrato.shape,"sine"),speed:F(b.vibrato.speed,1),magnitude:F(b.vibrato.magnitude,5),attack:F(b.vibrato.attack,0)}:null},i=function(a,b){a.tremolo=b.tremolo?{shape:F(b.tremolo.shape,"sine"),speed:F(b.tremolo.speed,1),magnitude:F(b.tremolo.magnitude,5),attack:F(b.tremolo.attack,1)}:null},j=function(a,c){if(c.reverb){a.reverb={wet:F(c.reverb.wet,1)};var d=c.reverb.impulse||o.defaultImpulse,e=new XMLHttpRequest;e.open("GET",d,!0),e.responseType="arraybuffer",a.playable--,e.onload=function(){b.decodeAudioData(e.response,function(b){a.reverb.buffer=b,a.playable++,a.playOnLoad&&a.play(a.playOnLoadArg),a instanceof o.Poly&&a.setUp(c),"mic"===a.source&&a.reverb&&a.reverb.buffer&&a.reverb.node&&!a.reverb.node.buffer&&(a.reverb.node.convolver.buffer=a.reverb.buffer)})},e.send()}else a.reverb=null},k=function(a,c){"panning"in c?(a.panning={location:c.panning},"number"==typeof c.panning?a.panning.type="stereo":(a.panning.type="3d",a.panning.panningModel=c.panningModel||"equalpower")):a.panning={location:0,type:"stereo"},"stereo"!==a.panning.type||b.createStereoPanner||(console.log("Your browser does not support stereo panning. Falling back to 3D panning."),a.panning={location:[0,0,0],type:"3d",panningModel:"equalpower"})},l=function(a,b){a.delay=b.delay?{delayTime:F(b.delay.delayTime,.5),maxDelayTime:F(b.delay.maxDelayTime,2),feedback:F(b.delay.feedback,.25),wet:F(b.delay.wet,.25)}:null},m=function(a,c){a.nodes=[],a.mediaStreamSource=null,a.gain=null,getUserMedia({audio:!0,video:!1},function(d){a.mediaStreamSource=b.createMediaStreamSource(d),o.micConsent=!0,n(a,c)},function(a){console.log("Error setting up microphone input: ",a)})},n=function(a,c){a.nodes=[],a.gain=b.createGain(),a.gain.gain.value=F(c.volume,a.volume),a.nodes.push(a.mediaStreamSource),a.nodes.push(a.gain),(a.filter||c.filter)&&u(a,c),(a.reverb||c.reverb)&&w(a,c),k(a,c),x(a,c),(a.delay||c.delay)&&A(a,c),a.setUpExternalFxOnPlay(c,b)},o=function(a){if(this.source=a.source,this.destination=a.destination||b.destination,this.volume=F(a.volume,1),this.defaultVolume=this.volume,this.playable=1,this.pitch=o.pitches[a.pitch]||a.pitch||440,this.detune=a.detune||0,this.globalReverb=a.globalReverb||!1,this.gain=[],this.loop=a.loop||!1,e(this,a),f(this,a),h(this,a),i(this,a),j(this,a),this.constructExternalFx(a,b),k(this,a),l(this,a),"noise"===this.source)this.decodedBuffer=c;else if("mic"===this.source)m(this,a);else if("object"==typeof this.source){var d=b.createBuffer(2,this.source[0].length,b.sampleRate);d.getChannelData(0).set(this.source[0]),d.getChannelData(1).set(this.source[1]),this.decodedBuffer=d}else this.source in{sine:0,sawtooth:0,square:0,triangle:0}?a.callback&&a.callback(this):g(this,a.callback)};o.micConsent=!1;var p=function(a,b){a.filter.forEach(function(a){a.node.frequency.linearRampToValueAtTime(a.frequency,b.exactTime),a.node.frequency.linearRampToValueAtTime(a.env.frequency,b.exactTime+a.env.attack)})},q=function(a,b){a.gain[0].gain.linearRampToValueAtTime(1e-4,b.exactTime),a.gain[0].gain.linearRampToValueAtTime(a.volume,b.exactTime+a.env.attack+1e-5),a.gain[0].gain.linearRampToValueAtTime(a.volume*a.env.sustain,b.exactTime+a.env.attack+a.env.decay+2e-5),a.gain[0].gain.linearRampToValueAtTime(a.volume*a.env.sustain,b.exactTime+a.env.attack+a.env.decay+a.env.hold+3e-5),a.gain[0].gain.linearRampToValueAtTime(1e-4,b.exactTime+a.env.attack+a.env.decay+a.env.hold+a.env.release+4e-5),a.soundSource.start(b.exactTime),a.soundSource.stop(b.exactTime+a.env.attack+a.env.decay+a.env.hold+a.env.release)},r=function(a,b){for(var c=b&&b.destination||a.destination,d=1;d<a.nodes.length;d++){if("custom"===a.nodes[d-1].interface)var e=a.nodes[d-1].output;else var e=a.nodes[d-1];if("custom"===a.nodes[d].interface)var f=a.nodes[d].input;else var f=a.nodes[d];e.connect(f)}if("custom"===a.nodes[a.nodes.length-1].interface)var g=a.nodes[a.nodes.length-1].output;else var g=a.nodes[a.nodes.length-1];g.connect(c),o.reverb&&a.globalReverb&&(a.nodes[a.nodes.length-1].connect(o.reverb.node),o.reverb.node.connect(o.reverb.gain),o.reverb.gain.connect(c))},s=function(a,c){c=c||{},a.soundSource=b.createOscillator(),a.soundSource.type=a.source,a.soundSource.frequency.value=c.pitch?c.pitch in o.pitches?o.pitches[c.pitch]:c.pitch:a.pitch,a.soundSource.detune.value=c.detune||a.detune},t=function(a,b){b&&b.env?(a.env.attack=F(b.env.attack,a.defaultEnv.attack),a.env.decay=F(b.env.decay,a.defaultEnv.decay),a.env.sustain=F(b.env.sustain,a.defaultEnv.sustain),a.env.hold=F(b.env.hold,a.defaultEnv.hold),a.env.release=F(b.env.release,a.defaultEnv.release)):a.env={attack:a.defaultEnv.attack,decay:a.defaultEnv.decay,sustain:a.defaultEnv.sustain,hold:a.defaultEnv.hold,release:a.defaultEnv.release}},u=function(a,c){c.filter&&!d(c.filter)&&(c.filter=[c.filter]),a.filter.forEach(function(d,e){d.node=b.createBiquadFilter(),d.node.type=d.type,d.node.frequency.value=c.filter&&c.filter[e]?c.filter[e].frequency||d.frequency:d.frequency,d.node.Q.value=c.filter&&c.filter[e]?c.filter[e].q||d.q:d.q,(c.filter&&c.filter[e].env||a.filter[e].env)&&"mic"!==a.source&&(d.env={attack:c.filter&&c.filter[e].env&&c.filter[e].env.attack||a.filter[e].env.attack,frequency:c.filter&&c.filter[e].env&&c.filter[e].env.frequency||a.filter[e].env.frequency}),a.nodes.push(d.node)})},v=function(a,b){b&&b.filter&&a.filter?(d(b.filter)||(b.filter=[b.filter]),u(a,b)):a.filter&&u(a,a)},w=function(a){var c={"interface":"custom",input:b.createGain(),convolver:b.createConvolver(),wet:b.createGain(),output:b.createGain()};c.convolver.buffer=a.reverb.buffer,c.wet.gain.value=a.reverb.wet,c.input.connect(c.convolver),c.input.connect(c.output),c.convolver.connect(c.wet),c.wet.connect(c.output),a.reverb.node=c,a.nodes.push(a.reverb.node)},x=function(a,c){var d=c&&c.panning;"undefined"==typeof d&&(d=a.panning.location),"number"==typeof d?(a.panning.node=b.createStereoPanner(),a.panning.node.pan.value=d,a.panning.type="stereo"):(a.panning.node=b.createPanner(),a.panning.node.setPosition(d[0],d[1],d[2]),a.panning.node.panningModel=c.panningModel||a.panningModel||"equalpower",a.panning.type="3d"),a.nodes.push(a.panning.node)},y=function(a){a.vibrato.wad=new o({source:a.vibrato.shape,pitch:a.vibrato.speed,volume:a.vibrato.magnitude,env:{attack:a.vibrato.attack},destination:a.soundSource.frequency}),a.vibrato.wad.play()},z=function(a){a.tremolo.wad=new o({source:a.tremolo.shape,pitch:a.tremolo.speed,volume:a.tremolo.magnitude,env:{attack:a.tremolo.attack,hold:10},destination:a.gain[0].gain}),a.tremolo.wad.play()},A=function(a,c){if(a.delay){c.delay||(c.delay={});var d={"interface":"custom",input:b.createGain(),output:b.createGain(),delayNode:b.createDelay(a.delay.maxDelayTime),feedbackNode:b.createGain(),wetNode:b.createGain()};d.delayNode.delayTime.value=F(c.delay.delayTime,a.delay.delayTime),d.feedbackNode.gain.value=F(c.delay.feedback,a.delay.feedback),d.wetNode.gain.value=F(c.delay.wet,a.delay.wet),d.input.connect(d.delayNode),d.input.connect(d.output),d.delayNode.connect(d.feedbackNode),d.delayNode.connect(d.wetNode),d.feedbackNode.connect(d.delayNode),d.wetNode.connect(d.output),a.delay.delayNode=d,a.nodes.push(d)}},B=function(a,c){a.compressor=b.createDynamicsCompressor(),a.compressor.attack.value=F(c.compressor.attack,a.compressor.attack.value),a.compressor.knee.value=F(c.compressor.knee,a.compressor.knee.value),a.compressor.ratio.value=F(c.compressor.ratio,a.compressor.ratio.value),a.compressor.release.value=F(c.compressor.release,a.compressor.release.value),a.compressor.threshold.value=F(c.compressor.threshold,a.compressor.threshold.value),a.nodes.push(a.compressor)};o.prototype.constructExternalFx=function(){},o.prototype.setUpExternalFxOnPlay=function(){},o.prototype.play=function(a){return a=a||{arg:null},this.playable<1?(this.playOnLoad=!0,this.playOnLoadArg=a):"mic"===this.source?o.micConsent?null===a.arg?r(this,a):(f(this,a),h(this,a),i(this,a),j(this,a),this.constructExternalFx(a,b),k(this,a),l(this,a),n(this,a),r(this,a)):console.log("You have not given your browser permission to use your microphone."):(this.nodes=[],a.wait||(a.wait=0),this.volume=a.volume?a.volume:this.defaultVolume,this.source in{sine:0,sawtooth:0,square:0,triangle:0}?s(this,a):(this.soundSource=b.createBufferSource(),this.soundSource.buffer=this.decodedBuffer,("noise"===this.source||this.loop||a.loop)&&(this.soundSource.loop=!0)),void 0===a.exactTime&&(a.exactTime=b.currentTime+a.wait),this.nodes.push(this.soundSource),t(this,a),v(this,a),this.setUpExternalFxOnPlay(a,b),this.gain.unshift(b.createGain()),this.gain[0].label=a.label,this.nodes.push(this.gain[0]),this.gain.length>15&&(this.gain.length=15),this.reverb&&w(this,a),x(this,a),A(this,a),r(this,a),this.filter&&this.filter[0].env&&p(this,a),q(this,a),this.vibrato&&y(this,a),this.tremolo&&z(this,a)),a.callback&&a.callback(this),this},o.prototype.setVolume=function(a){return this.defaultVolume=a,this.gain.length>0&&(this.gain[0].gain.value=a),this},o.prototype.setDetune=function(a){return this.soundSource.detune.value=a,this},o.prototype.setPanning=function(a){return this.panning.location=a,d(a)&&"3d"===this.panning.type&&this.panning.node?this.panning.node.setPosition(a[0],a[1],a[2]):"number"==typeof a&&"stereo"===this.panning.type&&this.panning.node&&(this.panning.node.pan.value=a),d(a)?this.panning.type="3d":"number"==typeof a&&(this.panning.type="stereo"),this},o.prototype.stop=function(a){if("mic"!==this.source){if(a)for(var c=0;c<this.gain.length;c++)this.gain[c].label===a&&(this.gain[c].gain.cancelScheduledValues(b.currentTime),this.gain[c].gain.setValueAtTime(this.gain[c].gain.value,b.currentTime),this.gain[c].gain.linearRampToValueAtTime(1e-4,b.currentTime+this.env.release));a||(this.gain[0].gain.cancelScheduledValues(b.currentTime),this.gain[0].gain.setValueAtTime(this.gain[0].gain.value,b.currentTime),this.gain[0].gain.linearRampToValueAtTime(1e-4,b.currentTime+this.env.release))}else o.micConsent?this.mediaStreamSource.disconnect(0):console.log("You have not given your browser permission to use your microphone.");this.tremolo&&this.tremolo.wad.stop()};var C=2048,D=new Uint8Array(C),E=function(a){var b=12*(Math.log(a/440)/Math.log(2));return Math.round(b)+69};o.Poly=function(a){a||(a={}),this.isSetUp=!1,this.playable=1,a.reverb?j(this,a):this.setUp(a)},o.Poly.prototype.setUp=function(a){if(this.wads=[],this.input=b.createAnalyser(),this.input.fftSize=2048,this.nodes=[this.input],this.destination=a.destination||b.destination,this.volume=a.volume||1,this.output=b.createGain(),this.output.gain.value=this.volume,"undefined"!=typeof Recorder&&a.recConfig){this.rec=new Recorder(this.output,a.recConfig),this.rec.recordings=[];var c=this,d=function(a){c.rec.createWadArg.source=a,c.rec.recordings.unshift(new o(c.rec.createWadArg))};this.rec.createWad=function(a){this.createWadArg=a||{env:{hold:9001}},this.getBuffer(d)}}this.globalReverb=a.globalReverb||!1,f(this,a),this.filter&&u(this,a),this.reverb&&w(this,a),this.constructExternalFx(a,b),k(this,a),x(this,a),a.compressor&&B(this,a),l(this,a),A(this,a),this.nodes.push(this.output),r(this,a),this.isSetUp=!0,a.callback&&a.callback(this)},o.Poly.prototype.updatePitch=function(){this.input.getByteTimeDomainData(D);var c=a(D,b.sampleRate);if(-1!==c&&11025!==c&&12e3!==c){var d=c;this.pitch=Math.floor(d);var e=E(d);this.noteName=o.pitchesArray[e-12]}var f=this;f.rafID=window.requestAnimationFrame(function(){f.updatePitch()})},o.Poly.prototype.stopUpdatingPitch=function(){cancelAnimationFrame(this.rafID)},o.Poly.prototype.setVolume=function(a){return this.isSetUp?this.output.gain.value=a:console.log("This PolyWad is not set up yet."),this},o.Poly.prototype.play=function(a){if(this.isSetUp)if(this.playable<1)this.playOnLoad=!0,this.playOnLoadArg=a;else{a&&a.volume&&(this.output.gain.value=a.volume,a.volume=void 0);for(var b=0;b<this.wads.length;b++)this.wads[b].play(a)}else console.log("This PolyWad is not set up yet.");return this},o.Poly.prototype.stop=function(a){if(this.isSetUp)for(var b=0;b<this.wads.length;b++)this.wads[b].stop(a)},o.Poly.prototype.add=function(a){return this.isSetUp?(a.destination=this.input,this.wads.push(a),a instanceof o.Poly&&(a.output.disconnect(0),a.output.connect(this.input))):console.log("This PolyWad is not set up yet."),this},o.Poly.prototype.remove=function(a){if(this.isSetUp)for(var c=0;c<this.wads.length;c++)this.wads[c]===a&&(this.wads[c].destination=b.destination,this.wads.splice(c,1),a instanceof o.Poly&&(a.output.disconnect(0),a.output.connect(b.destination)));return this},o.Poly.prototype.constructExternalFx=function(){},o.defaultImpulse="http://www.codecur.io/us/sendaudio/widehall.wav",o.setGlobalReverb=function(a){o.reverb={},o.reverb.node=b.createConvolver(),o.reverb.gain=b.createGain(),o.reverb.gain.gain.value=a.wet;var c=a.impulse||o.defaultImpulse,d=new XMLHttpRequest;d.open("GET",c,!0),d.responseType="arraybuffer",d.onload=function(){b.decodeAudioData(d.response,function(a){o.reverb.node.buffer=a})},d.send()};var F=function(a,b){var c=null==a?b:a;return c};o.pitches={A0:27.5,"A#0":29.1352,Bb0:29.1352,B0:30.8677,"B#0":32.7032,Cb1:30.8677,C1:32.7032,"C#1":34.6478,Db1:34.6478,D1:36.7081,"D#1":38.8909,Eb1:38.8909,E1:41.2034,Fb1:41.2034,"E#1":43.6535,F1:43.6535,"F#1":46.2493,Gb1:46.2493,G1:48.9994,"G#1":51.9131,Ab1:51.9131,A1:55,"A#1":58.2705,Bb1:58.2705,B1:61.7354,Cb2:61.7354,"B#1":65.4064,C2:65.4064,"C#2":69.2957,Db2:69.2957,D2:73.4162,"D#2":77.7817,Eb2:77.7817,E2:82.4069,Fb2:82.4069,"E#2":87.3071,F2:87.3071,"F#2":92.4986,Gb2:92.4986,G2:97.9989,"G#2":103.826,Ab2:103.826,A2:110,"A#2":116.541,Bb2:116.541,B2:123.471,Cb3:123.471,"B#2":130.813,C3:130.813,"C#3":138.591,Db3:138.591,D3:146.832,"D#3":155.563,Eb3:155.563,E3:164.814,Fb3:164.814,"E#3":174.614,F3:174.614,"F#3":184.997,Gb3:184.997,G3:195.998,"G#3":207.652,Ab3:207.652,A3:220,"A#3":233.082,Bb3:233.082,B3:246.942,Cb4:246.942,"B#3":261.626,C4:261.626,"C#4":277.183,Db4:277.183,D4:293.665,"D#4":311.127,Eb4:311.127,E4:329.628,Fb4:329.628,"E#4":349.228,F4:349.228,"F#4":369.994,Gb4:369.994,G4:391.995,"G#4":415.305,Ab4:415.305,A4:440,"A#4":466.164,Bb4:466.164,B4:493.883,Cb5:493.883,"B#4":523.251,C5:523.251,"C#5":554.365,Db5:554.365,D5:587.33,"D#5":622.254,Eb5:622.254,E5:659.255,Fb5:659.255,"E#5":698.456,F5:698.456,"F#5":739.989,Gb5:739.989,G5:783.991,"G#5":830.609,Ab5:830.609,A5:880,"A#5":932.328,Bb5:932.328,B5:987.767,Cb6:987.767,"B#5":1046.5,C6:1046.5,"C#6":1108.73,Db6:1108.73,D6:1174.66,"D#6":1244.51,Eb6:1244.51,Fb6:1318.51,E6:1318.51,"E#6":1396.91,F6:1396.91,"F#6":1479.98,Gb6:1479.98,G6:1567.98,"G#6":1661.22,Ab6:1661.22,A6:1760,"A#6":1864.66,Bb6:1864.66,B6:1975.53,Cb7:1975.53,"B#6":2093,C7:2093,"C#7":2217.46,Db7:2217.46,D7:2349.32,"D#7":2489.02,Eb7:2489.02,E7:2637.02,Fb7:2637.02,"E#7":2793.83,F7:2793.83,"F#7":2959.96,Gb7:2959.96,G7:3135.96,"G#7":3322.44,Ab7:3322.44,A7:3520,"A#7":3729.31,Bb7:3729.31,B7:3951.07,Cb8:3951.07,"B#7":4186.01,C8:4186.01},o.pitchesArray=["C0","C#0","D0","D#0","E0","E#0","Fb0","F0","F#0","G0","G#0","A0","A#0","B0","B#0","Cb1","C1","C#1","D1","D#1","E1","E#1","F1","Fb1","F#1","G1","G#1","A1","A#1","B1","B#1","Cb2","C2","C#2","D2","D#2","E2","E#2","Fb2","F2","F#2","G2","G#2","A2","A#2","B2","B#2","Cb3","C3","C#3","D3","D#3","E3","E#3","Fb3","F3","F#3","G3","G#3","A3","A#3","B3","B#3","Cb4","C4","C#4","D4","D#4","E4","E#4","Fb4","F4","F#4","G4","G#4","A4","A#4","B#4","B4","Cb5","C5","C#5","D5","D#5","E5","E#5","Fb5","F5","F#5","G5","G#5","A5","A#5","B#5","B5","Cb6","C6","C#6","D6","D#6","E6","E#6","Fb6","F6","F#6","G6","G#6","A6","A#6","B6","B#6","Cb7","C7","C#7","D7","D#7","E7","E#7","Fb7","F7","F#7","G7","G#7","A7","A#7","B7","B#7","C8"],o.midiInstrument={play:function(){console.log("playing midi")},stop:function(){console.log("stopping midi")}},o.midiInputs=[],midiMap=function(a){console.log(a.receivedTime,a.data),144===a.data[0]?0===a.data[2]?(console.log("|| stopping note: ",o.pitchesArray[a.data[1]-12]),o.midiInstrument.stop(o.pitchesArray[a.data[1]-12])):a.data[2]>0&&(console.log("> playing note: ",o.pitchesArray[a.data[1]-12]),o.midiInstrument.play({pitch:o.pitchesArray[a.data[1]-12],label:o.pitchesArray[a.data[1]-12],callback:function(){}})):176===a.data[0]?(console.log("controller"),46==a.data[1]&&(127==a.data[2]?o.midiInstrument.pedalMod=!0:0==a.data[2]&&(o.midiInstrument.pedalMod=!1))):224===a.data[0]&&console.log("pitch bend")};var G=function(a){o.midiInputs=[];for(var b=a.inputs.values(),c=b.next();!c.done;c=b.next())o.midiInputs.push(c.value);console.log("MIDI inputs: ",o.midiInputs);for(var d=0;d<o.midiInputs.length;d++)o.midiInputs[d].onmidimessage=midiMap},H=function(a){console.log("uh-oh! Something went wrong!  Error code: "+a.code)};if(navigator&&navigator.requestMIDIAccess)try{navigator.requestMIDIAccess().then(G,H)}catch(I){var J="There was an error on this page.\n\n";J+="Error description: "+I.message+"\n\n",J+="Click OK to continue.\n\n",console.log(J)}return o.presets={hiHatClosed:{source:"noise",env:{attack:.001,decay:.008,sustain:.2,hold:.03,release:.01},filter:{type:"highpass",frequency:400,q:1}},snare:{source:"noise",env:{attack:.001,decay:.01,sustain:.2,hold:.03,release:.02},filter:{type:"bandpass",frequency:300,q:.18}},hiHatOpen:{source:"noise",env:{attack:.001,decay:.008,sustain:.2,hold:.43,release:.01},filter:{type:"highpass",frequency:100,q:.2}},ghost:{source:"square",volume:.3,env:{attack:.01,decay:.002,sustain:.5,hold:2.5,release:.3},filter:{type:"lowpass",frequency:600,q:7,env:{attack:.7,frequency:1600}},vibrato:{attack:8,speed:8,magnitude:100}},piano:{source:"square",volume:1.4,env:{attack:.01,decay:.005,sustain:.2,hold:.015,release:.3},filter:{type:"lowpass",frequency:1200,q:8.5,env:{attack:.2,frequency:600}}}},o}();return"undefined"!=typeof module&&module.exports&&(module.exports=c),c});