@ilusiv/fyug-js 2026.11.8 → 2026.11.9
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 +8 -7
- package/dist/fugue-audio-worklet.js +1 -1
- package/dist/generated/embedded-assets.d.ts.map +1 -1
- package/dist/generated/embedded-assets.js +2 -2
- package/dist/generated/embedded-assets.js.map +1 -1
- package/dist/generated/fugue.d.ts +56 -6
- package/dist/generated/fugue.js +128 -10
- package/dist/generated/fugue_bg.wasm +0 -0
- package/dist/generated/fugue_bg.wasm.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @ilusiv/fyug-js
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
and its audio may drop out, especially when it runs on a
|
|
6
|
-
|
|
3
|
+
Fyug's engine for the browser, compiled to WebAssembly, for surfaces where the
|
|
4
|
+
desktop app can't run, such as the in-chat player. It builds the module types
|
|
5
|
+
its release lists, and its audio may drop out, especially when it runs on a
|
|
6
|
+
page's main thread. The desktop app is at
|
|
7
7
|
https://github.com/Ilusiv-media/fyug
|
|
8
8
|
|
|
9
9
|
The browser engine builds the module types listed in each engine release's
|
|
@@ -205,9 +205,10 @@ result | error }`) can ask it for what a meter and a playhead show with the
|
|
|
205
205
|
playhead follows, or `[]`. The answer covers everything rendered since the
|
|
206
206
|
last `views` request, which starts the next reading over:
|
|
207
207
|
|
|
208
|
-
- `levels`: the engine's `takeLevels()` JSON, with each channel's peak
|
|
209
|
-
|
|
210
|
-
of non-finite samples, and
|
|
208
|
+
- `levels`: the engine's `takeLevels()` JSON, with each channel's peak
|
|
209
|
+
(before the output clamp) and RMS (after it, of what the device plays), the
|
|
210
|
+
count of samples over full scale, the count of non-finite samples, and
|
|
211
|
+
`frames`.
|
|
211
212
|
- `squares`: `[left, right]`, the sums of squares of the samples the worklet
|
|
212
213
|
sent the device, after the clamp, over `frames` frames: the level that is
|
|
213
214
|
heard. RMS is `Math.sqrt(squares[i] / frames)`. `levels.frames` and `frames`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var D=Object.defineProperty;var L=(i,t,e)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var y=(i,t,e)=>L(i,typeof t!="symbol"?t+"":t,e);typeof globalThis.TextEncoder>"u"&&(globalThis.TextEncoder=class{encode(t=""){let e=[];for(let n=0;n<t.length;n+=1){let r=t.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<t.length){let o=t.charCodeAt(n+1);o>=56320&&o<=57343&&(r=65536+(r-55296<<10)+(o-56320),n+=1)}r<=127?e.push(r):r<=2047?e.push(192|r>>6,128|r&63):r<=65535?e.push(224|r>>12,128|r>>6&63,128|r&63):e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}return new Uint8Array(e)}encodeInto(t,e){let n=this.encode(t),r=Math.min(n.length,e.length);return e.set(n.subarray(0,r)),{read:t.length,written:r}}});typeof globalThis.TextDecoder>"u"&&(globalThis.TextDecoder=class{decode(t=new Uint8Array){let e=t instanceof Uint8Array?t:new Uint8Array(t),n="";for(let r=0;r<e.length;r+=1){let o=e[r]??0;if(o<128)n+=String.fromCharCode(o);else if((o&224)===192&&r+1<e.length){let _=(o&31)<<6|(e[++r]??0)&63;n+=String.fromCharCode(_)}else if((o&240)===224&&r+2<e.length){let _=(o&15)<<12|((e[++r]??0)&63)<<6|(e[++r]??0)&63;n+=String.fromCharCode(_)}else if((o&248)===240&&r+3<e.length){let _=(o&7)<<18|((e[++r]??0)&63)<<12|((e[++r]??0)&63)<<6|(e[++r]??0)&63;_-=65536,n+=String.fromCharCode(55296+(_>>10),56320+(_&1023))}else n+="\uFFFD"}return n}});if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function"){let i=(Date.now()&4294967295^(typeof currentTime=="number"?currentTime*4294967295:0)>>>0)>>>0,t=()=>(i^=i<<13,i^=i>>>17,i^=i<<5,i&255),e={getRandomValues(n){if(!n||!ArrayBuffer.isView(n))throw new TypeError("Expected an integer typed array");let r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);for(let o=0;o<r.length;o+=1)r[o]=t();return n}};typeof globalThis.crypto>"u"?Object.defineProperty(globalThis,"crypto",{configurable:!0,value:e}):Object.defineProperty(globalThis.crypto,"getRandomValues",{configurable:!0,value:e.getRandomValues})}var ee={},v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,F.unregister(this),t}free(){let t=this.__destroy_into_raw();s.__wbg_fugueengine_free(t,0)}addModule(t,e,n){let r=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),o=c,_=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c;var a=B(n)?0:f(n,s.__wbindgen_malloc,s.__wbindgen_realloc),d=c;let g=s.fugueengine_addModule(this.__wbg_ptr,r,o,_,l,a,d);if(g[1])throw u(g[0])}applyEdits(t){let e=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),n=c,r=s.fugueengine_applyEdits(this.__wbg_ptr,e,n);if(r[1])throw u(r[0])}connect(t,e,n,r){let o=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=c,l=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=c,d=f(n,s.__wbindgen_malloc,s.__wbindgen_realloc),g=c,b=f(r,s.__wbindgen_malloc,s.__wbindgen_realloc),p=c,h=s.fugueengine_connect(this.__wbg_ptr,o,_,l,a,d,g,b,p);if(h[1])throw u(h[0])}disconnect(t,e,n,r){let o=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),_=c,l=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),a=c,d=f(n,s.__wbindgen_malloc,s.__wbindgen_realloc),g=c,b=f(r,s.__wbindgen_malloc,s.__wbindgen_realloc),p=c,h=s.fugueengine_disconnect(this.__wbg_ptr,o,_,l,a,d,g,b,p);if(h[1])throw u(h[0])}finishAudioFileSink(t){let e,n;try{let _=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c,a=s.fugueengine_finishAudioFileSink(this.__wbg_ptr,_,l);var r=a[0],o=a[1];if(a[3])throw r=0,o=0,u(a[2]);return e=r,n=o,w(r,o)}finally{s.__wbindgen_free(e,n,1)}}getAudioFileSinkWav(t){let e=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),n=c,r=s.fugueengine_getAudioFileSinkWav(this.__wbg_ptr,e,n);if(r[3])throw u(r[2]);var o=I(r[0],r[1]).slice();return s.__wbindgen_free(r[0],r[1]*1,1),o}getCodeModuleConfig(t){let e,n;try{let _=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c,a=s.fugueengine_getCodeModuleConfig(this.__wbg_ptr,_,l);var r=a[0],o=a[1];if(a[3])throw r=0,o=0,u(a[2]);return e=r,n=o,w(r,o)}finally{s.__wbindgen_free(e,n,1)}}getControl(t,e){let n,r;try{let l=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),a=c,d=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),g=c,b=s.fugueengine_getControl(this.__wbg_ptr,l,a,d,g);var o=b[0],_=b[1];if(b[3])throw o=0,_=0,u(b[2]);return n=o,r=_,w(o,_)}finally{s.__wbindgen_free(n,r,1)}}listCodeModules(){let t,e;try{let o=s.fugueengine_listCodeModules(this.__wbg_ptr);var n=o[0],r=o[1];if(o[3])throw n=0,r=0,u(o[2]);return t=n,e=r,w(n,r)}finally{s.__wbindgen_free(t,e,1)}}listConnections(){let t,e;try{let o=s.fugueengine_listConnections(this.__wbg_ptr);var n=o[0],r=o[1];if(o[3])throw n=0,r=0,u(o[2]);return t=n,e=r,w(n,r)}finally{s.__wbindgen_free(t,e,1)}}listControls(t){let e,n;try{var r=B(t)?0:f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),o=c;let a=s.fugueengine_listControls(this.__wbg_ptr,r,o);var _=a[0],l=a[1];if(a[3])throw _=0,l=0,u(a[2]);return e=_,n=l,w(_,l)}finally{s.__wbindgen_free(e,n,1)}}listModules(){let t,e;try{let o=s.fugueengine_listModules(this.__wbg_ptr);var n=o[0],r=o[1];if(o[3])throw n=0,r=0,u(o[2]);return t=n,e=r,w(n,r)}finally{s.__wbindgen_free(t,e,1)}}loadInvention(t){let e=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),n=c,r=s.fugueengine_loadInvention(this.__wbg_ptr,e,n);if(r[1])throw u(r[0])}constructor(t){let e=s.fugueengine_new(t);return this.__wbg_ptr=e,F.register(this,this.__wbg_ptr,this),this}previewNotes(t,e){let n=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),r=c,o=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),_=c;return s.fugueengine_previewNotes(this.__wbg_ptr,n,r,o,_)}provideSample(t,e,n,r){let o,_;try{let d=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),g=c,b=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),p=c,h=f(n,s.__wbindgen_malloc,s.__wbindgen_realloc),x=c,U=Y(r,s.__wbindgen_malloc),V=c,M=s.fugueengine_provideSample(this.__wbg_ptr,d,g,b,p,h,x,U,V);var l=M[0],a=M[1];if(M[3])throw l=0,a=0,u(M[2]);return o=l,_=a,w(l,a)}finally{s.__wbindgen_free(o,_,1)}}removeModule(t){let e=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),n=c,r=s.fugueengine_removeModule(this.__wbg_ptr,e,n);if(r[1])throw u(r[0])}renderInterleavedInto(t){let e=s.fugueengine_renderInterleavedInto(this.__wbg_ptr,t);if(e[2])throw u(e[1]);return e[0]>>>0}renderInterleaved(t){let e=s.fugueengine_renderInterleaved(this.__wbg_ptr,t);if(e[3])throw u(e[2]);var n=W(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*4,4),n}reset(){let t=s.fugueengine_reset(this.__wbg_ptr);if(t[1])throw u(t[0])}sampleRate(){return s.fugueengine_sampleRate(this.__wbg_ptr)>>>0}setCodeModuleError(t,e){let n=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),r=c,o=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),_=c,l=s.fugueengine_setCodeModuleError(this.__wbg_ptr,n,r,o,_);if(l[1])throw u(l[0])}setCodeModuleStatus(t,e){let n=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),r=c,o=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),_=c,l=s.fugueengine_setCodeModuleStatus(this.__wbg_ptr,n,r,o,_);if(l[1])throw u(l[0])}setControlBool(t,e,n){let r=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),o=c,_=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c,a=s.fugueengine_setControlBool(this.__wbg_ptr,r,o,_,l,n);if(a[1])throw u(a[0])}setControlNumber(t,e,n){let r=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),o=c,_=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c,a=s.fugueengine_setControlNumber(this.__wbg_ptr,r,o,_,l,n);if(a[1])throw u(a[0])}setControlString(t,e,n){let r=f(t,s.__wbindgen_malloc,s.__wbindgen_realloc),o=c,_=f(e,s.__wbindgen_malloc,s.__wbindgen_realloc),l=c,a=f(n,s.__wbindgen_malloc,s.__wbindgen_realloc),d=c,g=s.fugueengine_setControlString(this.__wbg_ptr,r,o,_,l,a,d);if(g[1])throw u(g[0])}status(){let t,e;try{let o=s.fugueengine_status(this.__wbg_ptr);var n=o[0],r=o[1];if(o[3])throw n=0,r=0,u(o[2]);return t=n,e=r,w(n,r)}finally{s.__wbindgen_free(t,e,1)}}takeLevels(){let t,e;try{let o=s.fugueengine_takeLevels(this.__wbg_ptr);var n=o[0],r=o[1];if(o[3])throw n=0,r=0,u(o[2]);return t=n,e=r,w(n,r)}finally{s.__wbindgen_free(t,e,1)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function P(){return{__proto__:null,"./fugue_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,e){throw new Error(w(t,e))},__wbg__wbg_cb_unref_dcc1a90847f04c41:function(t){t._wbg_cb_unref()},__wbg_call_187d372bd5fdd4aa:function(){return q(function(t,e,n){return t.call(e,n)},arguments)},__wbg_getRandomValues_436a51d0629d84e1:function(){return q(function(t,e){globalThis.crypto.getRandomValues(I(t,e))},arguments)},__wbg_length_58572db4c38f3c3e:function(t){return t.length},__wbg_new_5502aad30c185fc8:function(t,e){try{var n={a:t,b:e},r=(_,l)=>{let a=n.a;n.a=0;try{return z(a,n.b,_,l)}finally{n.a=a}};return new Promise(r)}finally{n.a=0}},__wbg_now_aa4ccb83129e9e55:function(){return Date.now()},__wbg_setTimeout_4bf75e1eaccfc9e2:function(t,e){return setTimeout(t,e)},__wbg_set_070bd465f1c195a4:function(t,e,n){t.set(W(e,n))},__wbindgen_generic_0000000000000001:function(t,e){return X(t,e,j)},__wbindgen_generic_0000000000000002:function(t,e){return w(t,e)},__wbindgen_init_externref_table:function(){let t=s.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}}}}function j(i,t){s.wasm_bindgen__convert__closures_____invoke__hd2d6d321acd2ef74(i,t)}function z(i,t,e,n){s.wasm_bindgen__convert__closures_____invoke__h1b9b7a832ddda534(i,t,e,n)}var F=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>s.__wbg_fugueengine_free(i,1));function N(i){let t=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(t,i),t}var k=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>s.__wbindgen_destroy_closure(i.a,i.b));function W(i,t){return i=i>>>0,$().subarray(i/4,i/4+t)}function I(i,t){return i=i>>>0,m().subarray(i/1,i/1+t)}var C=null;function $(){return(C===null||C.byteLength===0)&&(C=new Float32Array(s.memory.buffer)),C}function w(i,t){return H(i>>>0,t)}var A=null;function m(){return(A===null||A.byteLength===0)&&(A=new Uint8Array(s.memory.buffer)),A}function q(i,t){try{return i.apply(this,t)}catch(e){let n=N(e);s.__wbindgen_exn_store(n)}}function B(i){return i==null}function X(i,t,e){let n={a:i,b:t,cnt:1},r=(...o)=>{n.cnt++;let _=n.a;n.a=0;try{return e(_,n.b,...o)}finally{n.a=_,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{--n.cnt===0&&(s.__wbindgen_destroy_closure(n.a,n.b),n.a=0,k.unregister(n))},k.register(r,n,n),r}function Y(i,t){let e=t(i.length*1,1)>>>0;return m().set(i,e/1),c=i.length,e}function f(i,t,e){if(e===void 0){let l=T.encode(i),a=t(l.length,1)>>>0;return m().subarray(a,a+l.length).set(l),c=l.length,a}let n=i.length,r=t(n,1)>>>0,o=m(),_=0;for(;_<n;_++){let l=i.charCodeAt(_);if(l>127)break;o[r+_]=l}if(_!==n){_!==0&&(i=i.slice(_)),r=e(r,n,n=_+i.length*3,1)>>>0;let l=m().subarray(r+_,r+n),a=T.encodeInto(i,l);_+=a.written,r=e(r,n,_,1)>>>0}return c=_,r}function u(i){let t=s.__wbindgen_externrefs.get(i);return s.__externref_table_dealloc(i),t}var R=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});R.decode();var G=2146435072,E=0;function H(i,t){return E+=t,E>=G&&(R=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),R.decode(),E=t),R.decode(m().subarray(i,i+t))}var T=new TextEncoder;"encodeInto"in T||(T.encodeInto=function(i,t){let e=T.encode(i);return t.set(e),{read:i.length,written:e.length}});var c=0,J,K,s;function Q(i,t){return K=i,s=i.exports,J=t,C=null,A=null,s.__wbindgen_start(),s}async function Z(i,t){if(typeof Response=="function"&&i instanceof Response){if(!i.ok)throw new Error(`failed to fetch Wasm: ${i.status} ${i.statusText} fetching '${i.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,t)}catch(r){if(e(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let n=await i.arrayBuffer();return await WebAssembly.instantiate(n,t)}else{let n=await WebAssembly.instantiate(i,t);return n instanceof WebAssembly.Instance?{instance:n,module:i}:n}function e(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}async function O(i){if(s!==void 0)return s;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("fugue_bg.wasm",ee.url));let t=P();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));let{instance:e,module:n}=await Z(await i,t);return Q(e,n)}var S=class extends AudioWorkletProcessor{constructor(e){super();y(this,"engine",null);y(this,"ready",!1);y(this,"playing",!1);y(this,"renderBuffer",new Float32Array(0));y(this,"squares",new Float64Array(2));y(this,"squaredFrames",0);y(this,"missingClock",null);this.port.onmessage=n=>{this.handleMessage(n.data)},this.initialize(e?.processorOptions??{})}async initialize(e){try{await O({module_or_path:e.wasmBytes}),this.engine=new v(e.sampleRate??sampleRate),this.ready=!0,this.port.postMessage({type:"ready"})}catch(n){this.postError(n)}}handleMessage(e){if(!(!e||typeof e!="object")){if(e.type==="play"){this.playing=!0,this.port.postMessage({type:"state",state:"playing"});return}if(e.type==="stop"){this.playing=!1,this.port.postMessage({type:"state",state:"stopped"});return}if(e.type==="request")try{let n=this.handleRequest(e.method,e.args??[]);this.port.postMessage({type:"response",id:e.id,result:n})}catch(n){this.port.postMessage({type:"response",id:e.id,error:n instanceof Error?n.message:String(n)})}}}handleRequest(e,n){if(!this.ready||!this.engine)throw new Error("Fugue engine is not ready");switch(e){case"loadInvention":return this.engine.loadInvention(n[0]),this.restartReading(),null;case"reset":return this.engine.reset(),this.restartReading(),null;case"provideSample":return this.engine.provideSample(n[0],n[1],n[2],n[3]),null;case"status":return this.engine.status();case"listModules":return this.engine.listModules();case"listConnections":return this.engine.listConnections();case"applyEdits":return this.missingClock=null,this.engine.applyEdits(n[0]);case"listControls":return this.engine.listControls(n[0]);case"getControl":return this.engine.getControl(n[0],n[1]);case"views":return this.views(n[0]);case"setControl":return this.setControl(n[0],n[1],n[2]),null;default:throw new Error(`Unknown Fugue player method: ${e}`)}}views(e){let n=this.engine,r=n.takeLevels(),o=null;if(typeof e=="string"&&e!==this.missingClock)try{o=n.getControl(e,"elapsed")}catch{this.missingClock=e}let _={levels:r,beats:o,squares:[this.squares[0],this.squares[1]],frames:this.squaredFrames,time:currentTime};return this.squares[0]=0,this.squares[1]=0,this.squaredFrames=0,_}restartReading(){this.squares[0]=0,this.squares[1]=0,this.squaredFrames=0,this.missingClock=null}setControl(e,n,r){switch(typeof r){case"number":this.engine?.setControlNumber(e,n,r);return;case"boolean":this.engine?.setControlBool(e,n,r);return;case"string":this.engine?.setControlString(e,n,r);return}}process(e,n){let r=n[0],o=r?.[0],_=r?.[1];if(!o||!_)return!0;if(!this.playing||!this.ready||!this.engine)return o.fill(0),_.fill(0),!0;let l=o.length,a=l*2;this.renderBuffer.length!==a&&(this.renderBuffer=new Float32Array(a));try{this.engine.renderInterleavedInto(this.renderBuffer);let d=0,g=0;for(let b=0,p=0;b<l;b+=1,p+=2){let h=this.renderBuffer[p]??0,x=this.renderBuffer[p+1]??0;o[b]=h,_[b]=x,d+=h*h,g+=x*x}this.squares[0]+=d,this.squares[1]+=g,this.squaredFrames+=l}catch(d){this.playing=!1,o.fill(0),_.fill(0);try{this.engine.takeLevels()}catch{}this.restartReading(),this.postError(d)}return!0}postError(e){this.port.postMessage({type:"error",error:e instanceof Error?e.message:String(e)})}};registerProcessor("fugue-audio-worklet",S);})();
|
|
1
|
+
"use strict";(()=>{var D=Object.defineProperty;var P=(i,t,e)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>P(i,typeof t!="symbol"?t+"":t,e);typeof globalThis.TextEncoder>"u"&&(globalThis.TextEncoder=class{encode(t=""){let e=[];for(let n=0;n<t.length;n+=1){let s=t.charCodeAt(n);if(s>=55296&&s<=56319&&n+1<t.length){let o=t.charCodeAt(n+1);o>=56320&&o<=57343&&(s=65536+(s-55296<<10)+(o-56320),n+=1)}s<=127?e.push(s):s<=2047?e.push(192|s>>6,128|s&63):s<=65535?e.push(224|s>>12,128|s>>6&63,128|s&63):e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}return new Uint8Array(e)}encodeInto(t,e){let n=this.encode(t),s=Math.min(n.length,e.length);return e.set(n.subarray(0,s)),{read:t.length,written:s}}});typeof globalThis.TextDecoder>"u"&&(globalThis.TextDecoder=class{decode(t=new Uint8Array){let e=t instanceof Uint8Array?t:new Uint8Array(t),n="";for(let s=0;s<e.length;s+=1){let o=e[s]??0;if(o<128)n+=String.fromCharCode(o);else if((o&224)===192&&s+1<e.length){let _=(o&31)<<6|(e[++s]??0)&63;n+=String.fromCharCode(_)}else if((o&240)===224&&s+2<e.length){let _=(o&15)<<12|((e[++s]??0)&63)<<6|(e[++s]??0)&63;n+=String.fromCharCode(_)}else if((o&248)===240&&s+3<e.length){let _=(o&7)<<18|((e[++s]??0)&63)<<12|((e[++s]??0)&63)<<6|(e[++s]??0)&63;_-=65536,n+=String.fromCharCode(55296+(_>>10),56320+(_&1023))}else n+="\uFFFD"}return n}});if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.getRandomValues!="function"){let i=(Date.now()&4294967295^(typeof currentTime=="number"?currentTime*4294967295:0)>>>0)>>>0,t=()=>(i^=i<<13,i^=i>>>17,i^=i<<5,i&255),e={getRandomValues(n){if(!n||!ArrayBuffer.isView(n))throw new TypeError("Expected an integer typed array");let s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);for(let o=0;o<s.length;o+=1)s[o]=t();return n}};typeof globalThis.crypto>"u"?Object.defineProperty(globalThis,"crypto",{configurable:!0,value:e}):Object.defineProperty(globalThis.crypto,"getRandomValues",{configurable:!0,value:e.getRandomValues})}var re={},v=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,q.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_fugueengine_free(t,0)}addModule(t,e,n){let s=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=c,_=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c;var l=F(n)?0:f(n,r.__wbindgen_malloc,r.__wbindgen_realloc),g=c;let d=r.fugueengine_addModule(this.__wbg_ptr,s,o,_,a,l,g);if(d[1])throw u(d[0])}applyEdits(t){let e,n;try{let _=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_applyEdits(this.__wbg_ptr,_,a);var s=l[0],o=l[1];if(l[3])throw s=0,o=0,u(l[2]);return e=s,n=o,w(s,o)}finally{r.__wbindgen_free(e,n,1)}}connect(t,e,n,s){let o=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),_=c,a=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),l=c,g=f(n,r.__wbindgen_malloc,r.__wbindgen_realloc),d=c,b=f(s,r.__wbindgen_malloc,r.__wbindgen_realloc),y=c,h=r.fugueengine_connect(this.__wbg_ptr,o,_,a,l,g,d,b,y);if(h[1])throw u(h[0])}disconnect(t,e,n,s){let o=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),_=c,a=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),l=c,g=f(n,r.__wbindgen_malloc,r.__wbindgen_realloc),d=c,b=f(s,r.__wbindgen_malloc,r.__wbindgen_realloc),y=c,h=r.fugueengine_disconnect(this.__wbg_ptr,o,_,a,l,g,d,b,y);if(h[1])throw u(h[0])}finishAudioFileSink(t){let e,n;try{let _=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_finishAudioFileSink(this.__wbg_ptr,_,a);var s=l[0],o=l[1];if(l[3])throw s=0,o=0,u(l[2]);return e=s,n=o,w(s,o)}finally{r.__wbindgen_free(e,n,1)}}getAudioFileSinkWav(t){let e=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=c,s=r.fugueengine_getAudioFileSinkWav(this.__wbg_ptr,e,n);if(s[3])throw u(s[2]);var o=V(s[0],s[1]).slice();return r.__wbindgen_free(s[0],s[1]*1,1),o}getCodeModuleConfig(t){let e,n;try{let _=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_getCodeModuleConfig(this.__wbg_ptr,_,a);var s=l[0],o=l[1];if(l[3])throw s=0,o=0,u(l[2]);return e=s,n=o,w(s,o)}finally{r.__wbindgen_free(e,n,1)}}getControl(t,e){let n,s;try{let a=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),l=c,g=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),d=c,b=r.fugueengine_getControl(this.__wbg_ptr,a,l,g,d);var o=b[0],_=b[1];if(b[3])throw o=0,_=0,u(b[2]);return n=o,s=_,w(o,_)}finally{r.__wbindgen_free(n,s,1)}}listCodeModules(){let t,e;try{let o=r.fugueengine_listCodeModules(this.__wbg_ptr);var n=o[0],s=o[1];if(o[3])throw n=0,s=0,u(o[2]);return t=n,e=s,w(n,s)}finally{r.__wbindgen_free(t,e,1)}}listConnections(){let t,e;try{let o=r.fugueengine_listConnections(this.__wbg_ptr);var n=o[0],s=o[1];if(o[3])throw n=0,s=0,u(o[2]);return t=n,e=s,w(n,s)}finally{r.__wbindgen_free(t,e,1)}}listControls(t){let e,n;try{var s=F(t)?0:f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=c;let l=r.fugueengine_listControls(this.__wbg_ptr,s,o);var _=l[0],a=l[1];if(l[3])throw _=0,a=0,u(l[2]);return e=_,n=a,w(_,a)}finally{r.__wbindgen_free(e,n,1)}}listModules(){let t,e;try{let o=r.fugueengine_listModules(this.__wbg_ptr);var n=o[0],s=o[1];if(o[3])throw n=0,s=0,u(o[2]);return t=n,e=s,w(n,s)}finally{r.__wbindgen_free(t,e,1)}}loadInvention(t){let e=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=c,s=r.fugueengine_loadInvention(this.__wbg_ptr,e,n);if(s[1])throw u(s[0])}constructor(t){let e=r.fugueengine_new(t);return this.__wbg_ptr=e,q.register(this,this.__wbg_ptr,this),this}previewNotes(t,e){let n=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),s=c,o=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),_=c;return r.fugueengine_previewNotes(this.__wbg_ptr,n,s,o,_)}provideSample(t,e,n,s){let o,_;try{let g=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),d=c,b=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),y=c,h=f(n,r.__wbindgen_malloc,r.__wbindgen_realloc),x=c,U=J(s,r.__wbindgen_malloc),L=c,R=r.fugueengine_provideSample(this.__wbg_ptr,g,d,b,y,h,x,U,L);var a=R[0],l=R[1];if(R[3])throw a=0,l=0,u(R[2]);return o=a,_=l,w(a,l)}finally{r.__wbindgen_free(o,_,1)}}removeModule(t){let e=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=c,s=r.fugueengine_removeModule(this.__wbg_ptr,e,n);if(s[1])throw u(s[0])}renderInterleavedInto(t){let e=r.fugueengine_renderInterleavedInto(this.__wbg_ptr,t);if(e[2])throw u(e[1]);return e[0]>>>0}renderInterleaved(t){let e=r.fugueengine_renderInterleaved(this.__wbg_ptr,t);if(e[3])throw u(e[2]);var n=B(e[0],e[1]).slice();return r.__wbindgen_free(e[0],e[1]*4,4),n}reset(){let t=r.fugueengine_reset(this.__wbg_ptr);if(t[1])throw u(t[0])}sampleRate(){return r.fugueengine_sampleRate(this.__wbg_ptr)>>>0}setCodeModuleError(t,e){let n=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),s=c,o=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),_=c,a=r.fugueengine_setCodeModuleError(this.__wbg_ptr,n,s,o,_);if(a[1])throw u(a[0])}setCodeModuleStatus(t,e){let n=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),s=c,o=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),_=c,a=r.fugueengine_setCodeModuleStatus(this.__wbg_ptr,n,s,o,_);if(a[1])throw u(a[0])}setControlBool(t,e,n){let s=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=c,_=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_setControlBool(this.__wbg_ptr,s,o,_,a,n);if(l[1])throw u(l[0])}setControlNumber(t,e,n){let s=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=c,_=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_setControlNumber(this.__wbg_ptr,s,o,_,a,n);if(l[1])throw u(l[0])}setControlString(t,e,n){let s=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=c,_=f(e,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=f(n,r.__wbindgen_malloc,r.__wbindgen_realloc),g=c,d=r.fugueengine_setControlString(this.__wbg_ptr,s,o,_,a,l,g);if(d[1])throw u(d[0])}setControls(t){let e,n;try{let _=f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),a=c,l=r.fugueengine_setControls(this.__wbg_ptr,_,a);var s=l[0],o=l[1];if(l[3])throw s=0,o=0,u(l[2]);return e=s,n=o,w(s,o)}finally{r.__wbindgen_free(e,n,1)}}setViewsClock(t){var e=F(t)?0:f(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=c;r.fugueengine_setViewsClock(this.__wbg_ptr,e,n)}status(){let t,e;try{let o=r.fugueengine_status(this.__wbg_ptr);var n=o[0],s=o[1];if(o[3])throw n=0,s=0,u(o[2]);return t=n,e=s,w(n,s)}finally{r.__wbindgen_free(t,e,1)}}takeLevels(){let t,e;try{let o=r.fugueengine_takeLevels(this.__wbg_ptr);var n=o[0],s=o[1];if(o[3])throw n=0,s=0,u(o[2]);return t=n,e=s,w(n,s)}finally{r.__wbindgen_free(t,e,1)}}takeViewsInto(t){let e=r.fugueengine_takeViewsInto(this.__wbg_ptr,t);if(e[2])throw u(e[1]);return e[0]!==0}static viewsLength(){return r.fugueengine_viewsLength()>>>0}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function j(){return{__proto__:null,"./fugue_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,e){throw new Error(w(t,e))},__wbg__wbg_cb_unref_dcc1a90847f04c41:function(t){t._wbg_cb_unref()},__wbg_call_187d372bd5fdd4aa:function(){return W(function(t,e,n){return t.call(e,n)},arguments)},__wbg_getRandomValues_436a51d0629d84e1:function(){return W(function(t,e){globalThis.crypto.getRandomValues(V(t,e))},arguments)},__wbg_length_58572db4c38f3c3e:function(t){return t.length},__wbg_length_b5f0008bbf60cf59:function(t){return t.length},__wbg_new_5502aad30c185fc8:function(t,e){try{var n={a:t,b:e},s=(_,a)=>{let l=n.a;n.a=0;try{return N(l,n.b,_,a)}finally{n.a=l}};return new Promise(s)}finally{n.a=0}},__wbg_now_aa4ccb83129e9e55:function(){return Date.now()},__wbg_setTimeout_4bf75e1eaccfc9e2:function(t,e){return setTimeout(t,e)},__wbg_set_070bd465f1c195a4:function(t,e,n){t.set(B(e,n))},__wbg_set_8b5ae6cfd49dec9f:function(t,e,n){t.set(X(e,n))},__wbindgen_generic_0000000000000001:function(t,e){return H(t,e,z)},__wbindgen_generic_0000000000000002:function(t,e){return w(t,e)},__wbindgen_init_externref_table:function(){let t=r.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}}}}function z(i,t){r.wasm_bindgen__convert__closures_____invoke__hd2d6d321acd2ef74(i,t)}function N(i,t,e,n){r.wasm_bindgen__convert__closures_____invoke__h1b9b7a832ddda534(i,t,e,n)}var q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>r.__wbg_fugueengine_free(i,1));function $(i){let t=r.__externref_table_alloc();return r.__wbindgen_externrefs.set(t,i),t}var I=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(i=>r.__wbindgen_destroy_closure(i.a,i.b));function B(i,t){return i=i>>>0,Y().subarray(i/4,i/4+t)}function X(i,t){return i=i>>>0,G().subarray(i/8,i/8+t)}function V(i,t){return i=i>>>0,m().subarray(i/1,i/1+t)}var C=null;function Y(){return(C===null||C.byteLength===0)&&(C=new Float32Array(r.memory.buffer)),C}var A=null;function G(){return(A===null||A.byteLength===0)&&(A=new Float64Array(r.memory.buffer)),A}function w(i,t){return Q(i>>>0,t)}var M=null;function m(){return(M===null||M.byteLength===0)&&(M=new Uint8Array(r.memory.buffer)),M}function W(i,t){try{return i.apply(this,t)}catch(e){let n=$(e);r.__wbindgen_exn_store(n)}}function F(i){return i==null}function H(i,t,e){let n={a:i,b:t,cnt:1},s=(...o)=>{n.cnt++;let _=n.a;n.a=0;try{return e(_,n.b,...o)}finally{n.a=_,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--n.cnt===0&&(r.__wbindgen_destroy_closure(n.a,n.b),n.a=0,I.unregister(n))},I.register(s,n,n),s}function J(i,t){let e=t(i.length*1,1)>>>0;return m().set(i,e/1),c=i.length,e}function f(i,t,e){if(e===void 0){let a=T.encode(i),l=t(a.length,1)>>>0;return m().subarray(l,l+a.length).set(a),c=a.length,l}let n=i.length,s=t(n,1)>>>0,o=m(),_=0;for(;_<n;_++){let a=i.charCodeAt(_);if(a>127)break;o[s+_]=a}if(_!==n){_!==0&&(i=i.slice(_)),s=e(s,n,n=_+i.length*3,1)>>>0;let a=m().subarray(s+_,s+n),l=T.encodeInto(i,a);_+=l.written,s=e(s,n,_,1)>>>0}return c=_,s}function u(i){let t=r.__wbindgen_externrefs.get(i);return r.__externref_table_dealloc(i),t}var E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});E.decode();var K=2146435072,S=0;function Q(i,t){return S+=t,S>=K&&(E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),E.decode(),S=t),E.decode(m().subarray(i,i+t))}var T=new TextEncoder;"encodeInto"in T||(T.encodeInto=function(i,t){let e=T.encode(i);return t.set(e),{read:i.length,written:e.length}});var c=0,Z,ee,r;function ne(i,t){return ee=i,r=i.exports,Z=t,C=null,A=null,M=null,r.__wbindgen_start(),r}async function te(i,t){if(typeof Response=="function"&&i instanceof Response){if(!i.ok)throw new Error(`failed to fetch Wasm: ${i.status} ${i.statusText} fetching '${i.url}'`);if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(i,t)}catch(s){if(e(i.type)&&i.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}let n=await i.arrayBuffer();return await WebAssembly.instantiate(n,t)}else{let n=await WebAssembly.instantiate(i,t);return n instanceof WebAssembly.Instance?{instance:n,module:i}:n}function e(n){switch(n){case"basic":case"cors":case"default":return!0}return!1}}async function O(i){if(r!==void 0)return r;i!==void 0&&(Object.getPrototypeOf(i)===Object.prototype?{module_or_path:i}=i:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),i===void 0&&(i=new URL("fugue_bg.wasm",re.url));let t=j();(typeof i=="string"||typeof Request=="function"&&i instanceof Request||typeof URL=="function"&&i instanceof URL)&&(i=fetch(i));let{instance:e,module:n}=await te(await i,t);return ne(e,n)}var k=class extends AudioWorkletProcessor{constructor(e){super();p(this,"engine",null);p(this,"ready",!1);p(this,"playing",!1);p(this,"renderBuffer",new Float32Array(0));p(this,"squares",new Float64Array(2));p(this,"squaredFrames",0);p(this,"missingClock",null);this.port.onmessage=n=>{this.handleMessage(n.data)},this.initialize(e?.processorOptions??{})}async initialize(e){try{await O({module_or_path:e.wasmBytes}),this.engine=new v(e.sampleRate??sampleRate),this.ready=!0,this.port.postMessage({type:"ready"})}catch(n){this.postError(n)}}handleMessage(e){if(!(!e||typeof e!="object")){if(e.type==="play"){this.playing=!0,this.port.postMessage({type:"state",state:"playing"});return}if(e.type==="stop"){this.playing=!1,this.port.postMessage({type:"state",state:"stopped"});return}if(e.type==="request")try{let n=this.handleRequest(e.method,e.args??[]);this.port.postMessage({type:"response",id:e.id,result:n})}catch(n){this.port.postMessage({type:"response",id:e.id,error:n instanceof Error?n.message:String(n)})}}}handleRequest(e,n){if(!this.ready||!this.engine)throw new Error("Fugue engine is not ready");switch(e){case"loadInvention":return this.engine.loadInvention(n[0]),this.restartReading(),null;case"reset":return this.engine.reset(),this.restartReading(),null;case"provideSample":return this.engine.provideSample(n[0],n[1],n[2],n[3]),null;case"status":return this.engine.status();case"listModules":return this.engine.listModules();case"listConnections":return this.engine.listConnections();case"applyEdits":return this.missingClock=null,this.engine.applyEdits(n[0]);case"listControls":return this.engine.listControls(n[0]);case"getControl":return this.engine.getControl(n[0],n[1]);case"views":return this.views(n[0]);case"setControl":return this.setControl(n[0],n[1],n[2]),null;default:throw new Error(`Unknown Fugue player method: ${e}`)}}views(e){let n=this.engine,s=n.takeLevels(),o=null;if(typeof e=="string"&&e!==this.missingClock)try{o=n.getControl(e,"elapsed")}catch{this.missingClock=e}let _={levels:s,beats:o,squares:[this.squares[0],this.squares[1]],frames:this.squaredFrames,time:currentTime};return this.squares[0]=0,this.squares[1]=0,this.squaredFrames=0,_}restartReading(){this.squares[0]=0,this.squares[1]=0,this.squaredFrames=0,this.missingClock=null}setControl(e,n,s){switch(typeof s){case"number":this.engine?.setControlNumber(e,n,s);return;case"boolean":this.engine?.setControlBool(e,n,s);return;case"string":this.engine?.setControlString(e,n,s);return}}process(e,n){let s=n[0],o=s?.[0],_=s?.[1];if(!o||!_)return!0;if(!this.playing||!this.ready||!this.engine)return o.fill(0),_.fill(0),!0;let a=o.length,l=a*2;this.renderBuffer.length!==l&&(this.renderBuffer=new Float32Array(l));try{this.engine.renderInterleavedInto(this.renderBuffer);let g=0,d=0;for(let b=0,y=0;b<a;b+=1,y+=2){let h=this.renderBuffer[y]??0,x=this.renderBuffer[y+1]??0;o[b]=h,_[b]=x,g+=h*h,d+=x*x}this.squares[0]+=g,this.squares[1]+=d,this.squaredFrames+=a}catch(g){this.playing=!1,o.fill(0),_.fill(0);try{this.engine.takeLevels()}catch{}this.restartReading(),this.postError(g)}return!0}postError(e){this.port.postMessage({type:"error",error:e instanceof Error?e.message:String(e)})}};registerProcessor("fugue-audio-worklet",k);})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-assets.d.ts","sourceRoot":"","sources":["../../src/generated/embedded-assets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"embedded-assets.d.ts","sourceRoot":"","sources":["../../src/generated/embedded-assets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,EAAE,MAAykhB,CAAC;AAE9mhB,eAAO,MAAM,kBAAkB,EAAE,MAAum/1I,CAAC"}
|