@jadujoel/web-audio-clip-node 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/audio/processor-code.d.ts +1 -1
- package/dist/audio/processor-code.js +1 -1
- package/dist/audio/processor-kernel.js +20 -6
- package/dist/audio/version.d.ts +1 -1
- package/dist/audio/version.js +1 -1
- package/dist/lib.bundle.js +6 -0
- package/dist/lib.bundle.js.map +7 -0
- package/dist/processor.js +2 -2
- package/dist/processor.js.map +3 -3
- package/examples/cdn-vanilla/README.md +6 -6
- package/examples/cdn-vanilla/index.html +4 -8
- package/examples/esm-bundler/README.md +3 -4
- package/examples/esm-bundler/bun.lock +15 -0
- package/examples/esm-bundler/index.html +1 -1
- package/examples/esm-bundler/main.ts +41 -0
- package/examples/esm-bundler/package.json +3 -6
- package/examples/react/README.md +2 -2
- package/examples/react/package.json +3 -5
- package/examples/self-hosted/src/main.ts +24 -24
- package/package.json +2 -1
- package/examples/esm-bundler/src/main.ts +0 -43
- package/examples/react/vite.config.ts +0 -6
package/README.md
CHANGED
|
@@ -62,10 +62,15 @@ function Player() {
|
|
|
62
62
|
|
|
63
63
|
```html
|
|
64
64
|
<script type="module">
|
|
65
|
+
import { ClipNode, getProcessorCdnUrl } from "https://cdn.jsdelivr.net/npm/@jadujoel/web-audio-clip-node@0.1.1/dist/lib.bundle.js";
|
|
66
|
+
|
|
65
67
|
const ctx = new AudioContext();
|
|
66
|
-
await ctx.audioWorklet.addModule(
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
await ctx.audioWorklet.addModule(getProcessorCdnUrl());
|
|
69
|
+
|
|
70
|
+
const clip = new ClipNode(ctx, {
|
|
71
|
+
processorOptions: { sampleRate: ctx.sampleRate },
|
|
72
|
+
});
|
|
73
|
+
clip.connect(ctx.destination);
|
|
69
74
|
</script>
|
|
70
75
|
```
|
|
71
76
|
|
|
@@ -82,6 +87,7 @@ function Player() {
|
|
|
82
87
|
| Entry point | Import path | Contents |
|
|
83
88
|
|-------------|-------------|----------|
|
|
84
89
|
| Core | `@jadujoel/web-audio-clip-node` | `ClipNode`, types, utils, controls, processor kernel |
|
|
90
|
+
| Bundle | `@jadujoel/web-audio-clip-node/bundle` | Single-file ESM bundle for CDN / `<script type="module">` |
|
|
85
91
|
| React | `@jadujoel/web-audio-clip-node/react` | Store, hooks, UI components |
|
|
86
92
|
| Processor | `@jadujoel/web-audio-clip-node/processor` | Standalone worklet script |
|
|
87
93
|
| Styles | `@jadujoel/web-audio-clip-node/styles.css` | CSS for React components |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const processorCode = "var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,F=A>0;return{totalLength:F?A:null,committedLength:F?A:0,streamEnded:F,streaming:!1,writtenSpans:F?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let F=[...V,A].sort((Q,J)=>Q.startSample-J.startSample),T=[];for(let Q of F){let J=T[T.length-1];if(!J||Q.startSample>J.endSample){T.push({...Q});continue}J.endSample=Math.max(J.endSample,Q.endSample)}return T}function I0(V){let A=0;for(let F of V){if(F.startSample>A)break;A=Math.max(A,F.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,F){let T=M0(V.buffer),Q=V.buffer.length;if(T>=F&&Q>=A)return;let J=Math.max(T,F),U=Math.max(Q,A),Y=G0(U,J);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,T));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<J)V.streamBuffer.totalLength=J}function B0(V,A){let F=Math.max(Math.floor(A.startSample),0),T=A.channelData[0]?.length??0,Q=A.totalLength??null,J=Math.max(F+T,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),J);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],F);if(Q!=null)V.streamBuffer.totalLength=Q;if(T>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:F,endSample:F+T}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:F=[],streamBuffer:T=i(F),duration:Q=-1,loop:J=!1,loopStart:U=0,loopEnd:Y=(F[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:F,streamBuffer:T,loop:J,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let F=b0(V,A);if(F<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=F)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>F)V.loopEnd=F}function e(V,A,F){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,F);if(A>(o(V)||1)-1)return e(V,o(V)%A,F);let T=Math.floor(A*F);return V.offset=T,T}function L0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J}=V,U=128;if(!T&&A+128>F)U=Math.max(F-A,0);let Y=Array(U);if(!T){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=F}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=J)X=Q+(X-J),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J,playbackRates:U}=V,Y=128;if(!T&&A+128>F)Y=Math.max(F-A,0);let X=Array(Y),k=A,H=!1;if(T){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),F-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>J||k>F))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=J,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),F-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=F||k<0}}function m0(V,A,F){for(let T=0;T<F.length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=A[Q][F[T]];for(let T=F.length;T<V[0].length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=0}function d(V){for(let A=0;A<V.length;A++)for(let F=0;F<V[A].length;F++)V[A][F]=0}function S0(V){let A=new Float32Array(V[0].length);for(let F=0;F<V[0].length;F++)A[F]=V[0][F];V.push(A)}function H0(V,A){for(let F=A.length;F<V.length;F++)A[F]=new Float32Array(V[F].length);for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)A[F][T]=V[F][T]}function c0(V){let A=0;for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)if(Number.isNaN(V[F][T]))A++,V[F][T]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let T=A[0];if(T===1)return;for(let Q of V)for(let J=0;J<Q.length;J++)Q[J]*=T;return}let F=A[0];for(let T of V)for(let Q=0;Q<T.length;Q++)F=A[Q]??F,T[Q]*=F}function d0(V,A){let F=A[0];for(let T=0;T<V[0].length;T++){F=A[T]??F;let Q=F<=0?1:1-F,J=F>=0?1:1+F;V[0][T]*=Q,V[1][T]*=J}}function h0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<J.length;b++){let c=J[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,J[b]=g}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function l0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<J.length;Z++){let E=J[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,J[Z]=O}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,F,T){let{type:Q,data:J}=A;switch(Q){case\"buffer\":return y0(V,J),n(V,T),[];case\"bufferInit\":{let U=J;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,T),[]}case\"bufferRange\":return V.streamBuffer.pendingWrites.push(J),[];case\"bufferEnd\":{let U=J;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case\"bufferReset\":return V.buffer=[],V.streamBuffer=i(),n(V,T),[];case\"start\":V.timesLooped=0;{let U=J;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/T;e(V,U?.offset,T),n(V,T),V.playhead=V.offset,V.startWhen=U?.when??F,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:\"scheduled\"}];case\"stop\":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=J??V.stopWhen,V.state=z.Stopped,[{type:\"stopped\"}];case\"pause\":return V.state=z.Paused,V.pauseWhen=J??F,[{type:\"paused\"}];case\"resume\":return V.state=z.Started,V.startWhen=J??F,[{type:\"resume\"}];case\"dispose\":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:\"disposed\"}];case\"loop\":{let U=J,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,T);return[]}case\"loopStart\":return V.loopStart=J,[];case\"loopEnd\":return V.loopEnd=J,[];case\"loopCrossfade\":return V.loopCrossfade=J,[];case\"playhead\":return V.playhead=Math.floor(J),[];case\"fadeIn\":return V.fadeInDuration=J,[];case\"fadeOut\":return V.fadeOutDuration=J,[];case\"toggleGain\":return V.enableGain=J??!V.enableGain,[];case\"togglePan\":return V.enablePan=J??!V.enablePan,[];case\"toggleLowpass\":return V.enableLowpass=J??!V.enableLowpass,[];case\"toggleHighpass\":return V.enableHighpass=J??!V.enableHighpass,[];case\"toggleDetune\":return V.enableDetune=J??!V.enableDetune,[];case\"togglePlaybackRate\":return V.enablePlaybackRate=J??!V.enablePlaybackRate,[];case\"toggleFadeIn\":return V.enableFadeIn=J??!V.enableFadeIn,[];case\"toggleFadeOut\":return V.enableFadeOut=J??!V.enableFadeOut,[];case\"toggleLoopStart\":return V.enableLoopStart=J??!V.enableLoopStart,[];case\"toggleLoopEnd\":return V.enableLoopEnd=J??!V.enableLoopEnd,[];case\"toggleLoopCrossfade\":return V.enableLoopCrossfade=J??!V.enableLoopCrossfade,[];case\"logState\":return[]}return[]}function j0(V,A,F,T,Q){let J=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:J};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:J};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:J};if(U===z.Scheduled)if(T.currentTime>=V.startWhen)U=V.state=z.Started,J.push({type:\"started\"});else return d(A[0]),{keepAlive:!0,messages:J};else if(U===z.Paused){if(T.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:J}}if(T.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,J.push({type:\"ended\"}),V.playedSamples=0,{keepAlive:!0,messages:J};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:J};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=F,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,l=Math.min(N.length,Y.length),W0=V.duration*T.sampleRate,Z0=Math.floor(T.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*T.sampleRate),q0):0,x=t?Math.min(Math.floor(w*T.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,u=k;if(J0){let M=Math.max(k.length,H.length,y);u=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];u[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&u.length>0&&u.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)J.push({type:\"bufferLowWater\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:u},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)J.push({type:\"bufferUnderrun\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*T.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*T.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*T.sampleRate),W=Math.floor(T.sampleRate*(Z-T.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][I]*=S}}if(O)h0(Y,$,T.sampleRate,Q.lowpass);if(R)l0(Y,j,T.sampleRate,Q.highpass);if(h)g0(Y,P);if(l===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,J.push({type:\"looped\",data:V.timesLooped});if(X0)V.state=z.Ended,J.push({type:\"ended\"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:J};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:\"playbackRate\",automationRate:\"a-rate\",defaultValue:1},{name:\"detune\",automationRate:\"a-rate\",defaultValue:0},{name:\"gain\",automationRate:\"a-rate\",defaultValue:1,minValue:0},{name:\"pan\",automationRate:\"a-rate\",defaultValue:0},{name:\"highpass\",automationRate:\"a-rate\",defaultValue:20,minValue:20,maxValue:20000},{name:\"lowpass\",automationRate:\"a-rate\",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let F=z0(this.properties,A.data,currentTime,sampleRate);for(let T of F)this.port.postMessage(T);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,F){try{let T=j0(this.properties,A,F,{currentTime,currentFrame,sampleRate},this.filterState);for(let J of T.messages)this.port.postMessage(J);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:\"frame\",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),T.keepAlive}catch(T){return console.log(T),!0}}}registerProcessor(\"ClipProcessor\",P0);\n\n//# debugId=5101232AAE128B1064756E2164756E21\n//# sourceMappingURL=processor.js.map\n";
|
|
1
|
+
export declare const processorCode = "var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,T=A>0;return{totalLength:T?A:null,committedLength:T?A:0,streamEnded:T,streaming:!1,writtenSpans:T?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let T=[...V,A].sort((Q,F)=>Q.startSample-F.startSample),J=[];for(let Q of T){let F=J[J.length-1];if(!F||Q.startSample>F.endSample){J.push({...Q});continue}F.endSample=Math.max(F.endSample,Q.endSample)}return J}function I0(V){let A=0;for(let T of V){if(T.startSample>A)break;A=Math.max(A,T.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,T){let J=M0(V.buffer),Q=V.buffer.length;if(J>=T&&Q>=A)return;let F=Math.max(J,T),U=Math.max(Q,A),Y=G0(U,F);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,J));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<F)V.streamBuffer.totalLength=F}function B0(V,A){let T=Math.max(Math.floor(A.startSample),0),J=A.channelData[0]?.length??0,Q=A.totalLength??null,F=Math.max(T+J,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),F);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],T);if(Q!=null)V.streamBuffer.totalLength=Q;if(J>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:T,endSample:T+J}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:T=[],streamBuffer:J=i(T),duration:Q=-1,loop:F=!1,loopStart:U=0,loopEnd:Y=(T[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:T,streamBuffer:J,loop:F,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let T=b0(V,A);if(T<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=T)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>T)V.loopEnd=T}function e(V,A,T){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,T);if(A>(o(V)||1)-1)return e(V,o(V)%A,T);let J=Math.floor(A*T);return V.offset=J,J}function L0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F}=V,U=128;if(!J&&A+128>T)U=Math.max(T-A,0);let Y=Array(U);if(!J){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=T}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=F)X=Q+(X-F),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F,playbackRates:U}=V,Y=128;if(!J&&A+128>T)Y=Math.max(T-A,0);let X=Array(Y),k=A,H=!1;if(J){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),T-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>F||k>T))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=F,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),T-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=T||k<0}}function m0(V,A,T){let J=Math.min(V.length,A.length);for(let Q=0;Q<T.length;Q++)for(let F=0;F<J;F++)V[F][Q]=A[F][T[Q]];for(let Q=J;Q<V.length;Q++)for(let F=0;F<V[Q].length;F++)V[Q][F]=0;for(let Q=T.length;Q<V[0].length;Q++)for(let F=0;F<J;F++)V[F][Q]=0}function d(V){for(let A=0;A<V.length;A++)for(let T=0;T<V[A].length;T++)V[A][T]=0}function S0(V){if(V.length>=2)for(let A=0;A<V[0].length;A++)V[1][A]=V[0][A];else{let A=new Float32Array(V[0].length);for(let T=0;T<V[0].length;T++)A[T]=V[0][T];V.push(A)}}function H0(V,A){for(let T=A.length;T<V.length;T++)A[T]=new Float32Array(V[T].length);for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)A[T][J]=V[T][J]}function c0(V){let A=0;for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)if(Number.isNaN(V[T][J]))A++,V[T][J]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let J=A[0];if(J===1)return;for(let Q of V)for(let F=0;F<Q.length;F++)Q[F]*=J;return}let T=A[0];for(let J of V)for(let Q=0;Q<J.length;Q++)T=A[Q]??T,J[Q]*=T}function d0(V,A){let T=A[0];for(let J=0;J<V[0].length;J++){T=A[J]??T;let Q=T<=0?1:1-T,F=T>=0?1:1+T;V[0][J]*=Q,V[1][J]*=F}}function h0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<F.length;b++){let c=F[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,F[b]=g}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function u0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<F.length;Z++){let E=F[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,F[Z]=O}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,T,J){let{type:Q,data:F}=A;switch(Q){case\"buffer\":return y0(V,F),n(V,J),[];case\"bufferInit\":{let U=F;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,J),[]}case\"bufferRange\":return V.streamBuffer.pendingWrites.push(F),[];case\"bufferEnd\":{let U=F;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case\"bufferReset\":return V.buffer=[],V.streamBuffer=i(),n(V,J),[];case\"start\":V.timesLooped=0;{let U=F;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/J;e(V,U?.offset,J),n(V,J),V.playhead=V.offset,V.startWhen=U?.when??T,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:\"scheduled\"}];case\"stop\":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=F??V.stopWhen,V.state=z.Stopped,[{type:\"stopped\"}];case\"pause\":return V.state=z.Paused,V.pauseWhen=F??T,[{type:\"paused\"}];case\"resume\":return V.state=z.Started,V.startWhen=F??T,[{type:\"resume\"}];case\"dispose\":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:\"disposed\"}];case\"loop\":{let U=F,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,J);return[]}case\"loopStart\":return V.loopStart=F,[];case\"loopEnd\":return V.loopEnd=F,[];case\"loopCrossfade\":return V.loopCrossfade=F,[];case\"playhead\":return V.playhead=Math.floor(F),[];case\"fadeIn\":return V.fadeInDuration=F,[];case\"fadeOut\":return V.fadeOutDuration=F,[];case\"toggleGain\":return V.enableGain=F??!V.enableGain,[];case\"togglePan\":return V.enablePan=F??!V.enablePan,[];case\"toggleLowpass\":return V.enableLowpass=F??!V.enableLowpass,[];case\"toggleHighpass\":return V.enableHighpass=F??!V.enableHighpass,[];case\"toggleDetune\":return V.enableDetune=F??!V.enableDetune,[];case\"togglePlaybackRate\":return V.enablePlaybackRate=F??!V.enablePlaybackRate,[];case\"toggleFadeIn\":return V.enableFadeIn=F??!V.enableFadeIn,[];case\"toggleFadeOut\":return V.enableFadeOut=F??!V.enableFadeOut,[];case\"toggleLoopStart\":return V.enableLoopStart=F??!V.enableLoopStart,[];case\"toggleLoopEnd\":return V.enableLoopEnd=F??!V.enableLoopEnd,[];case\"toggleLoopCrossfade\":return V.enableLoopCrossfade=F??!V.enableLoopCrossfade,[];case\"logState\":return[]}return[]}function j0(V,A,T,J,Q){let F=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:F};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:F};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:F};if(U===z.Scheduled)if(J.currentTime>=V.startWhen)U=V.state=z.Started,F.push({type:\"started\"});else return d(A[0]),{keepAlive:!0,messages:F};else if(U===z.Paused){if(J.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:F}}if(J.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,F.push({type:\"ended\"}),V.playedSamples=0,{keepAlive:!0,messages:F};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:F};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=T,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,u=Math.min(N.length,Y.length),W0=V.duration*J.sampleRate,Z0=Math.floor(J.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*J.sampleRate),q0):0,x=t?Math.min(Math.floor(w*J.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,l=k;if(J0){let M=Math.max(k.length,H.length,y);l=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];l[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&l.length>0&&l.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)F.push({type:\"bufferLowWater\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:l},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)F.push({type:\"bufferUnderrun\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*J.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*J.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*J.sampleRate),W=Math.floor(J.sampleRate*(Z-J.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][I]*=S}}if(O)h0(Y,$,J.sampleRate,Q.lowpass);if(R)u0(Y,j,J.sampleRate,Q.highpass);if(h)g0(Y,P);if(u===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,F.push({type:\"looped\",data:V.timesLooped});if(X0)V.state=z.Ended,F.push({type:\"ended\"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:F};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:\"playbackRate\",automationRate:\"a-rate\",defaultValue:1},{name:\"detune\",automationRate:\"a-rate\",defaultValue:0},{name:\"gain\",automationRate:\"a-rate\",defaultValue:1,minValue:0},{name:\"pan\",automationRate:\"a-rate\",defaultValue:0},{name:\"highpass\",automationRate:\"a-rate\",defaultValue:20,minValue:20,maxValue:20000},{name:\"lowpass\",automationRate:\"a-rate\",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let T=z0(this.properties,A.data,currentTime,sampleRate);for(let J of T)this.port.postMessage(J);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,T){try{let J=j0(this.properties,A,T,{currentTime,currentFrame,sampleRate},this.filterState);for(let F of J.messages)this.port.postMessage(F);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:\"frame\",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),J.keepAlive}catch(J){return console.log(J),!0}}}registerProcessor(\"ClipProcessor\",P0);\n\n//# debugId=E1A630180247A19C64756E2164756E21\n//# sourceMappingURL=processor.js.map\n";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// AUTO-GENERATED — do not edit. Run 'bun run build:lib' to regenerate.
|
|
2
|
-
export const processorCode = "var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,F=A>0;return{totalLength:F?A:null,committedLength:F?A:0,streamEnded:F,streaming:!1,writtenSpans:F?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let F=[...V,A].sort((Q,J)=>Q.startSample-J.startSample),T=[];for(let Q of F){let J=T[T.length-1];if(!J||Q.startSample>J.endSample){T.push({...Q});continue}J.endSample=Math.max(J.endSample,Q.endSample)}return T}function I0(V){let A=0;for(let F of V){if(F.startSample>A)break;A=Math.max(A,F.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,F){let T=M0(V.buffer),Q=V.buffer.length;if(T>=F&&Q>=A)return;let J=Math.max(T,F),U=Math.max(Q,A),Y=G0(U,J);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,T));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<J)V.streamBuffer.totalLength=J}function B0(V,A){let F=Math.max(Math.floor(A.startSample),0),T=A.channelData[0]?.length??0,Q=A.totalLength??null,J=Math.max(F+T,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),J);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],F);if(Q!=null)V.streamBuffer.totalLength=Q;if(T>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:F,endSample:F+T}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:F=[],streamBuffer:T=i(F),duration:Q=-1,loop:J=!1,loopStart:U=0,loopEnd:Y=(F[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:F,streamBuffer:T,loop:J,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let F=b0(V,A);if(F<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=F)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>F)V.loopEnd=F}function e(V,A,F){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,F);if(A>(o(V)||1)-1)return e(V,o(V)%A,F);let T=Math.floor(A*F);return V.offset=T,T}function L0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J}=V,U=128;if(!T&&A+128>F)U=Math.max(F-A,0);let Y=Array(U);if(!T){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=F}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=J)X=Q+(X-J),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:F,loop:T,loopStartSamples:Q,loopEndSamples:J,playbackRates:U}=V,Y=128;if(!T&&A+128>F)Y=Math.max(F-A,0);let X=Array(Y),k=A,H=!1;if(T){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),F-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>J||k>F))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=J,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),F-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=F||k<0}}function m0(V,A,F){for(let T=0;T<F.length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=A[Q][F[T]];for(let T=F.length;T<V[0].length;T++)for(let Q=0;Q<V.length;Q++)V[Q][T]=0}function d(V){for(let A=0;A<V.length;A++)for(let F=0;F<V[A].length;F++)V[A][F]=0}function S0(V){let A=new Float32Array(V[0].length);for(let F=0;F<V[0].length;F++)A[F]=V[0][F];V.push(A)}function H0(V,A){for(let F=A.length;F<V.length;F++)A[F]=new Float32Array(V[F].length);for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)A[F][T]=V[F][T]}function c0(V){let A=0;for(let F=0;F<V.length;F++)for(let T=0;T<V[F].length;T++)if(Number.isNaN(V[F][T]))A++,V[F][T]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let T=A[0];if(T===1)return;for(let Q of V)for(let J=0;J<Q.length;J++)Q[J]*=T;return}let F=A[0];for(let T of V)for(let Q=0;Q<T.length;Q++)F=A[Q]??F,T[Q]*=F}function d0(V,A){let F=A[0];for(let T=0;T<V[0].length;T++){F=A[T]??F;let Q=F<=0?1:1-F,J=F>=0?1:1+F;V[0][T]*=Q,V[1][T]*=J}}function h0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<J.length;b++){let c=J[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,J[b]=g}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function l0(V,A,F,T){for(let Q=0;Q<V.length;Q++){let J=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=T[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/F,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<J.length;Z++){let E=J[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,J[Z]=O}}else{let H=A[0];for(let $=0;$<J.length;$++){let j=A[$]??H,P=2*Math.PI*j/F,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=J[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,J[$]=R}}T[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,F,T){let{type:Q,data:J}=A;switch(Q){case\"buffer\":return y0(V,J),n(V,T),[];case\"bufferInit\":{let U=J;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,T),[]}case\"bufferRange\":return V.streamBuffer.pendingWrites.push(J),[];case\"bufferEnd\":{let U=J;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case\"bufferReset\":return V.buffer=[],V.streamBuffer=i(),n(V,T),[];case\"start\":V.timesLooped=0;{let U=J;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/T;e(V,U?.offset,T),n(V,T),V.playhead=V.offset,V.startWhen=U?.when??F,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:\"scheduled\"}];case\"stop\":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=J??V.stopWhen,V.state=z.Stopped,[{type:\"stopped\"}];case\"pause\":return V.state=z.Paused,V.pauseWhen=J??F,[{type:\"paused\"}];case\"resume\":return V.state=z.Started,V.startWhen=J??F,[{type:\"resume\"}];case\"dispose\":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:\"disposed\"}];case\"loop\":{let U=J,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,T);return[]}case\"loopStart\":return V.loopStart=J,[];case\"loopEnd\":return V.loopEnd=J,[];case\"loopCrossfade\":return V.loopCrossfade=J,[];case\"playhead\":return V.playhead=Math.floor(J),[];case\"fadeIn\":return V.fadeInDuration=J,[];case\"fadeOut\":return V.fadeOutDuration=J,[];case\"toggleGain\":return V.enableGain=J??!V.enableGain,[];case\"togglePan\":return V.enablePan=J??!V.enablePan,[];case\"toggleLowpass\":return V.enableLowpass=J??!V.enableLowpass,[];case\"toggleHighpass\":return V.enableHighpass=J??!V.enableHighpass,[];case\"toggleDetune\":return V.enableDetune=J??!V.enableDetune,[];case\"togglePlaybackRate\":return V.enablePlaybackRate=J??!V.enablePlaybackRate,[];case\"toggleFadeIn\":return V.enableFadeIn=J??!V.enableFadeIn,[];case\"toggleFadeOut\":return V.enableFadeOut=J??!V.enableFadeOut,[];case\"toggleLoopStart\":return V.enableLoopStart=J??!V.enableLoopStart,[];case\"toggleLoopEnd\":return V.enableLoopEnd=J??!V.enableLoopEnd,[];case\"toggleLoopCrossfade\":return V.enableLoopCrossfade=J??!V.enableLoopCrossfade,[];case\"logState\":return[]}return[]}function j0(V,A,F,T,Q){let J=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:J};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:J};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:J};if(U===z.Scheduled)if(T.currentTime>=V.startWhen)U=V.state=z.Started,J.push({type:\"started\"});else return d(A[0]),{keepAlive:!0,messages:J};else if(U===z.Paused){if(T.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:J}}if(T.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,J.push({type:\"ended\"}),V.playedSamples=0,{keepAlive:!0,messages:J};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:J};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=F,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,l=Math.min(N.length,Y.length),W0=V.duration*T.sampleRate,Z0=Math.floor(T.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*T.sampleRate),q0):0,x=t?Math.min(Math.floor(w*T.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,u=k;if(J0){let M=Math.max(k.length,H.length,y);u=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];u[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&u.length>0&&u.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)J.push({type:\"bufferLowWater\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:u},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)J.push({type:\"bufferUnderrun\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*T.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<l;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*T.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*T.sampleRate),W=Math.floor(T.sampleRate*(Z-T.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<l;q++)Y[q][I]*=S}}if(O)h0(Y,$,T.sampleRate,Q.lowpass);if(R)l0(Y,j,T.sampleRate,Q.highpass);if(h)g0(Y,P);if(l===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,J.push({type:\"looped\",data:V.timesLooped});if(X0)V.state=z.Ended,J.push({type:\"ended\"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:J};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:J}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:\"playbackRate\",automationRate:\"a-rate\",defaultValue:1},{name:\"detune\",automationRate:\"a-rate\",defaultValue:0},{name:\"gain\",automationRate:\"a-rate\",defaultValue:1,minValue:0},{name:\"pan\",automationRate:\"a-rate\",defaultValue:0},{name:\"highpass\",automationRate:\"a-rate\",defaultValue:20,minValue:20,maxValue:20000},{name:\"lowpass\",automationRate:\"a-rate\",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let F=z0(this.properties,A.data,currentTime,sampleRate);for(let T of F)this.port.postMessage(T);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,F){try{let T=j0(this.properties,A,F,{currentTime,currentFrame,sampleRate},this.filterState);for(let J of T.messages)this.port.postMessage(J);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:\"frame\",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),T.keepAlive}catch(T){return console.log(T),!0}}}registerProcessor(\"ClipProcessor\",P0);\n\n//# debugId=5101232AAE128B1064756E2164756E21\n//# sourceMappingURL=processor.js.map\n";
|
|
2
|
+
export const processorCode = "var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,T=A>0;return{totalLength:T?A:null,committedLength:T?A:0,streamEnded:T,streaming:!1,writtenSpans:T?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let T=[...V,A].sort((Q,F)=>Q.startSample-F.startSample),J=[];for(let Q of T){let F=J[J.length-1];if(!F||Q.startSample>F.endSample){J.push({...Q});continue}F.endSample=Math.max(F.endSample,Q.endSample)}return J}function I0(V){let A=0;for(let T of V){if(T.startSample>A)break;A=Math.max(A,T.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,T){let J=M0(V.buffer),Q=V.buffer.length;if(J>=T&&Q>=A)return;let F=Math.max(J,T),U=Math.max(Q,A),Y=G0(U,F);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,J));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<F)V.streamBuffer.totalLength=F}function B0(V,A){let T=Math.max(Math.floor(A.startSample),0),J=A.channelData[0]?.length??0,Q=A.totalLength??null,F=Math.max(T+J,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),F);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],T);if(Q!=null)V.streamBuffer.totalLength=Q;if(J>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:T,endSample:T+J}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:T=[],streamBuffer:J=i(T),duration:Q=-1,loop:F=!1,loopStart:U=0,loopEnd:Y=(T[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:T,streamBuffer:J,loop:F,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let T=b0(V,A);if(T<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=T)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>T)V.loopEnd=T}function e(V,A,T){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,T);if(A>(o(V)||1)-1)return e(V,o(V)%A,T);let J=Math.floor(A*T);return V.offset=J,J}function L0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F}=V,U=128;if(!J&&A+128>T)U=Math.max(T-A,0);let Y=Array(U);if(!J){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=T}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=F)X=Q+(X-F),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F,playbackRates:U}=V,Y=128;if(!J&&A+128>T)Y=Math.max(T-A,0);let X=Array(Y),k=A,H=!1;if(J){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),T-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>F||k>T))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=F,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),T-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=T||k<0}}function m0(V,A,T){let J=Math.min(V.length,A.length);for(let Q=0;Q<T.length;Q++)for(let F=0;F<J;F++)V[F][Q]=A[F][T[Q]];for(let Q=J;Q<V.length;Q++)for(let F=0;F<V[Q].length;F++)V[Q][F]=0;for(let Q=T.length;Q<V[0].length;Q++)for(let F=0;F<J;F++)V[F][Q]=0}function d(V){for(let A=0;A<V.length;A++)for(let T=0;T<V[A].length;T++)V[A][T]=0}function S0(V){if(V.length>=2)for(let A=0;A<V[0].length;A++)V[1][A]=V[0][A];else{let A=new Float32Array(V[0].length);for(let T=0;T<V[0].length;T++)A[T]=V[0][T];V.push(A)}}function H0(V,A){for(let T=A.length;T<V.length;T++)A[T]=new Float32Array(V[T].length);for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)A[T][J]=V[T][J]}function c0(V){let A=0;for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)if(Number.isNaN(V[T][J]))A++,V[T][J]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let J=A[0];if(J===1)return;for(let Q of V)for(let F=0;F<Q.length;F++)Q[F]*=J;return}let T=A[0];for(let J of V)for(let Q=0;Q<J.length;Q++)T=A[Q]??T,J[Q]*=T}function d0(V,A){let T=A[0];for(let J=0;J<V[0].length;J++){T=A[J]??T;let Q=T<=0?1:1-T,F=T>=0?1:1+T;V[0][J]*=Q,V[1][J]*=F}}function h0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<F.length;b++){let c=F[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,F[b]=g}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function u0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<F.length;Z++){let E=F[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,F[Z]=O}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,T,J){let{type:Q,data:F}=A;switch(Q){case\"buffer\":return y0(V,F),n(V,J),[];case\"bufferInit\":{let U=F;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,J),[]}case\"bufferRange\":return V.streamBuffer.pendingWrites.push(F),[];case\"bufferEnd\":{let U=F;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case\"bufferReset\":return V.buffer=[],V.streamBuffer=i(),n(V,J),[];case\"start\":V.timesLooped=0;{let U=F;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/J;e(V,U?.offset,J),n(V,J),V.playhead=V.offset,V.startWhen=U?.when??T,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:\"scheduled\"}];case\"stop\":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=F??V.stopWhen,V.state=z.Stopped,[{type:\"stopped\"}];case\"pause\":return V.state=z.Paused,V.pauseWhen=F??T,[{type:\"paused\"}];case\"resume\":return V.state=z.Started,V.startWhen=F??T,[{type:\"resume\"}];case\"dispose\":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:\"disposed\"}];case\"loop\":{let U=F,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,J);return[]}case\"loopStart\":return V.loopStart=F,[];case\"loopEnd\":return V.loopEnd=F,[];case\"loopCrossfade\":return V.loopCrossfade=F,[];case\"playhead\":return V.playhead=Math.floor(F),[];case\"fadeIn\":return V.fadeInDuration=F,[];case\"fadeOut\":return V.fadeOutDuration=F,[];case\"toggleGain\":return V.enableGain=F??!V.enableGain,[];case\"togglePan\":return V.enablePan=F??!V.enablePan,[];case\"toggleLowpass\":return V.enableLowpass=F??!V.enableLowpass,[];case\"toggleHighpass\":return V.enableHighpass=F??!V.enableHighpass,[];case\"toggleDetune\":return V.enableDetune=F??!V.enableDetune,[];case\"togglePlaybackRate\":return V.enablePlaybackRate=F??!V.enablePlaybackRate,[];case\"toggleFadeIn\":return V.enableFadeIn=F??!V.enableFadeIn,[];case\"toggleFadeOut\":return V.enableFadeOut=F??!V.enableFadeOut,[];case\"toggleLoopStart\":return V.enableLoopStart=F??!V.enableLoopStart,[];case\"toggleLoopEnd\":return V.enableLoopEnd=F??!V.enableLoopEnd,[];case\"toggleLoopCrossfade\":return V.enableLoopCrossfade=F??!V.enableLoopCrossfade,[];case\"logState\":return[]}return[]}function j0(V,A,T,J,Q){let F=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:F};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:F};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:F};if(U===z.Scheduled)if(J.currentTime>=V.startWhen)U=V.state=z.Started,F.push({type:\"started\"});else return d(A[0]),{keepAlive:!0,messages:F};else if(U===z.Paused){if(J.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:F}}if(J.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,F.push({type:\"ended\"}),V.playedSamples=0,{keepAlive:!0,messages:F};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:F};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=T,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,u=Math.min(N.length,Y.length),W0=V.duration*J.sampleRate,Z0=Math.floor(J.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*J.sampleRate),q0):0,x=t?Math.min(Math.floor(w*J.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,l=k;if(J0){let M=Math.max(k.length,H.length,y);l=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];l[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&l.length>0&&l.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)F.push({type:\"bufferLowWater\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:l},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)F.push({type:\"bufferUnderrun\",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*J.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*J.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*J.sampleRate),W=Math.floor(J.sampleRate*(Z-J.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][I]*=S}}if(O)h0(Y,$,J.sampleRate,Q.lowpass);if(R)u0(Y,j,J.sampleRate,Q.highpass);if(h)g0(Y,P);if(u===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,F.push({type:\"looped\",data:V.timesLooped});if(X0)V.state=z.Ended,F.push({type:\"ended\"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:F};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:\"playbackRate\",automationRate:\"a-rate\",defaultValue:1},{name:\"detune\",automationRate:\"a-rate\",defaultValue:0},{name:\"gain\",automationRate:\"a-rate\",defaultValue:1,minValue:0},{name:\"pan\",automationRate:\"a-rate\",defaultValue:0},{name:\"highpass\",automationRate:\"a-rate\",defaultValue:20,minValue:20,maxValue:20000},{name:\"lowpass\",automationRate:\"a-rate\",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let T=z0(this.properties,A.data,currentTime,sampleRate);for(let J of T)this.port.postMessage(J);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,T){try{let J=j0(this.properties,A,T,{currentTime,currentFrame,sampleRate},this.filterState);for(let F of J.messages)this.port.postMessage(F);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:\"frame\",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),J.keepAlive}catch(J){return console.log(J),!0}}}registerProcessor(\"ClipProcessor\",P0);\n\n//# debugId=E1A630180247A19C64756E2164756E21\n//# sourceMappingURL=processor.js.map\n";
|
|
@@ -256,13 +256,19 @@ export function findIndexesWithPlaybackRates(p) {
|
|
|
256
256
|
// Buffer operations
|
|
257
257
|
// ---------------------------------------------------------------------------
|
|
258
258
|
export function fill(target, source, indexes) {
|
|
259
|
+
const nc = Math.min(target.length, source.length);
|
|
259
260
|
for (let i = 0; i < indexes.length; i++) {
|
|
260
|
-
for (let ch = 0; ch <
|
|
261
|
+
for (let ch = 0; ch < nc; ch++) {
|
|
261
262
|
target[ch][i] = source[ch][indexes[i]];
|
|
262
263
|
}
|
|
263
264
|
}
|
|
265
|
+
for (let ch = nc; ch < target.length; ch++) {
|
|
266
|
+
for (let i = 0; i < target[ch].length; i++) {
|
|
267
|
+
target[ch][i] = 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
264
270
|
for (let i = indexes.length; i < target[0].length; i++) {
|
|
265
|
-
for (let ch = 0; ch <
|
|
271
|
+
for (let ch = 0; ch < nc; ch++) {
|
|
266
272
|
target[ch][i] = 0;
|
|
267
273
|
}
|
|
268
274
|
}
|
|
@@ -275,11 +281,19 @@ export function fillWithSilence(buffer) {
|
|
|
275
281
|
}
|
|
276
282
|
}
|
|
277
283
|
export function monoToStereo(signal) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
284
|
+
if (signal.length >= 2) {
|
|
285
|
+
// Output already has a second channel — copy mono data into it
|
|
286
|
+
for (let i = 0; i < signal[0].length; i++) {
|
|
287
|
+
signal[1][i] = signal[0][i];
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const r = new Float32Array(signal[0].length);
|
|
292
|
+
for (let i = 0; i < signal[0].length; i++) {
|
|
293
|
+
r[i] = signal[0][i];
|
|
294
|
+
}
|
|
295
|
+
signal.push(r);
|
|
281
296
|
}
|
|
282
|
-
signal.push(r);
|
|
283
297
|
}
|
|
284
298
|
export function copy(source, target) {
|
|
285
299
|
for (let i = target.length; i < source.length; i++) {
|
package/dist/audio/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.3";
|
package/dist/audio/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// AUTO-GENERATED — do not edit. Run 'bun run build:lib' to regenerate.
|
|
2
|
-
export const VERSION = "0.1.
|
|
2
|
+
export const VERSION = "0.1.3";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function Ue(e){return Math.max(20*Math.log10(e),-1e3)}function ve(e){return 10**(e/20)}var Je=["beat","bar","8th","16th"];function q(e,t,a){return Math.min(Math.max(e,t),a)}function ge(e){return Je.includes(e)}function X(e,t){if(!Number.isFinite(t)||t<=0)return null;let a=60/t;switch(e){case"beat":return a;case"bar":return a*4;case"8th":return a/2;case"16th":return a/4;default:return null}}function Ne(e,t,a,o,r,n){if(!ge(t)||e<0)return q(e,r,n);let s=X(t,a),l=X(t,o);if(s==null||l==null)return q(e,r,n);let i=Math.round(e/s);return q(i*l,r,n)}function $e(e,t,a){let o=X(t,a);return o!=null?Math.round(e/o)*o:t==="int"?Math.round(e):e}var Qe={hertz:{snaps:[32,64,128,256,512,1024,2048,4096,8192,16384],ticks:[64,128,256,512,1024,2048,4096,8192,16384],min:32,max:16384,logarithmic:!0},decibel:{ticks:[-48,-24,-12,-6,-3,0],min:-60,max:0,skew:1},cents:{snaps:Array.from({length:49},(e,t)=>(t-24)*100),ticks:[-2400,-1200,0,1200,2400],min:-2400,max:2400,skew:1,step:1},playbackRate:{snaps:[-2,-1,-.5,0,.5,1,1.5,2],ticks:[-2,-1,0,1,2],min:-2,max:2,skew:1},gain:{snaps:[-60,-48,-36,-24,-18,-12,-9,-6,-3,-1,0],ticks:[-48,-24,-12,-6,-3,0],min:-100,max:0,skew:6},pan:{snaps:[-1,-.75,-.5,-.25,0,.25,.5,.75,1],ticks:[-1,-.5,0,.5,1],min:-1,max:1,skew:1}};function Xe(e){return e.numberOfChannels===1?[e.getChannelData(0)]:[e.getChannelData(0),e.getChannelData(1)]}function ae(e,t){if(!t||t.length===0)return;let a=e.createBuffer(t.length,t[0].length,e.sampleRate);for(let o=0;o<t.length;o++)a.copyToChannel(new Float32Array(t[o]),o);return a}function Ke(e,t,a,o){let r=X(e,t)??(e==="int"?1:null);if(r==null)return[];if(r<=0)return[];let n=[],s=Math.ceil(a/r)*r;for(let l=s;l<=o;l+=r)n.push(Math.round(l*1e10)/1e10);return n}var oe=class extends AudioWorkletNode{onscheduled;onstarted;onpaused;onresumed;onended;onlooped;onstopped;onframe;ondisposed;onstatechange;_buffer;_loopStart=0;_loopEnd=0;_loop=!1;_offset=0;_playhead=0;_fadeIn=0;_fadeOut=0;_loopCrossfade=0;_duration=-1;_previousState="initial";_bufferWriteCursor=0;timesLooped=0;state="initial";cpu=0;constructor(t,a={}){super(t,"ClipProcessor",{numberOfInputs:a.numberOfInputs??0,outputChannelCount:a.outputChannelCount??[2],processorOptions:a.processorOptions,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs,parameterData:a.parameterData}),this._buffer=ae(this.context,a.processorOptions?.buffer),this.port.onmessage=this.handleMessage}handleMessage=t=>{let{type:a,data:o}=t.data;switch(a){case"frame":{let[r,n,s,l]=o;this._playhead=s,this.cpu=l,this.onframe?.(o);break}case"scheduled":this.setState("scheduled"),this.onscheduled?.();break;case"started":this.setState("started"),this.onstarted?.();break;case"stopped":this.setState("stopped"),this.onstopped?.();break;case"paused":this.setState("paused"),this.onpaused?.();break;case"resume":this.setState("resumed"),this.onresumed?.();break;case"ended":this.setState("ended"),this.onended?.();break;case"looped":this.timesLooped++,this.onlooped?.();break;case"disposed":this.setState("disposed");break}};setState(t){this._previousState=this.state,this.state=t,this.state!==this._previousState&&this.onstatechange?.(this.state)}toggleGain(t=!0){this.port.postMessage({type:"toggleGain",data:t})}togglePlaybackRate(t=!0){this.port.postMessage({type:"togglePlaybackRate",data:t})}toggleDetune(t=!0){this.port.postMessage({type:"toggleDetune",data:t})}togglePan(t=!0){this.port.postMessage({type:"togglePan",data:t})}toggleHighpass(t=!0){this.port.postMessage({type:"toggleHighpass",data:t})}toggleLowpass(t=!0){this.port.postMessage({type:"toggleLowpass",data:t})}toggleFadeIn(t=!0){this.port.postMessage({type:"toggleFadeIn",data:t})}toggleFadeOut(t=!0){this.port.postMessage({type:"toggleFadeOut",data:t})}toggleLoopCrossfade(t=!0){this.port.postMessage({type:"toggleLoopCrossfade",data:t})}toggleLoopStart(t=!0){this.port.postMessage({type:"toggleLoopStart",data:t})}toggleLoopEnd(t=!0){this.port.postMessage({type:"toggleLoopEnd",data:t})}logState(){this.port.postMessage({type:"logState"})}get buffer(){return this._buffer}set buffer(t){this._buffer=t,this._bufferWriteCursor=t.length,this._loopStart>=t.duration&&(this._loopStart=0),(this._loopEnd<=this._loopStart||this._loopEnd>t.duration)&&(this._loopEnd=t.duration);let a=t.numberOfChannels===1?[t.getChannelData(0)]:[t.getChannelData(0),t.getChannelData(1)];this.port.postMessage({type:"buffer",data:a}),this.port.postMessage({type:"loopStart",data:this._loopStart}),this.port.postMessage({type:"loopEnd",data:this._loopEnd})}initializeBuffer(t,a,o={}){this._buffer=this.context.createBuffer(a,t,this.context.sampleRate),this._bufferWriteCursor=0;let r=t/this.context.sampleRate;this._loopStart>=r&&(this._loopStart=0),(this._loopEnd<=this._loopStart||this._loopEnd>r)&&(this._loopEnd=r),this.port.postMessage({type:"bufferInit",data:{channels:a,totalLength:t,streaming:o.streaming??!0}}),this.port.postMessage({type:"loopStart",data:this._loopStart}),this.port.postMessage({type:"loopEnd",data:this._loopEnd})}replaceBufferRange(t,a,o={}){this.port.postMessage({type:"bufferRange",data:{startSample:t,channelData:a,totalLength:o.totalLength,streamEnded:o.streamEnded}}),this._bufferWriteCursor=Math.max(this._bufferWriteCursor,t+(a[0]?.length??0))}appendBufferRange(t,a={}){this.replaceBufferRange(this._bufferWriteCursor,t,a)}finalizeBuffer(t){this.port.postMessage({type:"bufferEnd",data:{totalLength:t}})}start(t,a,o){if(!this._buffer){console.error("Buffer not set.");return}this.port.postMessage({type:"start",data:{when:t,offset:a,duration:o}})}stop(t=this.context.currentTime,a=0){this.port.postMessage({type:"stop",data:t+a+this._fadeOut+.2})}pause(t=this.context.currentTime){this.port.postMessage({type:"pause",data:t})}resume(t=this.context.currentTime){this.port.postMessage({type:"resume",data:t})}get loop(){return this._loop}set loop(t){this._loop!==t&&(this._loop=t,this.port.postMessage({type:"loop",data:t}))}get loopStart(){return this._loopStart}set loopStart(t){t!==this._loopStart&&(this._loopStart=t,this.port.postMessage({type:"loopStart",data:t}))}get loopEnd(){return this._loopEnd}set loopEnd(t){t!==this._loopEnd&&(this._loopEnd=t,this.port.postMessage({type:"loopEnd",data:t}))}get duration(){return this._duration??this._buffer?.duration??-1}set duration(t){this._duration=t}get offset(){return this._offset}set offset(t){this._offset=t}get playhead(){return this._playhead}set playhead(t){this.port.postMessage({type:"playhead",data:t})}get playbackRate(){return this.parameters.get("playbackRate")}get detune(){return this.parameters.get("detune")}get highpass(){return this.parameters.get("highpass")}get lowpass(){return this.parameters.get("lowpass")}get gain(){return this.parameters.get("gain")}get pan(){return this.parameters.get("pan")}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this.port.postMessage({type:"fadeIn",data:t})}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this.port.postMessage({type:"fadeOut",data:t})}get loopCrossfade(){return this._loopCrossfade}set loopCrossfade(t){this._loopCrossfade=t,this.port.postMessage({type:"loopCrossfade",data:t})}dispose(){this.port.postMessage({type:"dispose"}),this.port.close(),this.ondisposed?.(),this._buffer=void 0,this.onended=void 0,this.onframe=void 0,this.onlooped=void 0,this.onpaused=void 0,this.onresumed=void 0,this.onstarted=void 0,this.onstopped=void 0,this.onscheduled=void 0,this.onstatechange=void 0,this.ondisposed=void 0,this.state="disposed"}};var ne=`var z={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var y=128;function i(V=[]){let A=V[0]?.length??0,T=A>0;return{totalLength:T?A:null,committedLength:T?A:0,streamEnded:T,streaming:!1,writtenSpans:T?[{startSample:0,endSample:A}]:[],pendingWrites:[],lowWaterThreshold:y*4,lowWaterNotified:!1,lastUnderrunSample:null}}function M0(V){return V[0]?.length??0}function o(V){return V.streamBuffer.totalLength??M0(V.buffer)}function G0(V,A){return Array.from({length:V},()=>new Float32Array(A))}function E0(V,A){let T=[...V,A].sort((Q,F)=>Q.startSample-F.startSample),J=[];for(let Q of T){let F=J[J.length-1];if(!F||Q.startSample>F.endSample){J.push({...Q});continue}F.endSample=Math.max(F.endSample,Q.endSample)}return J}function I0(V){let A=0;for(let T of V){if(T.startSample>A)break;A=Math.max(A,T.endSample)}return A}function w0(V,A){if(V.committedLength-Math.floor(A)>=V.lowWaterThreshold)V.lowWaterNotified=!1}function R0(V,A,T){let J=M0(V.buffer),Q=V.buffer.length;if(J>=T&&Q>=A)return;let F=Math.max(J,T),U=Math.max(Q,A),Y=G0(U,F);for(let X=0;X<Q;X++)Y[X].set(V.buffer[X].subarray(0,J));if(V.buffer=Y,V.streamBuffer.totalLength==null||V.streamBuffer.totalLength<F)V.streamBuffer.totalLength=F}function B0(V,A){let T=Math.max(Math.floor(A.startSample),0),J=A.channelData[0]?.length??0,Q=A.totalLength??null,F=Math.max(T+J,Q??0);R0(V,Math.max(A.channelData.length,V.buffer.length,1),F);for(let U=0;U<A.channelData.length;U++)V.buffer[U].set(A.channelData[U],T);if(Q!=null)V.streamBuffer.totalLength=Q;if(J>0)V.streamBuffer.writtenSpans=E0(V.streamBuffer.writtenSpans,{startSample:T,endSample:T+J}),V.streamBuffer.committedLength=I0(V.streamBuffer.writtenSpans);if(A.streamEnded===!0)V.streamBuffer.streamEnded=!0;w0(V.streamBuffer,V.playhead)}function _0(V){if(V.streamBuffer.pendingWrites.length===0)return;for(let A of V.streamBuffer.pendingWrites)B0(V,A);V.streamBuffer.pendingWrites=[]}function y0(V,A){V.buffer=A,V.streamBuffer=i(A)}function v0(V={},A){let{buffer:T=[],streamBuffer:J=i(T),duration:Q=-1,loop:F=!1,loopStart:U=0,loopEnd:Y=(T[0]?.length??0)/A,loopCrossfade:X=0,playhead:k=0,offset:H=0,startWhen:$=0,stopWhen:j=0,pauseWhen:P=0,resumeWhen:C=0,playedSamples:N=0,state:K=z.Initial,timesLooped:w=0,fadeInDuration:v=0,fadeOutDuration:Z=0,enableFadeIn:E=v>0,enableFadeOut:O=Z>0,enableLoopStart:R=!0,enableLoopEnd:h=!0,enableLoopCrossfade:b=X>0,enableHighpass:c=!0,enableLowpass:g=!0,enableGain:s=!0,enablePan:r=!0,enableDetune:t=!0,enablePlaybackRate:p=!0}=V;return{buffer:T,streamBuffer:J,loop:F,loopStart:U,loopEnd:Y,loopCrossfade:X,duration:Q,playhead:k,offset:H,startWhen:$,stopWhen:j,pauseWhen:P,resumeWhen:C,playedSamples:N,state:K,timesLooped:w,fadeInDuration:v,fadeOutDuration:Z,enableFadeIn:E,enableFadeOut:O,enableLoopStart:R,enableLoopEnd:h,enableHighpass:c,enableLowpass:g,enableGain:s,enablePan:r,enableDetune:t,enablePlaybackRate:p,enableLoopCrossfade:b}}function b0(V,A){return o(V)/A}function n(V,A){let T=b0(V,A);if(T<=0){V.loopStart=0,V.loopEnd=0;return}if(!Number.isFinite(V.loopStart)||V.loopStart<0)V.loopStart=0;if(V.loopStart>=T)V.loopStart=0;if(!Number.isFinite(V.loopEnd)||V.loopEnd<=V.loopStart||V.loopEnd>T)V.loopEnd=T}function e(V,A,T){if(A===void 0)return V.offset=0,0;if(A<0)return e(V,o(V)+A,T);if(A>(o(V)||1)-1)return e(V,o(V)%A,T);let J=Math.floor(A*T);return V.offset=J,J}function L0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F}=V,U=128;if(!J&&A+128>T)U=Math.max(T-A,0);let Y=Array(U);if(!J){for(let $=0,j=A;$<U;$++,j++)Y[$]=j;let H=A+U;return{playhead:H,indexes:Y,looped:!1,ended:H>=T}}let X=A,k=!1;for(let H=0;H<U;H++,X++){if(X>=F)X=Q+(X-F),k=!0;Y[H]=X}return{indexes:Y,looped:k,ended:!1,playhead:X}}function x0(V){let{playhead:A,bufferLength:T,loop:J,loopStartSamples:Q,loopEndSamples:F,playbackRates:U}=V,Y=128;if(!J&&A+128>T)Y=Math.max(T-A,0);let X=Array(Y),k=A,H=!1;if(J){for(let $=0;$<Y;$++){X[$]=Math.min(Math.max(Math.floor(k),0),T-1);let j=U[$]??U[0]??1;if(k+=j,j>=0&&(k>F||k>T))k=Q,H=!0;else if(j<0&&(k<Q||k<0))k=F,H=!0}return{playhead:k,indexes:X,looped:H,ended:!1}}for(let $=0;$<Y;$++)X[$]=Math.min(Math.max(Math.floor(k),0),T-1),k+=U[$]??U[0]??1;return{playhead:k,indexes:X,looped:!1,ended:k>=T||k<0}}function m0(V,A,T){let J=Math.min(V.length,A.length);for(let Q=0;Q<T.length;Q++)for(let F=0;F<J;F++)V[F][Q]=A[F][T[Q]];for(let Q=J;Q<V.length;Q++)for(let F=0;F<V[Q].length;F++)V[Q][F]=0;for(let Q=T.length;Q<V[0].length;Q++)for(let F=0;F<J;F++)V[F][Q]=0}function d(V){for(let A=0;A<V.length;A++)for(let T=0;T<V[A].length;T++)V[A][T]=0}function S0(V){if(V.length>=2)for(let A=0;A<V[0].length;A++)V[1][A]=V[0][A];else{let A=new Float32Array(V[0].length);for(let T=0;T<V[0].length;T++)A[T]=V[0][T];V.push(A)}}function H0(V,A){for(let T=A.length;T<V.length;T++)A[T]=new Float32Array(V[T].length);for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)A[T][J]=V[T][J]}function c0(V){let A=0;for(let T=0;T<V.length;T++)for(let J=0;J<V[T].length;J++)if(Number.isNaN(V[T][J]))A++,V[T][J]=0;return A}function V0(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function g0(V,A){if(A.length===1){let J=A[0];if(J===1)return;for(let Q of V)for(let F=0;F<Q.length;F++)Q[F]*=J;return}let T=A[0];for(let J of V)for(let Q=0;Q<J.length;Q++)T=A[Q]??T,J[Q]*=T}function d0(V,A){let T=A[0];for(let J=0;J<V[0].length;J++){T=A[J]??T;let Q=T<=0?1:1-T,F=T>=0?1:1+T;V[0][J]*=Q,V[1][J]*=F}}function h0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H>=20000)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1-Math.cos($))/2,C=1-Math.cos($),N=(1-Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j,Z=P/K,E=C/K,O=N/K,R=w/K,h=v/K;for(let b=0;b<F.length;b++){let c=F[b],g=Z*c+E*U+O*Y-R*X-h*k;Y=U,U=c,k=X,X=g,F[b]=g}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1-Math.cos(P))/2,K=1-Math.cos(P),w=(1-Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function u0(V,A,T,J){for(let Q=0;Q<V.length;Q++){let F=V[Q],{x_1:U,x_2:Y,y_1:X,y_2:k}=J[Q]??{x_1:0,x_2:0,y_1:0,y_2:0};if(A.length===1){let H=A[0];if(H<=20)return;let $=2*Math.PI*H/T,j=Math.sin($)/2,P=(1+Math.cos($))/2,C=-(1+Math.cos($)),N=(1+Math.cos($))/2,K=1+j,w=-2*Math.cos($),v=1-j;for(let Z=0;Z<F.length;Z++){let E=F[Z],O=P/K*E+C/K*U+N/K*Y-w/K*X-v/K*k;Y=U,U=E,k=X,X=O,F[Z]=O}}else{let H=A[0];for(let $=0;$<F.length;$++){let j=A[$]??H,P=2*Math.PI*j/T,C=Math.sin(P)/2,N=(1+Math.cos(P))/2,K=-(1+Math.cos(P)),w=(1+Math.cos(P))/2,v=1+C,Z=-2*Math.cos(P),E=1-C,O=F[$],R=N/v*O+K/v*U+w/v*Y-Z/v*X-E/v*k;Y=U,U=O,k=X,X=R,F[$]=R}}J[Q]={x_1:U,x_2:Y,y_1:X,y_2:k}}}function z0(V,A,T,J){let{type:Q,data:F}=A;switch(Q){case"buffer":return y0(V,F),n(V,J),[];case"bufferInit":{let U=F;return V.buffer=G0(U.channels,U.totalLength),V.streamBuffer={...i(),totalLength:U.totalLength,streamEnded:!1,streaming:U.streaming??!0},n(V,J),[]}case"bufferRange":return V.streamBuffer.pendingWrites.push(F),[];case"bufferEnd":{let U=F;if(U?.totalLength!=null)V.streamBuffer.totalLength=U.totalLength;return V.streamBuffer.streamEnded=!0,[]}case"bufferReset":return V.buffer=[],V.streamBuffer=i(),n(V,J),[];case"start":V.timesLooped=0;{let U=F;if(V.duration=U?.duration??-1,V.duration===-1)V.duration=V.loop?Number.MAX_SAFE_INTEGER:(V.buffer[0]?.length??0)/J;e(V,U?.offset,J),n(V,J),V.playhead=V.offset,V.startWhen=U?.when??T,V.stopWhen=V.startWhen+V.duration,V.playedSamples=0,V.state=z.Scheduled}return[{type:"scheduled"}];case"stop":if(V.state===z.Ended||V.state===z.Initial)return[];return V.stopWhen=F??V.stopWhen,V.state=z.Stopped,[{type:"stopped"}];case"pause":return V.state=z.Paused,V.pauseWhen=F??T,[{type:"paused"}];case"resume":return V.state=z.Started,V.startWhen=F??T,[{type:"resume"}];case"dispose":return V.state=z.Disposed,V.buffer=[],V.streamBuffer=i(),[{type:"disposed"}];case"loop":{let U=F,Y=V.state;if(U&&(Y===z.Scheduled||Y===z.Started))V.stopWhen=Number.MAX_SAFE_INTEGER,V.duration=Number.MAX_SAFE_INTEGER;if(V.loop=U,U)n(V,J);return[]}case"loopStart":return V.loopStart=F,[];case"loopEnd":return V.loopEnd=F,[];case"loopCrossfade":return V.loopCrossfade=F,[];case"playhead":return V.playhead=Math.floor(F),[];case"fadeIn":return V.fadeInDuration=F,[];case"fadeOut":return V.fadeOutDuration=F,[];case"toggleGain":return V.enableGain=F??!V.enableGain,[];case"togglePan":return V.enablePan=F??!V.enablePan,[];case"toggleLowpass":return V.enableLowpass=F??!V.enableLowpass,[];case"toggleHighpass":return V.enableHighpass=F??!V.enableHighpass,[];case"toggleDetune":return V.enableDetune=F??!V.enableDetune,[];case"togglePlaybackRate":return V.enablePlaybackRate=F??!V.enablePlaybackRate,[];case"toggleFadeIn":return V.enableFadeIn=F??!V.enableFadeIn,[];case"toggleFadeOut":return V.enableFadeOut=F??!V.enableFadeOut,[];case"toggleLoopStart":return V.enableLoopStart=F??!V.enableLoopStart,[];case"toggleLoopEnd":return V.enableLoopEnd=F??!V.enableLoopEnd,[];case"toggleLoopCrossfade":return V.enableLoopCrossfade=F??!V.enableLoopCrossfade,[];case"logState":return[]}return[]}function j0(V,A,T,J,Q){let F=[],U=V.state;if(U===z.Disposed)return{keepAlive:!1,messages:F};if(_0(V),U===z.Initial)return{keepAlive:!0,messages:F};if(U===z.Ended)return d(A[0]),{keepAlive:!0,messages:F};if(U===z.Scheduled)if(J.currentTime>=V.startWhen)U=V.state=z.Started,F.push({type:"started"});else return d(A[0]),{keepAlive:!0,messages:F};else if(U===z.Paused){if(J.currentTime>V.pauseWhen)return d(A[0]),{keepAlive:!0,messages:F}}if(J.currentTime>V.stopWhen)return d(A[0]),V.state=z.Ended,F.push({type:"ended"}),V.playedSamples=0,{keepAlive:!0,messages:F};let Y=A[0],X=o(V);if(X===0)return d(Y),{keepAlive:!0,messages:F};let{playbackRate:k,detune:H,lowpass:$,highpass:j,gain:P,pan:C}=T,{buffer:N,loopStart:K,loopEnd:w,loopCrossfade:v,stopWhen:Z,playedSamples:E,enableLowpass:O,enableHighpass:R,enableGain:h,enablePan:b,enableDetune:c,enableFadeOut:g,enableFadeIn:s,enableLoopStart:r,enableLoopEnd:t,enableLoopCrossfade:p,playhead:D,fadeInDuration:A0,fadeOutDuration:F0}=V,K0=V.streamBuffer.streaming&&V.streamBuffer.committedLength<X,T0=V.loop&&!K0,u=Math.min(N.length,Y.length),W0=V.duration*J.sampleRate,Z0=Math.floor(J.sampleRate*v),q0=Math.max(X-y,0),L=r?Math.min(Math.floor(K*J.sampleRate),q0):0,x=t?Math.min(Math.floor(w*J.sampleRate),X):X,N0=x-L,J0=c&&H.length>0&&H[0]!==0,l=k;if(J0){let M=Math.max(k.length,H.length,y);l=new Float32Array(M);for(let W=0;W<M;W++){let I=k[W]??k[k.length-1],G=H[W]??H[H.length-1];l[W]=I*2**(G/1200)}}let Q0=V.enablePlaybackRate||J0,O0=Q0&&l.length>0&&l.every((M)=>M===0);if(V.streamBuffer.streaming&&!V.streamBuffer.streamEnded&&!V.streamBuffer.lowWaterNotified&&V.streamBuffer.committedLength-Math.floor(D)<V.streamBuffer.lowWaterThreshold)F.push({type:"bufferLowWater",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength}}),V.streamBuffer.lowWaterNotified=!0;if(O0){d(Y);for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}let U0={bufferLength:X,loop:T0,playhead:D,loopStartSamples:L,loopEndSamples:x,durationSamples:W0,playbackRates:l},{indexes:a,ended:X0,looped:Y0,playhead:$0}=Q0?x0(U0):L0(U0),f=a.find((M)=>M>=V.streamBuffer.committedLength&&M<X);if(f!==void 0&&!V.streamBuffer.streamEnded&&V.streamBuffer.lastUnderrunSample!==f)F.push({type:"bufferUnderrun",data:{playhead:Math.floor(D),committedLength:V.streamBuffer.committedLength,requestedSample:f}}),V.streamBuffer.lastUnderrunSample=f;else if(f===void 0)V.streamBuffer.lastUnderrunSample=null;m0(Y,N,a);let m=Math.min(Math.floor(v*J.sampleRate),N0),D0=T0&&D>L&&D<x,C0=p&&Z0>0&&X>y;if(D0&&C0){{let M=L+m;if(m>0&&D>L&&D<M){let W=D-L,I=Math.min(Math.floor(M-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.cos(Math.PI*B/2),q=Math.floor(x-m+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}{let M=x-m;if(m>0&&D>M&&D<x){let W=D-M,I=Math.min(Math.floor(x-D),y);for(let G=0;G<I;G++){let B=(W+G)/m,S=Math.sin(Math.PI*B/2),q=Math.floor(L+W+G);if(q>=0&&q<X)for(let _=0;_<u;_++)Y[_][G]+=N[_][q]*S}}}}if(s&&A0>0){let M=Math.floor(A0*J.sampleRate),W=M-E;if(W>0){let I=Math.min(W,y);for(let G=0;G<I;G++){let B=(E+G)/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][G]*=S}}}if(g&&F0>0){let M=Math.floor(F0*J.sampleRate),W=Math.floor(J.sampleRate*(Z-J.currentTime));if(W<M+y)for(let I=0;I<y;I++){let G=W-I;if(G>=M)continue;let B=G<=0?0:G/M,S=B*B*B;for(let q=0;q<u;q++)Y[q][I]*=S}}if(O)h0(Y,$,J.sampleRate,Q.lowpass);if(R)u0(Y,j,J.sampleRate,Q.highpass);if(h)g0(Y,P);if(u===1)S0(Y);if(b)d0(Y,C);if(Y0)V.timesLooped++,F.push({type:"looped",data:V.timesLooped});if(X0)V.state=z.Ended,F.push({type:"ended"});V.playedSamples+=a.length,V.playhead=$0;let k0=c0(Y);if(k0>0)return console.log({numNans:k0,indexes:a,playhead:$0,ended:X0,looped:Y0,sourceLength:X}),{keepAlive:!0,messages:F};for(let M=1;M<A.length;M++)H0(Y,A[M]);return{keepAlive:!0,messages:F}}class P0 extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:"playbackRate",automationRate:"a-rate",defaultValue:1},{name:"detune",automationRate:"a-rate",defaultValue:0},{name:"gain",automationRate:"a-rate",defaultValue:1,minValue:0},{name:"pan",automationRate:"a-rate",defaultValue:0},{name:"highpass",automationRate:"a-rate",defaultValue:20,minValue:20,maxValue:20000},{name:"lowpass",automationRate:"a-rate",defaultValue:20000,minValue:20,maxValue:20000}]}properties;filterState={lowpass:V0(),highpass:V0()};lastFrameTime=0;constructor(V){super(V);this.properties=v0(V?.processorOptions,sampleRate),this.port.onmessage=(A)=>{let T=z0(this.properties,A.data,currentTime,sampleRate);for(let J of T)this.port.postMessage(J);if(this.properties.state===z.Disposed)this.port.close()}}process(V,A,T){try{let J=j0(this.properties,A,T,{currentTime,currentFrame,sampleRate},this.filterState);for(let F of J.messages)this.port.postMessage(F);let Q=currentTime-this.lastFrameTime;return this.lastFrameTime=currentTime,this.port.postMessage({type:"frame",data:[currentTime,currentFrame,Math.floor(this.properties.playhead),Q*1000]}),J.keepAlive}catch(J){return console.log(J),!0}}}registerProcessor("ClipProcessor",P0);
|
|
2
|
+
|
|
3
|
+
//# debugId=E1A630180247A19C64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=processor.js.map
|
|
5
|
+
`;var b={Initial:0,Started:1,Stopped:2,Paused:3,Scheduled:4,Ended:5,Disposed:6};var T=128;function G(e=[]){let t=e[0]?.length??0,a=t>0;return{totalLength:a?t:null,committedLength:a?t:0,streamEnded:a,streaming:!1,writtenSpans:a?[{startSample:0,endSample:t}]:[],pendingWrites:[],lowWaterThreshold:T*4,lowWaterNotified:!1,lastUnderrunSample:null}}function ye(e){return e[0]?.length??0}function H(e){return e.streamBuffer.totalLength??ye(e.buffer)}function Se(e,t){return Array.from({length:e},()=>new Float32Array(t))}function Ge(e,t){let a=[...e,t].sort((r,n)=>r.startSample-n.startSample),o=[];for(let r of a){let n=o[o.length-1];if(!n||r.startSample>n.endSample){o.push({...r});continue}n.endSample=Math.max(n.endSample,r.endSample)}return o}function He(e){let t=0;for(let a of e){if(a.startSample>t)break;t=Math.max(t,a.endSample)}return t}function Ye(e,t){e.committedLength-Math.floor(t)>=e.lowWaterThreshold&&(e.lowWaterNotified=!1)}function qe(e,t,a){let o=ye(e.buffer),r=e.buffer.length;if(o>=a&&r>=t)return;let n=Math.max(o,a),s=Math.max(r,t),l=Se(s,n);for(let i=0;i<r;i++)l[i].set(e.buffer[i].subarray(0,o));e.buffer=l,(e.streamBuffer.totalLength==null||e.streamBuffer.totalLength<n)&&(e.streamBuffer.totalLength=n)}function je(e,t){let a=Math.max(Math.floor(t.startSample),0),o=t.channelData[0]?.length??0,r=t.totalLength??null,n=Math.max(a+o,r??0);qe(e,Math.max(t.channelData.length,e.buffer.length,1),n);for(let s=0;s<t.channelData.length;s++)e.buffer[s].set(t.channelData[s],a);r!=null&&(e.streamBuffer.totalLength=r),o>0&&(e.streamBuffer.writtenSpans=Ge(e.streamBuffer.writtenSpans,{startSample:a,endSample:a+o}),e.streamBuffer.committedLength=He(e.streamBuffer.writtenSpans)),t.streamEnded===!0&&(e.streamBuffer.streamEnded=!0),Ye(e.streamBuffer,e.playhead)}function ze(e){if(e.streamBuffer.pendingWrites.length!==0){for(let t of e.streamBuffer.pendingWrites)je(e,t);e.streamBuffer.pendingWrites=[]}}function Ze(e,t){e.buffer=t,e.streamBuffer=G(t)}function et(e={},t){let{buffer:a=[],streamBuffer:o=G(a),duration:r=-1,loop:n=!1,loopStart:s=0,loopEnd:l=(a[0]?.length??0)/t,loopCrossfade:i=0,playhead:f=0,offset:d=0,startWhen:u=0,stopWhen:c=0,pauseWhen:m=0,resumeWhen:M=0,playedSamples:A=0,state:y=b.Initial,timesLooped:k=0,fadeInDuration:g=0,fadeOutDuration:x=0,enableFadeIn:L=g>0,enableFadeOut:C=x>0,enableLoopStart:R=!0,enableLoopEnd:J=!0,enableLoopCrossfade:_=i>0,enableHighpass:W=!0,enableLowpass:U=!0,enableGain:z=!0,enablePan:Z=!0,enableDetune:ee=!0,enablePlaybackRate:te=!0}=e;return{buffer:a,streamBuffer:o,loop:n,loopStart:s,loopEnd:l,loopCrossfade:i,duration:r,playhead:f,offset:d,startWhen:u,stopWhen:c,pauseWhen:m,resumeWhen:M,playedSamples:A,state:y,timesLooped:k,fadeInDuration:g,fadeOutDuration:x,enableFadeIn:L,enableFadeOut:C,enableLoopStart:R,enableLoopEnd:J,enableHighpass:W,enableLowpass:U,enableGain:z,enablePan:Z,enableDetune:ee,enablePlaybackRate:te,enableLoopCrossfade:_}}function tt(e,t){return H(e)/t}function K(e,t){let a=tt(e,t);if(a<=0){e.loopStart=0,e.loopEnd=0;return}(!Number.isFinite(e.loopStart)||e.loopStart<0)&&(e.loopStart=0),e.loopStart>=a&&(e.loopStart=0),(!Number.isFinite(e.loopEnd)||e.loopEnd<=e.loopStart||e.loopEnd>a)&&(e.loopEnd=a)}function re(e,t,a){if(t===void 0)return e.offset=0,0;if(t<0)return re(e,H(e)+t,a);if(t>(H(e)||1)-1)return re(e,H(e)%t,a);let o=Math.floor(t*a);return e.offset=o,o}function at(e){let{playhead:t,bufferLength:a,loop:o,loopStartSamples:r,loopEndSamples:n}=e,s=128;!o&&t+128>a&&(s=Math.max(a-t,0));let l=new Array(s);if(!o){for(let u=0,c=t;u<s;u++,c++)l[u]=c;let d=t+s;return{playhead:d,indexes:l,looped:!1,ended:d>=a}}let i=t,f=!1;for(let d=0;d<s;d++,i++)i>=n&&(i=r+(i-n),f=!0),l[d]=i;return{indexes:l,looped:f,ended:!1,playhead:i}}function ot(e){let{playhead:t,bufferLength:a,loop:o,loopStartSamples:r,loopEndSamples:n,playbackRates:s}=e,l=128;!o&&t+128>a&&(l=Math.max(a-t,0));let i=new Array(l),f=t,d=!1;if(o){for(let u=0;u<l;u++){i[u]=Math.min(Math.max(Math.floor(f),0),a-1);let c=s[u]??s[0]??1;f+=c,c>=0&&(f>n||f>a)?(f=r,d=!0):c<0&&(f<r||f<0)&&(f=n,d=!0)}return{playhead:f,indexes:i,looped:d,ended:!1}}for(let u=0;u<l;u++)i[u]=Math.min(Math.max(Math.floor(f),0),a-1),f+=s[u]??s[0]??1;return{playhead:f,indexes:i,looped:!1,ended:f>=a||f<0}}function nt(e,t,a){let o=Math.min(e.length,t.length);for(let r=0;r<a.length;r++)for(let n=0;n<o;n++)e[n][r]=t[n][a[r]];for(let r=o;r<e.length;r++)for(let n=0;n<e[r].length;n++)e[r][n]=0;for(let r=a.length;r<e[0].length;r++)for(let n=0;n<o;n++)e[n][r]=0}function v(e){for(let t=0;t<e.length;t++)for(let a=0;a<e[t].length;a++)e[t][a]=0}function rt(e){if(e.length>=2)for(let t=0;t<e[0].length;t++)e[1][t]=e[0][t];else{let t=new Float32Array(e[0].length);for(let a=0;a<e[0].length;a++)t[a]=e[0][a];e.push(t)}}function be(e,t){for(let a=t.length;a<e.length;a++)t[a]=new Float32Array(e[a].length);for(let a=0;a<e.length;a++)for(let o=0;o<e[a].length;o++)t[a][o]=e[a][o]}function st(e){let t=0;for(let a=0;a<e.length;a++)for(let o=0;o<e[a].length;o++)Number.isNaN(e[a][o])&&(t++,e[a][o]=0);return t}function lt(){return[{x_1:0,x_2:0,y_1:0,y_2:0},{x_1:0,x_2:0,y_1:0,y_2:0}]}function it(e,t){if(t.length===1){let o=t[0];if(o===1)return;for(let r of e)for(let n=0;n<r.length;n++)r[n]*=o;return}let a=t[0];for(let o of e)for(let r=0;r<o.length;r++)a=t[r]??a,o[r]*=a}function ut(e,t){let a=t[0];for(let o=0;o<e[0].length;o++){a=t[o]??a;let r=a<=0?1:1-a,n=a>=0?1:1+a;e[0][o]*=r,e[1][o]*=n}}function ft(e,t,a,o){for(let r=0;r<e.length;r++){let n=e[r],{x_1:s,x_2:l,y_1:i,y_2:f}=o[r]??{x_1:0,x_2:0,y_1:0,y_2:0};if(t.length===1){let d=t[0];if(d>=2e4)return;let u=2*Math.PI*d/a,c=Math.sin(u)/2,m=(1-Math.cos(u))/2,M=1-Math.cos(u),A=(1-Math.cos(u))/2,y=1+c,k=-2*Math.cos(u),g=1-c,x=m/y,L=M/y,C=A/y,R=k/y,J=g/y;for(let _=0;_<n.length;_++){let W=n[_],U=x*W+L*s+C*l-R*i-J*f;l=s,s=W,f=i,i=U,n[_]=U}}else{let d=t[0];for(let u=0;u<n.length;u++){let c=t[u]??d,m=2*Math.PI*c/a,M=Math.sin(m)/2,A=(1-Math.cos(m))/2,y=1-Math.cos(m),k=(1-Math.cos(m))/2,g=1+M,x=-2*Math.cos(m),L=1-M,C=n[u],R=A/g*C+y/g*s+k/g*l-x/g*i-L/g*f;l=s,s=C,f=i,i=R,n[u]=R}}o[r]={x_1:s,x_2:l,y_1:i,y_2:f}}}function dt(e,t,a,o){for(let r=0;r<e.length;r++){let n=e[r],{x_1:s,x_2:l,y_1:i,y_2:f}=o[r]??{x_1:0,x_2:0,y_1:0,y_2:0};if(t.length===1){let d=t[0];if(d<=20)return;let u=2*Math.PI*d/a,c=Math.sin(u)/2,m=(1+Math.cos(u))/2,M=-(1+Math.cos(u)),A=(1+Math.cos(u))/2,y=1+c,k=-2*Math.cos(u),g=1-c;for(let x=0;x<n.length;x++){let L=n[x],C=m/y*L+M/y*s+A/y*l-k/y*i-g/y*f;l=s,s=L,f=i,i=C,n[x]=C}}else{let d=t[0];for(let u=0;u<n.length;u++){let c=t[u]??d,m=2*Math.PI*c/a,M=Math.sin(m)/2,A=(1+Math.cos(m))/2,y=-(1+Math.cos(m)),k=(1+Math.cos(m))/2,g=1+M,x=-2*Math.cos(m),L=1-M,C=n[u],R=A/g*C+y/g*s+k/g*l-x/g*i-L/g*f;l=s,s=C,f=i,i=R,n[u]=R}}o[r]={x_1:s,x_2:l,y_1:i,y_2:f}}}function pt(e,t,a,o){let{type:r,data:n}=t;switch(r){case"buffer":return Ze(e,n),K(e,o),[];case"bufferInit":{let s=n;return e.buffer=Se(s.channels,s.totalLength),e.streamBuffer={...G(),totalLength:s.totalLength,streamEnded:!1,streaming:s.streaming??!0},K(e,o),[]}case"bufferRange":return e.streamBuffer.pendingWrites.push(n),[];case"bufferEnd":{let s=n;return s?.totalLength!=null&&(e.streamBuffer.totalLength=s.totalLength),e.streamBuffer.streamEnded=!0,[]}case"bufferReset":return e.buffer=[],e.streamBuffer=G(),K(e,o),[];case"start":e.timesLooped=0;{let s=n;e.duration=s?.duration??-1,e.duration===-1&&(e.duration=e.loop?Number.MAX_SAFE_INTEGER:(e.buffer[0]?.length??0)/o),re(e,s?.offset,o),K(e,o),e.playhead=e.offset,e.startWhen=s?.when??a,e.stopWhen=e.startWhen+e.duration,e.playedSamples=0,e.state=b.Scheduled}return[{type:"scheduled"}];case"stop":return e.state===b.Ended||e.state===b.Initial?[]:(e.stopWhen=n??e.stopWhen,e.state=b.Stopped,[{type:"stopped"}]);case"pause":return e.state=b.Paused,e.pauseWhen=n??a,[{type:"paused"}];case"resume":return e.state=b.Started,e.startWhen=n??a,[{type:"resume"}];case"dispose":return e.state=b.Disposed,e.buffer=[],e.streamBuffer=G(),[{type:"disposed"}];case"loop":{let s=n,l=e.state;return s&&(l===b.Scheduled||l===b.Started)&&(e.stopWhen=Number.MAX_SAFE_INTEGER,e.duration=Number.MAX_SAFE_INTEGER),e.loop=s,s&&K(e,o),[]}case"loopStart":return e.loopStart=n,[];case"loopEnd":return e.loopEnd=n,[];case"loopCrossfade":return e.loopCrossfade=n,[];case"playhead":return e.playhead=Math.floor(n),[];case"fadeIn":return e.fadeInDuration=n,[];case"fadeOut":return e.fadeOutDuration=n,[];case"toggleGain":return e.enableGain=n??!e.enableGain,[];case"togglePan":return e.enablePan=n??!e.enablePan,[];case"toggleLowpass":return e.enableLowpass=n??!e.enableLowpass,[];case"toggleHighpass":return e.enableHighpass=n??!e.enableHighpass,[];case"toggleDetune":return e.enableDetune=n??!e.enableDetune,[];case"togglePlaybackRate":return e.enablePlaybackRate=n??!e.enablePlaybackRate,[];case"toggleFadeIn":return e.enableFadeIn=n??!e.enableFadeIn,[];case"toggleFadeOut":return e.enableFadeOut=n??!e.enableFadeOut,[];case"toggleLoopStart":return e.enableLoopStart=n??!e.enableLoopStart,[];case"toggleLoopEnd":return e.enableLoopEnd=n??!e.enableLoopEnd,[];case"toggleLoopCrossfade":return e.enableLoopCrossfade=n??!e.enableLoopCrossfade,[];case"logState":return[]}return[]}function ct(e,t,a,o,r){let n=[],s=e.state;if(s===b.Disposed)return{keepAlive:!1,messages:n};if(ze(e),s===b.Initial)return{keepAlive:!0,messages:n};if(s===b.Ended)return v(t[0]),{keepAlive:!0,messages:n};if(s===b.Scheduled)if(o.currentTime>=e.startWhen)s=e.state=b.Started,n.push({type:"started"});else return v(t[0]),{keepAlive:!0,messages:n};else if(s===b.Paused&&o.currentTime>e.pauseWhen)return v(t[0]),{keepAlive:!0,messages:n};if(o.currentTime>e.stopWhen)return v(t[0]),e.state=b.Ended,n.push({type:"ended"}),e.playedSamples=0,{keepAlive:!0,messages:n};let l=t[0],i=H(e);if(i===0)return v(l),{keepAlive:!0,messages:n};let{playbackRate:f,detune:d,lowpass:u,highpass:c,gain:m,pan:M}=a,{buffer:A,loopStart:y,loopEnd:k,loopCrossfade:g,stopWhen:x,playedSamples:L,enableLowpass:C,enableHighpass:R,enableGain:J,enablePan:_,enableDetune:W,enableFadeOut:U,enableFadeIn:z,enableLoopStart:Z,enableLoopEnd:ee,enableLoopCrossfade:te,playhead:F,fadeInDuration:se,fadeOutDuration:le}=e,Te=e.streamBuffer.streaming&&e.streamBuffer.committedLength<i,ie=e.loop&&!Te,N=Math.min(A.length,l.length),Ee=e.duration*o.sampleRate,_e=Math.floor(o.sampleRate*g),De=Math.max(i-T,0),D=Z?Math.min(Math.floor(y*o.sampleRate),De):0,O=ee?Math.min(Math.floor(k*o.sampleRate),i):i,Oe=O-D,ue=W&&d.length>0&&d[0]!==0,$=f;if(ue){let p=Math.max(f.length,d.length,T);$=new Float32Array(p);for(let S=0;S<p;S++){let P=f[S]??f[f.length-1],h=d[S]??d[d.length-1];$[S]=P*2**(h/1200)}}let fe=e.enablePlaybackRate||ue,we=fe&&$.length>0&&$.every(p=>p===0);if(e.streamBuffer.streaming&&!e.streamBuffer.streamEnded&&!e.streamBuffer.lowWaterNotified&&e.streamBuffer.committedLength-Math.floor(F)<e.streamBuffer.lowWaterThreshold&&(n.push({type:"bufferLowWater",data:{playhead:Math.floor(F),committedLength:e.streamBuffer.committedLength}}),e.streamBuffer.lowWaterNotified=!0),we){v(l);for(let p=1;p<t.length;p++)be(l,t[p]);return{keepAlive:!0,messages:n}}let de={bufferLength:i,loop:ie,playhead:F,loopStartSamples:D,loopEndSamples:O,durationSamples:Ee,playbackRates:$},{indexes:Y,ended:pe,looped:ce,playhead:he}=fe?ot(de):at(de),Q=Y.find(p=>p>=e.streamBuffer.committedLength&&p<i);Q!==void 0&&!e.streamBuffer.streamEnded&&e.streamBuffer.lastUnderrunSample!==Q?(n.push({type:"bufferUnderrun",data:{playhead:Math.floor(F),committedLength:e.streamBuffer.committedLength,requestedSample:Q}}),e.streamBuffer.lastUnderrunSample=Q):Q===void 0&&(e.streamBuffer.lastUnderrunSample=null),nt(l,A,Y);let w=Math.min(Math.floor(g*o.sampleRate),Oe),Ie=ie&&F>D&&F<O,We=te&&_e>0&&i>T;if(Ie&&We){{let p=D+w;if(w>0&&F>D&&F<p){let S=F-D,P=Math.min(Math.floor(p-F),T);for(let h=0;h<P;h++){let B=(S+h)/w,I=Math.cos(Math.PI*B/2),V=Math.floor(O-w+S+h);if(V>=0&&V<i)for(let E=0;E<N;E++)l[E][h]+=A[E][V]*I}}}{let p=O-w;if(w>0&&F>p&&F<O){let S=F-p,P=Math.min(Math.floor(O-F),T);for(let h=0;h<P;h++){let B=(S+h)/w,I=Math.sin(Math.PI*B/2),V=Math.floor(D+S+h);if(V>=0&&V<i)for(let E=0;E<N;E++)l[E][h]+=A[E][V]*I}}}}if(z&&se>0){let p=Math.floor(se*o.sampleRate),S=p-L;if(S>0){let P=Math.min(S,T);for(let h=0;h<P;h++){let B=(L+h)/p,I=B*B*B;for(let V=0;V<N;V++)l[V][h]*=I}}}if(U&&le>0){let p=Math.floor(le*o.sampleRate),S=Math.floor(o.sampleRate*(x-o.currentTime));if(S<p+T)for(let P=0;P<T;P++){let h=S-P;if(h>=p)continue;let B=h<=0?0:h/p,I=B*B*B;for(let V=0;V<N;V++)l[V][P]*=I}}C&&ft(l,u,o.sampleRate,r.lowpass),R&&dt(l,c,o.sampleRate,r.highpass),J&&it(l,m),N===1&&rt(l),_&&ut(l,M),ce&&(e.timesLooped++,n.push({type:"looped",data:e.timesLooped})),pe&&(e.state=b.Ended,n.push({type:"ended"})),e.playedSamples+=Y.length,e.playhead=he;let me=st(l);if(me>0)return console.log({numNans:me,indexes:Y,playhead:he,ended:pe,looped:ce,sourceLength:i}),{keepAlive:!0,messages:n};for(let p=1;p<t.length;p++)be(l,t[p]);return{keepAlive:!0,messages:n}}var Me="0.1.3";var ht="@jadujoel/web-audio-clip-node",mt=Me;function gt(){let e=new Blob([ne],{type:"text/javascript"});return URL.createObjectURL(e)}function bt(e=mt){return`https://cdn.jsdelivr.net/npm/${ht}@${e}/dist/processor.js`}function yt(e=document.baseURI){return new URL("./processor.js",e).toString()}var St=120,Mt=48e3,xe=[{key:"offset",label:"Offset",min:0,max:60,defaultValue:0,snap:"bar",hasSnap:!0,hasToggle:!0,hasMaxLock:!0,maxLockedByDefault:!0,title:"Start position in the buffer (seconds)."},{key:"duration",label:"Duration",min:-1,max:60,defaultValue:-1,hasSnap:!0,hasToggle:!0,hasMaxLock:!0,maxLockedByDefault:!0,title:"How long to play before auto-stopping (seconds). -1 for full length."},{key:"startDelay",label:"StartDelay",min:0,max:4,defaultValue:0,snap:"beat",hasSnap:!0,hasToggle:!0,title:"Delay before starting (seconds)."},{key:"stopDelay",label:"StopDelay",min:0,max:4,defaultValue:0,snap:"beat",hasSnap:!0,hasToggle:!0,title:"Delay before stopping (seconds)."},{key:"fadeIn",label:"FadeIn",min:0,max:60,defaultValue:0,snap:"beat",hasSnap:!0,hasToggle:!0,title:"Fade-in duration (seconds)."},{key:"fadeOut",label:"FadeOut",min:0,max:60,defaultValue:0,snap:"beat",hasSnap:!0,hasToggle:!0,title:"Fade-out duration (seconds)."}],Ve=[{key:"loopStart",label:"Start",min:0,max:60,defaultValue:0,snap:"bar",hasSnap:!0,hasToggle:!0,hasMaxLock:!0,maxLockedByDefault:!0},{key:"loopEnd",label:"End",min:0,max:60,defaultValue:0,snap:"bar",hasSnap:!0,hasToggle:!0,hasMaxLock:!0,maxLockedByDefault:!0},{key:"loopCrossfade",label:"Crossfade",min:0,max:1,defaultValue:0,snap:"beat",hasSnap:!0,hasToggle:!0}],Ae=[{key:"playbackRate",label:"PlaybackRate",min:-2,max:2,defaultValue:1,precision:2,preset:"playbackRate",hasToggle:!0,title:"Playback speed. Negative for reverse."},{key:"detune",label:"Detune",min:-2400,max:2400,defaultValue:0,precision:4,preset:"cents",hasToggle:!0,title:"Pitch shift in cents."},{key:"gain",label:"Gain",min:-100,max:0,defaultValue:0,precision:3,preset:"gain",hasToggle:!0,title:"Amplitude in dB."},{key:"pan",label:"Pan",min:-1,max:1,defaultValue:0,preset:"pan",hasToggle:!0,title:"-1 full left, 1 full right."},{key:"lowpass",label:"Lowpass",min:32,max:16384,defaultValue:16384,preset:"hertz",hasToggle:!0,title:"Lowpass cutoff frequency."},{key:"highpass",label:"Highpass",min:32,max:16384,defaultValue:32,preset:"hertz",hasToggle:!0,title:"Highpass cutoff frequency."}],xt={key:"playhead",label:"Playhead",min:0,max:48e4,defaultValue:0,precision:1,snap:"int",title:"Current sample position of buffer playback."},Ce=[xt,...xe,...Ve,...Ae];function Vt(){let e={},t={},a={},o={},r={},n={};for(let s of Ce)e[s.key]=s.defaultValue,t[s.key]=s.snap??"none",a[s.key]=!0,o[s.key]=s.min,r[s.key]=s.max,n[s.key]=s.maxLockedByDefault??!1;return{values:e,snaps:t,enabled:a,mins:o,maxs:r,maxLocked:n}}function At(e,t,a,o){switch(t){case"gain":return`${e.toFixed(1)} dB`;case"lowpass":case"highpass":return`${Math.round(e)} Hz`;case"detune":return`${Math.round(e)} cents`;case"pan":return e===0?"center":e<0?`${Math.abs(e).toFixed(2)} left`:`${e.toFixed(2)} right`;case"playbackRate":return`${e.toFixed(2)}x`;case"playhead":return`sample ${Math.round(e)}`;default:break}if(a==="beat"||a==="bar"||a==="8th"||a==="16th"){let r=60/o;if(a==="bar"){let s=e/(r*4);return`${Math.round(s)} bars`}if(a==="8th"){let s=e/(r/2);return`${Math.round(s)} 8ths`}if(a==="16th"){let s=e/(r/4);return`${Math.round(s)} 16ths`}let n=e/r;return`${Math.round(n)} beats`}return a==="integer"?`${Math.round(e)} s`:`${e.toPrecision(4)} s`}function Ct(e,t,a,o){switch(t){case"gain":return e.toFixed(1);case"lowpass":case"highpass":return`${Math.round(e)}`;case"detune":return`${Math.round(e)}`;case"pan":return e===0?"C":e<0?`${Math.abs(e).toFixed(2)}L`:`${e.toFixed(2)}R`;case"playbackRate":return`${e.toFixed(2)}x`;case"playhead":return`${Math.round(e)}`;default:break}if(a==="beat"||a==="bar"||a==="8th"||a==="16th"){let r=60/o;return a==="bar"?`${Math.round(e/(r*4))}`:a==="8th"?`${Math.round(e/(r/2))}`:a==="16th"?`${Math.round(e/(r/4))}`:`${Math.round(e/r)}`}return a==="integer"?`${Math.round(e)}`:e.toPrecision(4)}var Fe=[{key:"fadeOutStopDelay",label:"Link StopDelay and FadeOut",controls:["stopDelay","fadeOut"]}],Le=[{key:"loopStartEnd",label:"Link Start and End",controls:["loopStart","loopEnd"]}],Ft=[...Fe,...Le];function Lt(){return{fadeOutStopDelay:!1,loopStartEnd:!1}}function Pe(e){return Ft.find(t=>t.controls[0]===e||t.controls[1]===e)}function Pt(e,t){let a=Pe(e);return a&&t[a.key]?a.controls:[e]}function kt({pair:e,changedKey:t,nextValue:a,values:o,mins:r,maxs:n}){let[s,l]=e.controls;if(t!==s&&t!==l)return{[t]:a};let i=t===s?l:s,f=o[t],d=o[i],u=a-f,c=Math.max(r[t]-f,r[i]-d),m=Math.min(n[t]-f,n[i]-d),M=Math.min(Math.max(u,c),m);return{[t]:f+M,[i]:d+M}}var Rt=caches.open("sound-files");async function Bt(e){let t=performance.now(),a=await Rt,o=await a.match(e);if(o)return console.log(`[cache] Loaded ${e} from CacheStorage in ${(performance.now()-t).toFixed(0)}ms`),o.arrayBuffer();let r=await fetch(e);if(r.ok)return a.put(e,r.clone()).catch(()=>{}),console.log(`[cache] Loaded ${e} from network in ${(performance.now()-t).toFixed(0)}ms`),r.arrayBuffer()}var Tt="clip-audio-store";var j="files",ke="last-uploaded";function Re(){return new Promise((e,t)=>{let a=indexedDB.open(Tt,1);a.onupgradeneeded=()=>{let o=a.result;o.objectStoreNames.contains(j)||o.createObjectStore(j)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}function Be(e,t){return e.transaction(j,t).objectStore(j)}async function Et(e,t){let a=await Re(),o=Be(a,"readwrite"),r={name:e,arrayBuffer:t};await new Promise((n,s)=>{let l=o.put(r,ke);l.onsuccess=()=>n(),l.onerror=()=>s(l.error)})}async function _t(){let e=await Re(),t=Be(e,"readonly");return new Promise((a,o)=>{let r=t.get(ke);r.onsuccess=()=>a(r.result??null),r.onerror=()=>o(r.error)})}export{oe as ClipNode,St as DEFAULT_TEMPO,T as SAMPLE_BLOCK_SIZE,Mt as SAMPLE_RATE,b as State,Ce as allDefs,ae as audioBufferFromFloat32Array,Vt as buildDefaults,Lt as buildLinkedControlPairDefaults,xe as controlDefs,lt as createFilterState,Ue as dbFromLin,Xe as float32ArrayFromAudioBuffer,Ct as formatTickLabel,At as formatValueText,Ke as generateSnapPoints,Pt as getActiveLinkedControls,Pe as getLinkedControlPairForControl,kt as getLinkedControlUpdates,gt as getProcessorBlobUrl,bt as getProcessorCdnUrl,yt as getProcessorModuleUrl,et as getProperties,$e as getSnappedValue,X as getTempoSnapInterval,pt as handleProcessorMessage,ge as isTempoRelativeSnap,ve as linFromDb,Bt as loadFromCache,_t as loadUploadedFile,Ve as loopControlDefs,Le as loopLinkedControlPairs,Ae as paramDefs,Qe as presets,ct as processBlock,ne as processorCode,Ne as remapTempoRelativeValue,Et as saveUploadedFile,Fe as transportLinkedControlPairs};
|
|
6
|
+
//# sourceMappingURL=lib.bundle.js.map
|