-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbundle.js
1 lines (1 loc) · 34.6 KB
/
bundle.js
1
!function(){var o={soundTouchWorklet:URL.createObjectURL(new Blob(["(",function(){"use strict";function O(t){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function t(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function l(t,e,i){return(l=c()?Reflect.construct:function(t,e,i){var r=[null],e=(r.push.apply(r,e),new(Function.bind.apply(t,r)));return i&&f(e,i.prototype),e}).apply(null,arguments)}function p(t){var i="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,e)}function e(){return l(t,arguments,n(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),f(e,t)}(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function y(i){var r=c();return function(){var t,e=n(i),e=(t=r?(t=n(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),this);if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}}function v(){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=n(t)););return t}(t,e);if(r)return(r=Object.getOwnPropertyDescriptor(r,e)).get?r.get.call(arguments.length<3?t:i):r.value}).apply(this,arguments)}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function g(s){var u,a=Object.prototype,h=a.hasOwnProperty,t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",c=t.asyncIterator||"@@asyncIterator",l=t.toStringTag||"@@toStringTag";function i(t,e,i){return Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,i){return t[e]=i}}function p(t,e,i,r){var n,o,s,a,e=e&&e.prototype instanceof _?e:_,e=Object.create(e.prototype),r=new S(r||[]);return e._invoke=(n=t,o=i,s=r,a=y,function(t,e){if(a===m)throw new Error("Generator is already running");if(a===g){if("throw"===t)throw e;return R()}for(s.method=t,s.arg=e;;){var i=s.delegate;if(i){i=function t(e,i){var r=e.iterator[i.method];if(r===u){if(i.delegate=null,"throw"===i.method){if(e.iterator.return&&(i.method="return",i.arg=u,t(e,i),"throw"===i.method))return f;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}r=d(r,e.iterator,i.arg);if("throw"===r.type)return i.method="throw",i.arg=r.arg,i.delegate=null,f;r=r.arg;return r?r.done?(i[e.resultName]=r.value,i.next=e.nextLoc,"return"!==i.method&&(i.method="next",i.arg=u),i.delegate=null,f):r:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,f)}(i,s);if(i){if(i===f)continue;return i}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(a===y)throw a=g,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);a=m;i=d(n,o,s);if("normal"===i.type){if(a=s.done?g:v,i.arg===f)continue;return{value:i.arg,done:s.done}}"throw"===i.type&&(a=g,s.method="throw",s.arg=i.arg)}}),e}function d(t,e,i){try{return{type:"normal",arg:t.call(e,i)}}catch(t){return{type:"throw",arg:t}}}s.wrap=p;var y="suspendedStart",v="suspendedYield",m="executing",g="completed",f={};function _(){}function w(){}function e(){}i(t={},r,function(){return this});var n=Object.getPrototypeOf,o=((n=n&&n(n(C([]))))&&n!==a&&h.call(n,r)&&(t=n),e.prototype=_.prototype=Object.create(t));function k(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function P(s,a){var e;this._invoke=function(i,r){function t(){return new a(function(t,e){!function e(t,i,r,n){var o,t=d(s[t],s,i);return"throw"!==t.type?(i=(o=t.arg).value)&&"object"===O(i)&&h.call(i,"__await")?a.resolve(i.__await).then(function(t){e("next",t,r,n)},function(t){e("throw",t,r,n)}):a.resolve(i).then(function(t){o.value=t,r(o)},function(t){return e("throw",t,r,n)}):void n(t.arg)}(i,r,t,e)})}return e=e?e.then(t,t):t()}}function B(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(B,this),this.reset(!0)}function C(e){if(e){var i,t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return i=-1,(t=function t(){for(;++i<e.length;)if(h.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=u,t.done=!0,t}).next=t}return{next:R}}function R(){return{value:u,done:!0}}return i(o,"constructor",w.prototype=e),i(e,"constructor",w),w.displayName=i(e,l,"GeneratorFunction"),s.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},s.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,e):(t.__proto__=e,i(t,l,"GeneratorFunction")),t.prototype=Object.create(o),t},s.awrap=function(t){return{__await:t}},k(P.prototype),i(P.prototype,c,function(){return this}),s.AsyncIterator=P,s.async=function(t,e,i,r,n){void 0===n&&(n=Promise);var o=new P(p(t,e,i,r),n);return s.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},k(o),i(o,l,"Generator"),i(o,r,function(){return this}),i(o,"toString",function(){return"[object Generator]"}),s.keys=function(i){var t,r=[];for(t in i)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in i)return t.value=e,t.done=!1,t}return t.done=!0,t}},s.values=C,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&h.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var r=this;function t(t,e){return o.type="throw",o.arg=i,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e],o=n.completion;if("root"===n.tryLoc)return t("end");if(n.tryLoc<=this.prev){var s=h.call(n,"catchLoc"),a=h.call(n,"finallyLoc");if(s&&a){if(this.prev<n.catchLoc)return t(n.catchLoc,!0);if(this.prev<n.finallyLoc)return t(n.finallyLoc)}else if(s){if(this.prev<n.catchLoc)return t(n.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<n.finallyLoc)return t(n.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;0<=i;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&h.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var n=r;break}}var o=(n=n&&("break"===t||"continue"===t)&&n.tryLoc<=e&&e<=n.finallyLoc?null:n)?n.completion:{};return o.type=t,o.arg=e,n?(this.method="next",this.next=n.finallyLoc,f):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),b(i),f}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var i,r,n=this.tryEntries[e];if(n.tryLoc===t)return"throw"===(i=n.completion).type&&(r=i.arg,b(n)),r}throw new Error("illegal catch attempt")},delegateYield:function(t,e,i){return this.delegate={iterator:C(t),resultName:e,nextLoc:i},"next"===this.method&&(this.arg=u),f}},s}try{regeneratorRuntime=g}catch(a){"object"===("undefined"==typeof globalThis?"undefined":O(globalThis))?globalThis.regeneratorRuntime=g:Function("r","regeneratorRuntime = r")(g)}t(j,[{key:"vector",get:function(){return this._vector}},{key:"position",get:function(){return this._position}},{key:"startIndex",get:function(){return 2*this._position}},{key:"frameCount",get:function(){return this._frameCount}},{key:"endIndex",get:function(){return 2*(this._position+this._frameCount)}},{key:"clear",value:function(){this.receive(this._frameCount),this.rewind()}},{key:"put",value:function(t){this._frameCount+=t}},{key:"putSamples",value:function(t,e){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,e=2*(e=e||0),r=2*(i=0<=i?i:(t.length-e)/2),n=(this.ensureCapacity(i+this._frameCount),this.endIndex);this.vector.set(t.subarray(e,e+r),n),this._frameCount+=i}},{key:"putBuffer",value:function(t,e){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;e=e||0,0<=i||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}},{key:"receive",value:function(t){0<=t&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}},{key:"receiveSamples",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=this.startIndex;t.set(this._vector.subarray(i,i+2*e)),this.receive(e)}},{key:"extract",value:function(t){var e=this.startIndex+2*(1<arguments.length&&void 0!==arguments[1]?arguments[1]:0);t.set(this._vector.subarray(e,e+2*(2<arguments.length&&void 0!==arguments[2]?arguments[2]:0)))}},{key:"ensureCapacity",value:function(){var t=parseInt(2*(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0));this._vector.length<t?((t=new Float32Array(t)).set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=t,this._position=0):this.rewind()}},{key:"ensureAdditionalCapacity",value:function(){this.ensureCapacity(this._frameCount+(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0))}},{key:"rewind",value:function(){0<this._position&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}]);var i=j,_=(t(N,[{key:"inputBuffer",get:function(){return this._inputBuffer},set:function(t){this._inputBuffer=t}},{key:"outputBuffer",get:function(){return this._outputBuffer},set:function(t){this._outputBuffer=t}},{key:"clear",value:function(){this._inputBuffer.clear(),this._outputBuffer.clear()}}]),N),w=(e(s,_),S=y(s),t(s,[{key:"rate",set:function(t){this._rate=t}},{key:"reset",value:function(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}},{key:"clone",value:function(){var t=new s;return t.rate=this._rate,t}},{key:"process",value:function(){var t=this._inputBuffer.frameCount,t=(this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1),this.transpose(t));this._inputBuffer.receive(),this._outputBuffer.put(t)}},{key:"transpose",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(0===t)return 0;for(var e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,r=this._outputBuffer.vector,n=this._outputBuffer.endIndex,o=0,s=0;this.slopeCount<1;)r[n+2*s]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],r[n+2*s+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],s+=1,this.slopeCount+=this._rate;if(--this.slopeCount,1!==t)t:for(;;){for(;1<this.slopeCount;)if(--this.slopeCount,(o+=1)>=t-1)break t;var a=i+2*o;r[n+2*s]=(1-this.slopeCount)*e[a]+this.slopeCount*e[a+2],r[n+2*s+1]=(1-this.slopeCount)*e[a+1]+this.slopeCount*e[a+3],s+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],s}}]),s);t(A,[{key:"pipe",get:function(){return this._pipe}},{key:"inputBuffer",get:function(){return this._pipe.inputBuffer}},{key:"outputBuffer",get:function(){return this._pipe.outputBuffer}},{key:"fillInputBuffer",value:function(){throw new Error("fillInputBuffer() not overridden")}},{key:"fillOutputBuffer",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;this.outputBuffer.frameCount<t;){var e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}},{key:"clear",value:function(){this._pipe.clear()}}]);function k(t,e){return 1e-10<(e<t?t-e:e-t)}function P(t){var e=Math.floor(t/60),t=t-60*e;return"".concat(e,":").concat((e=parseInt(t),(e+="").length>=2?e:new Array(2-e.length+1).join("0")+e))}var B,b,S,C=function(){},R=(e(o,A),b=y(o),t(o,[{key:"position",get:function(){return this._position},set:function(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");var e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}},{key:"sourcePosition",get:function(){return this._sourcePosition},set:function(t){this.clear(),this._sourcePosition=t}},{key:"onEnd",value:function(){this.callback()}},{key:"fillInputBuffer",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=new Float32Array(2*t),t=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=t,this.inputBuffer.putSamples(e,0,t)}},{key:"extract",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,e=(this.fillOutputBuffer(this.outputBufferPosition+e),Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition)),t=(this.outputBuffer.extract(t,this.outputBufferPosition,e),this.outputBufferPosition+e);return this.outputBufferPosition=Math.min(this.historyBufferSize,t),this.outputBuffer.receive(Math.max(t-this.historyBufferSize,0)),this._position+=e,e}},{key:"handleSampleData",value:function(t){this.extract(t.data,4096)}},{key:"clear",value:function(){v(n(o.prototype),"clear",this).call(this),this.outputBufferPosition=0}}]),o),L=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],E=(e(r,_),B=y(r),t(r,[{key:"clear",value:function(){v(n(r.prototype),"clear",this).call(this),this.clearMidBuffer()}},{key:"clearMidBuffer",value:function(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}},{key:"setParameters",value:function(t,e,i,r){0<t&&(this.sampleRate=t),0<r&&(this.overlapMs=r),0<e?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,0<i?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}},{key:"tempo",get:function(){return this._tempo},set:function(t){this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,t=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(t+this.overlapLength,this.seekWindowLength)+this.seekLength}},{key:"inputChunkSize",get:function(){return this.sampleReq}},{key:"outputChunkSize",get:function(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}},{key:"calculateOverlapLength",value:function(){var t=(t=this.sampleRate*(0<arguments.length&&void 0!==arguments[0]?arguments[0]:0)/1e3)<16?16:t;this.overlapLength=t-=t%8,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}},{key:"checkLimits",value:function(t,e,i){return t<e?e:i<t?i:t}},{key:"calculateSequenceParameters",value:function(){var t;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(t=25- -10/1.5*.5+-10/1.5*this._tempo,t=this.checkLimits(t,15,25),this.seekWindowMs=Math.floor(t+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}},{key:"quickSeek",set:function(t){this._quickSeek=t}},{key:"clone",value:function(){var t=new r;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}},{key:"seekBestOverlapPosition",value:function(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}},{key:"seekBestOverlapPositionStereo",value:function(){var t,e,i,r=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;r<this.seekLength;r+=1)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>e&&(e=i,t=r);return t}},{key:"seekBestOverlapPositionStereoQuick",value:function(){var t,e,i,r,n,o=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,n=r=t=0;o<4;o+=1){for(var s=0;L[o][s]&&!((n=r+L[o][s])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*n,this.refMidBuffer))>e&&(e=i,t=n),s+=1;r=t}return t}},{key:"preCalculateCorrelationReferenceStereo",value:function(){for(var t,e,i=0;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),this.refMidBuffer[t=2*i]=this.midBuffer[t]*e,this.refMidBuffer[1+t]=this.midBuffer[1+t]*e}},{key:"calculateCrossCorrelationStereo",value:function(t,e){var i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var r,n=0,o=2,s=2*this.overlapLength;o<s;o+=2)n+=i[r=o+t]*e[o]+i[r+1]*e[o+1];return n}},{key:"overlap",value:function(t){this.overlapStereo(2*t)}},{key:"overlapStereo",value:function(t){var e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var i,r,n,o,s,a=this._outputBuffer.vector,f=this._outputBuffer.endIndex,u=0,h=1/this.overlapLength;u<this.overlapLength;u+=1)r=(this.overlapLength-u)*h,o=(i=2*u)+t,a[(s=i+f)+0]=e[o+0]*(n=u*h)+this.midBuffer[0+i]*r,a[s+1]=e[o+1]*n+this.midBuffer[1+i]*r}},{key:"process",value:function(){var t;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),0<(e=this.seekWindowLength-2*this.overlapLength)&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);var e=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(e,e+2*this.overlapLength)),this.skipFract+=this.nominalSkip,t=Math.floor(this.skipFract),this.skipFract-=t,this._inputBuffer.receive(t)}}}]),r),x=(t(M,[{key:"clear",value:function(){this.transposer.clear(),this.stretch.clear()}},{key:"clone",value:function(){var t=new M;return t.rate=this.rate,t.tempo=this.tempo,t}},{key:"rate",get:function(){return this._rate},set:function(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}},{key:"rateChange",set:function(t){this._rate=1+.01*t}},{key:"tempo",get:function(){return this._tempo},set:function(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}},{key:"tempoChange",set:function(t){this.tempo=1+.01*t}},{key:"pitch",set:function(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}},{key:"pitchOctaves",set:function(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}},{key:"pitchSemitones",set:function(t){this.pitchOctaves=t/12}},{key:"inputBuffer",get:function(){return this._inputBuffer}},{key:"outputBuffer",get:function(){return this._outputBuffer}},{key:"calculateEffectiveRateAndTempo",value:function(){var t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,k(this._tempo,t)&&(this.stretch.tempo=this._tempo),k(this._rate,e)&&(this.transposer.rate=this._rate),1<this._rate?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}},{key:"process",value:function(){1<this._rate?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}]),M),T=(t(I,[{key:"dualChannel",get:function(){return 1<this.buffer.numberOfChannels}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}},{key:"extract",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var r=this.buffer.getChannelData(0),n=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),o=0;o<e;o++)t[2*o]=r[o+i],t[2*o+1]=n[o+i];return Math.min(e,r.length-i)}}]),I);function I(t){a(this,I),this.buffer=t,this._position=0}function M(){a(this,M),this.transposer=new w(!1),this.stretch=new E(!1),this._inputBuffer=new i,this._intermediateBuffer=new i,this._outputBuffer=new i,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}function r(t){return a(this,r),(t=B.call(this,t))._quickSeek=!0,t.midBufferDirty=!1,t.midBuffer=null,t.overlapLength=0,t.autoSeqSetting=!0,t.autoSeekSetting=!0,t._tempo=1,t.setParameters(44100,0,0,8),t}function o(t,e){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:C;return a(this,o),(e=b.call(this,e)).callback=i,e.sourceSound=t,e.historyBufferSize=22050,e._sourcePosition=0,e.outputBufferPosition=0,e._position=0,e}function A(t){a(this,A),this._pipe=t}function s(t){return a(this,s),(t=S.call(this,t)).reset(),t._rate=1,t}function N(t){a(this,N),t?(this._inputBuffer=new i,this._outputBuffer=new i):this._inputBuffer=this._outputBuffer=null}function j(){a(this,j),this._vector=new Float32Array,this._position=0,this._frameCount=0}t(function t(e,i,r){var n=this,o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:C,s=(a(this,t),this._soundtouch=new x,new T(i));this.timePlayed=0,this.sourcePosition=0,this._filter=new R(s,this._soundtouch,o),this._node=function(t,o){var s=2<arguments.length&&void 0!==arguments[2]?arguments[2]:C,a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:4096,t=t.createScriptProcessor(a,2,2),u=new Float32Array(2*a);return t.onaudioprocess=function(t){var e=t.outputBuffer.getChannelData(0),i=t.outputBuffer.getChannelData(1),r=o.extract(u,a);s(o.sourcePosition),0===r&&o.onEnd();for(var n=0;n<r;n++)e[n]=u[2*n],i[n]=u[2*n+1]},t}(e,this._filter,function(t){return function(t){var e=this.timePlayed,i=this.sampleRate;this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed&&(t=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}}),this._node.dispatchEvent(t))}.call(n,t)},r),this.tempo=1,this.rate=1,this.duration=i.duration,this.sampleRate=e.sampleRate,this.listeners=[]},[{key:"formattedDuration",get:function(){return P(this.duration)}},{key:"formattedTimePlayed",get:function(){return P(this.timePlayed)}},{key:"percentagePlayed",get:function(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)},set:function(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate),this.sourcePosition=this._filter.sourcePosition,this.timePlayed=this.sourcePosition/this.sampleRate}},{key:"node",get:function(){return this._node}},{key:"pitch",set:function(t){this._soundtouch.pitch=t}},{key:"pitchSemitones",set:function(t){this._soundtouch.pitchSemitones=t}},{key:"rate",set:function(t){this._soundtouch.rate=t}},{key:"tempo",set:function(t){this._soundtouch.tempo=t}},{key:"connect",value:function(t){this._node.connect(t)}},{key:"disconnect",value:function(){this._node.disconnect()}},{key:"on",value:function(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,function(t){return e(t.detail)})}},{key:"off",value:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,i=this.listeners;(i=e?i.filter(function(t){return t.name===e}):i).forEach(function(e){t._node.removeEventListener(e.name,function(t){return e.cb(t.detail)})})}}]);t(q,[{key:"position",get:function(){return this._position},set:function(t){this._position=t}},{key:"extract",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var r=0;r<e;r++)t[2*r]=this.leftChannel[r+i],t[2*r+1]=this.rightChannel[r+i];return e}}]);var D,F=q;function u(t){var e;return a(this,u),(e=D.call(this))._initialized=!1,e.bufferSize=128,e.port.onmessage=e._messageProcessor.bind(d(e)),e.port.postMessage({message:"PROCESSOR_CONSTRUCTOR",detail:t}),e}function q(t,e,i){a(this,q),Object.assign(this,t),this.leftChannel=e,this.rightChannel=i,this._position=0}e(u,p(AudioWorkletProcessor)),D=y(u),t(u,[{key:"_messageProcessor",value:function(t){var e,i,r,n=t.data,o=n.message,n=n.detail;return"INITIALIZE_PROCESSOR"===o?(e=3,e=(i=function(t){if(Array.isArray(t))return t}(i=n)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,n,o=[],s=!0,a=!1;try{for(i=i.call(t);!(s=(r=i.next()).done)&&(o.push(r.value),!e||o.length!==e);s=!0);}catch(t){a=!0,n=t}finally{try{s||null==i.return||i.return()}finally{if(a)throw n}}return o}}(i,e)||function(t,e){if(t){if("string"==typeof t)return m(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(i="Object"===i&&t.constructor?t.constructor.name:i)||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?m(t,e):void 0}}(i,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],r=i[1],i=i[2],this.bufferSource=new F(e,r,i),this._samples=new Float32Array(2*this.bufferSize),this._pipe=new x,this._filter=new R(this.bufferSource,this._pipe),this.port.postMessage({message:"PROCESSOR_READY"}),this._initialized=!0):"SET_PIPE_PROP"===o&&n?(e=n.name,r=n.value,this._pipe[e]=r,void this.port.postMessage({message:"PIPE_PROP_CHANGED",detail:"Updated ".concat(e," to ").concat(this._pipe[e],"\ntypeof ").concat(O(r))})):"SET_FILTER_PROP"===o&&n?(i=n.name,r=n.value,this._filter[i]=r,void this.port.postMessage({message:"FILTER_PROP_CHANGED",detail:"Updated ".concat(i," to ").concat(this._filter[i],"\ntypeof ").concat(O(r))})):void console.log("[PitchShifterWorkletProcessor] Unknown message: ",t)}},{key:"_sendMessage",value:function(t){t&&this.port.postMessage({message:t,detail:1<arguments.length&&void 0!==arguments[1]?arguments[1]:null})}},{key:"process",value:function(t,e){if(!this._initialized||!t[0].length)return!0;var i=e[0][0],r=1<e[0].length?e[0][1]:e[0][0],n=this._samples;if(!i||!i.length)return!1;var o=this._filter.extract(n,t[0][0].length);if(isNaN(n[0])||!o)return this._sendMessage("PROCESSOR_END"),!1;this._sendMessage("SOURCEPOSITION",this._filter.sourcePosition);for(var s=0;s<o;s+=1)i[s]=n[2*s],r[s]=n[2*s+1],(isNaN(i[s])||isNaN(r[s]))&&(i[s]=0,r[s]=0);return!0}}]),registerProcessor("soundtouch-worklet",u)}.toString(),")()"],{type:"application/javascript"}))};const n=function(t){var e=Math.floor(t/60);return e+":"+(t=parseInt(t-60*e),2<=(t+="").length?t:new Array(2-t.length+1).join("0")+t)},s=function(t,e){return(e-t)/1e3};var a=(t,e,i,r)=>new class extends e{constructor(t,e,i){super(t,"soundtouch-worklet",i),this._arrayBuffer=e.slice(0),this.listeners=[],this.port.onmessage=this._messageProcessor.bind(this),this.sourcePosition=0,this.timePlayed=0,this._startTime=0,this._pauseTime=0,this._playHead=0,this._playing=!1,this._ready=!1,this._initialPlay=!0}get formattedDuration(){return n(this.duration)}get formattedTimePlayed(){return n(this.timePlayed)}get percentagePlayed(){return 100*this.sourcePosition/(this.duration*this.sampleRate)}set percentagePlayed(t){var{duration:e,sampleRate:i}=this;this.sourcePosition=parseInt(e*i*(t/100)),this._updateFilterProp("sourcePosition",this.sourcePosition),this.currentTime=this.duration*t/100}get currentTime(){return this.playing?this._playHead+s(this._startTime,(new Date).getTime()):this._playHead}set currentTime(t){this._playHead=t}get playing(){return this._playing}set playing(t){this._playing=Boolean(t)}get ready(){return this._ready}set ready(t){this._ready=Boolean(t)}get sampleRate(){if(this.audioBuffer)return this.audioBuffer.sampleRate}get duration(){if(this.audioBuffer)return this.audioBuffer.duration}get bufferLength(){if(this.audioBuffer)return this.audioBuffer.length}get numberOfChannels(){if(this.audioBuffer)return this.audioBuffer.numberOfChannels}set pitch(t){this._updatePipeProp("pitch",t)}set pitchSemitones(t){this._updatePipeProp("pitchSemitones",t)}set rate(t){this._updatePipeProp("rate",t)}set tempo(t){this._updatePipeProp("tempo",t)}connectToBuffer(){return this.bufferNode=this.context.createBufferSource(),this.bufferNode.buffer=this.audioBuffer,this.bufferNode.onended=()=>console.log("song ended"),this.bufferNode.connect(this),this.bufferNode}disconnectFromBuffer(){this.bufferNode.disconnect()}handleAudioData(t){this.audioBuffer=t,this.port.postMessage({message:"INITIALIZE_PROCESSOR",detail:this.createBaseArray(t)})}createBaseArray(t){return[{sampleRate:this.sampleRate,duration:this.duration,bufferLength:this.bufferLength,numberOfChannels:this.numberOfChannels},t.getChannelData(0),1<this.numberOfChannels?t.getChannelData(1):t.getChannelData(0)]}async play(){if(!this.ready)throw new Error("Your processor is not ready yet");this.playing&&this.stop(!0),this._initialPlay&&(0===this._playHead&&(this.percentagePlayed=0),this._initialPlay=!1),await this.context.resume(),this._startTime=(new Date).getTime(),this.playing=!0}pause(){var t=this.currentTime;this.stop(),this.currentTime=t}async stop(){await this.context.suspend(),this.currentTime=0,this._startTime=(new Date).getTime(),this.playing=!1}on(t,e){this.listeners.push({name:t,cb:e}),this.addEventListener(t,t=>e(t.detail))}off(e=null){let t=this.listeners;(t=e?t.filter(t=>t.name===e):t).forEach(e=>{this.removeEventListener(e.name,t=>e.cb(t.detail))})}onprocessorerror(t){throw t}_updatePipeProp(t,e){this.port.postMessage({message:"SET_PIPE_PROP",detail:{name:t,value:e}})}_updateFilterProp(t,e){this.port.postMessage({message:"SET_FILTER_PROP",detail:{name:t,value:e}})}_messageProcessor(t){const{message:e,detail:i}=t.data,{sampleRate:r,timePlayed:n}=this;if("SOURCEPOSITION"===e){const t=(this.sourcePosition=i)/r;if(n!==t){this.timePlayed=t;const e=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this.dispatchEvent(e)}}if("PROCESSOR_CONSTRUCTOR"!==e)if("PROCESSOR_READY"!==e){if("PROCESSOR_END"===e){this.stop(),this.percentagePlayed=0;const t=new CustomEvent("end",{detail:{timePlayed:this.currentTime,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this.dispatchEvent(t)}}else if(this.ready=!0,"function"!=typeof this.onInitialized){const t=new CustomEvent("initialized",i);this.dispatchEvent(t)}else this.onInitialized(i);else this.context.decodeAudioData(this._arrayBuffer,t=>this.handleAudioData(t),t=>console.log("[decodeAudioData ERROR] ",t))}}(t,i,r);!function(t){!function(){window.TKK=google.translate._const._ctkk,window.logld="v"+window.google.translate.v,window.ytk="trnsl.1.1.20190713T000625Z.d2c1eb1a0a0fc57b.a63c0da34996c0eeb5bee8a727b064ed53fa8424";function u(t){return function(){return t}}function h(t,e){for(var i=0;i<e.length-2;i+=3){var r="a"<=(r=e.charAt(i+2))?r.charCodeAt(0)-87:Number(r),r="+"==e.charAt(i+1)?t>>>r:t<<r;t="+"==e.charAt(i)?t+r&4294967295:t^r}return t}var f=null;function i(t){return function(t){e=null!==f?f:(e=u(String.fromCharCode(84)),r=u(String.fromCharCode(75)),(e=[e(),e()])[1]=r(),(f=window[e.join(r())]||"")||"");var e,i=u(String.fromCharCode(116)),r=u(String.fromCharCode(107));(i=[i(),i()])[1]=r(),r="&"+i.join("")+"=",i=e.split("."),e=Number(i[0])||0;for(var n=[],o=0,s=0;s<t.length;s++){var a=t.charCodeAt(s);a<128?n[o++]=a:(a<2048?n[o++]=a>>6|192:(55296==(64512&a)&&s+1<t.length&&56320==(64512&t.charCodeAt(s+1))?(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++s)),n[o++]=a>>18|240,n[o++]=a>>12&63|128):n[o++]=a>>12|224,n[o++]=a>>6&63|128),n[o++]=63&a|128)}for(t=e,o=0;o<n.length;o++)t+=n[o],t=h(t,"+-a^+6");return t=h(t,"+-3^+b+-f"),(t^=Number(i[1])||0)<0&&(t=2147483648+(2147483647&t)),r+((t%=1e6).toString()+".")+(t^e)}(t).replace("&tk=","")}function r(i,r,n){(r=r||{}).headers=r.headers||{},n=n||"";const o=new XMLHttpRequest;return new Promise((t,e)=>{o.onreadystatechange=()=>{4===o.readyState&&(200===o.status?t(o.responseText):(console.warn("request_error"),e("request_error")))},o.open("POST",i);for(const[i,n]of Object.entries(r.headers))o.setRequestHeader(i,n);""===n?o.send():o.send(n)})}e=document.createElement("div");var e,n=function(t){return t&&"string"==typeof t&&(t=(t=t.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,"")).replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),e.innerHTML=t,t=e.textContent,e.textContent=""),t};t.window.gtranslate=async function(t,e){return url=`https://translate.googleapis.com/translate_a/t?anno=3&client=te&format=html&v=1.0&key&logld=${window.logld}&sl=${e.from}&tl=${e.to}&tc=1&dom=1&sr=1&tk=${i(t)}&mode=1`,body="q="+encodeURI(t),e=await r(url,{headers:{"content-type":"application/x-www-form-urlencoded"}},body),n(JSON.parse(e)[0])},t.window.ytranslate=async function(t,e){return e=await r(url=`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${window.ytk}&lang=${e.from.split("-")[0]}-${e.to.split("-")[0]}&text=`+encodeURI(t)),n(JSON.parse(e).text[0])},t.window.soundTouchWorklet=o.soundTouchWorklet,t.window.createSoundTouchNode=a}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})}();