text: "use strict";var FlMMLonHTML5=function(){function t(t){n||(n=document.createElement("div"),document.body.appendChild(n));var e=document.createElement("div");e.appendChild(document.createTextNode(t)),n.appendChild(e);var i=n.getElementsByTagName("div");i.length>10&&n.removeChild(n.firstChild)}function e(t,e){for(var i in e)t[i]=e[i];return t}function i(t){t||(t="FlMMLonHTML5"===i.name?"flmmlworker-raw.js":"flmmlworker.js");var e=this.worker=new Worker(t);e.addEventListener("message",this.onMessage.bind(this)),this.onAudioProcessBinded=this.onAudioProcess.bind(this),this.warnings="",this.totalTimeStr="00:00",this.bufferReady=!1,this.volume=100,this.events={},e.postMessage({type:r,sampleRate:i.audioCtx.sampleRate,bufferSize:s}),this.setInfoInterval(125)}var n,s=8192,r=1,o=2,a=3,c=4,u=5,h=6,f=7,l=8,d=9,g=10,m=11,p=12,v=new Float32Array(s);e(i.prototype,{onMessage:function(i){var n=i.data,s=n.type;switch(s){case u:this.buffer=n.buffer,this.bufferReady=!0;break;case h:e(this,n.info),this.oncompilecomplete&&this.oncompilecomplete(),this.trigger("compilecomplete");break;case f:this.onbuffering&&this.onbuffering(n),this.trigger("buffering",n);break;case l:this.oncomplete&&this.oncomplete(),this.trigger("complete");break;case d:e(this,n.info),this.onsyncinfo&&this.onsyncinfo(),this.trigger("syncinfo");break;case g:this.playSound();break;case m:this.stopSound(n.isFlushBuf),this.worker.postMessage({type:m});break;case p:t(n.str)}},playSound:function(){if(!(this.gain||this.scrProc||this.oscDmy)){var t=i.audioCtx,e=this.gain=t.createGain();e.gain.value=this.volume/127,e.connect(t.destination),this.scrProc=t.createScriptProcessor(s,1,2),this.scrProc.addEventListener("audioprocess",this.onAudioProcessBinded),this.scrProc.connect(this.gain),this.oscDmy=t.createOscillator(),this.oscDmy.connect(this.scrProc),this.oscDmy.start(0)}},stopSound:function(t){t&&(this.bufferReady=!1),(this.gain||this.scrProc||this.oscDmy)&&(this.scrProc.removeEventListener("audioprocess",this.onAudioProcessBinded),this.gain&&(this.gain.disconnect(),this.gain=null),this.scrProc&&(this.scrProc.disconnect(),this.scrProc=null),this.oscDmy&&(this.oscDmy.disconnect(),this.oscDmy=null))},onAudioProcess:function(t){var e=t.outputBuffer;this.bufferReady?(e.getChannelData(0).set(this.buffer[0]),e.getChannelData(1).set(this.buffer[1]),this.bufferReady=!1,this.worker.postMessage({type:u,retBuf:this.buffer},[this.buffer[0].buffer,this.buffer[1].buffer])):(e.getChannelData(0).set(v),e.getChannelData(1).set(v),this.worker.postMessage({type:u,retBuf:null}))},trigger:function(t,i){var n=this.events[t];if(n){var s={};e(s,i);for(var r=0,o=n.length;o>r;r++)n[r]&&n[r].call(this,s)}},play:function(t){this.worker.postMessage({type:o,mml:t})},stop:function(){this.worker.postMessage({type:a})},pause:function(){this.worker.postMessage({type:c})},setMasterVolume:function(t){this.volume=t,this.gain&&(this.gain.gain.value=this.volume/127)},isPlaying:function(){return this._isPlaying},isPaused:function(){return this._isPaused},getWarnings:function(){return this.warnings},getTotalMSec:function(){return 0|this.totalMSec},getTotalTimeStr:function(){return this.totalTimeStr},getNowMSec:function(){return 0|this.nowMSec},getNowTimeStr:function(){return this.nowTimeStr},getVoiceCount:function(){return this.voiceCount},getMetaTitle:function(){return this.metaTitle},getMetaComment:function(){return this.metaComment},getMetaArtist:function(){return this.metaArtist},getMetaCoding:function(){return this.metaCoding},setInfoInterval:function(t){this.worker.postMessage({type:d,interval:t})},syncInfo:function(){this.worker.postMessage({type:d,interval:null})},addEventListener:function(t,e){var i=this.events[t];i||(i=this.events[t]=[]);for(var n=i.length;n--;)if(i[n]===e)return!1;return i.push(e),!0},removeEventListener:function(t,e){var i=this.events[t];if(!i)return!1;for(var n=i.length;n--;)if(i[n]===e)return i.splice(n,1),!0;return!1},release:function(){this.stopSound(),this.worker.terminate()}});var y=window.AudioContext||window.webkitAudioContext;return i.audioCtx=new y,document.addEventListener("DOMContentLoaded",function(){document.addEventListener("click",function t(e){var n=i.audioCtx,s=n.createBufferSource();s.connect(n.destination),s.start(0),document.removeEventListener("click",t)})}),i}();