2 lines
968 B
JavaScript
2 lines
968 B
JavaScript
var n=Object.defineProperty;var p=(e,s,r)=>s in e?n(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r;var a=(e,s,r)=>(p(e,typeof s!="symbol"?s+"":s,r),r);(function(){"use strict";class e extends AudioWorkletProcessor{constructor(t){super(t);a(this,"handleMessage",t=>{t.data&&t.data.type==="ping"?this.port.postMessage(t.data):t.data==="start"?this.started=!0:t.data==="pause"?this.started=!1:t.data==="stop"?this.started=!1:t.data.type==="bpm"?(this.bpm=t.data.value,this.currentPulsePosition=0):t.data.type==="ppqn"&&(this.ppqn=t.data.value,this.currentPulsePosition=0)});this.port.addEventListener("message",this.handleMessage),this.port.start(),this.started=!1,this.bpm=120,this.ppqn=48,this.currentPulsePosition=0}process(t,u,h){if(this.started){const o=currentTime/(60/this.bpm),i=Math.ceil(o*this.ppqn);i>this.currentPulsePosition&&(this.currentPulsePosition=i,this.port.postMessage({type:"bang"}))}return!0}}registerProcessor("transport",e)})();
|