From a7a1088e7478e52c50cc320b3e01a90a03b3859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Letz?= Date: Sat, 5 Oct 2024 20:04:49 +0200 Subject: [PATCH] Make build has to be used. --- docs/gamelan/atomicro/dsp-meta.json | 6 +- docs/gamelan/atomicro/dsp-module.wasm | Bin 5516 -> 5517 bytes docs/gamelan/atomicro/faustwasm/index.d.ts | 10 +- docs/gamelan/atomicro/faustwasm/index.js | 99 +- docs/gamelan/atomicro/faustwasm/index.js.map | 4 +- docs/gamelan/atomicro/index.js | 72 +- docs/gamelan/attackey/dsp-meta.json | 5 +- docs/gamelan/attackey/dsp-module.wasm | Bin 20142 -> 20166 bytes docs/gamelan/attackey/faustwasm/index.d.ts | 10 +- docs/gamelan/attackey/faustwasm/index.js | 99 +- docs/gamelan/attackey/faustwasm/index.js.map | 4 +- docs/gamelan/attackey/index.js | 72 +- docs/gamelan/baliphone/dsp-meta.json | 6 +- docs/gamelan/baliphone/dsp-module.wasm | Bin 22809 -> 22810 bytes docs/gamelan/baliphone/faustwasm/index.d.ts | 10 +- docs/gamelan/baliphone/faustwasm/index.js | 99 +- docs/gamelan/baliphone/faustwasm/index.js.map | 4 +- docs/gamelan/baliphone/index.js | 72 +- docs/gamelan/drone/dsp-meta.json | 5 +- docs/gamelan/drone/dsp-module.wasm | Bin 10352 -> 10338 bytes docs/gamelan/drone/faustwasm/index.d.ts | 10 +- docs/gamelan/drone/faustwasm/index.js | 99 +- docs/gamelan/drone/faustwasm/index.js.map | 4 +- docs/gamelan/drone/index.js | 72 +- docs/gamelan/index.html | 10 +- docs/gamelan/sequenceur/dsp-meta.json | 6 +- docs/gamelan/sequenceur/dsp-module.wasm | Bin 10932 -> 10933 bytes docs/gamelan/sequenceur/faustwasm/index.d.ts | 10 +- docs/gamelan/sequenceur/faustwasm/index.js | 99 +- .../gamelan/sequenceur/faustwasm/index.js.map | 4 +- docs/gamelan/sequenceur/index.js | 72 +- docs/gamelan/shakerxy/dsp-meta.json | 6 +- docs/gamelan/shakerxy/dsp-module.wasm | Bin 6100 -> 6101 bytes docs/gamelan/shakerxy/faustwasm/index.d.ts | 10 +- docs/gamelan/shakerxy/faustwasm/index.js | 99 +- docs/gamelan/shakerxy/faustwasm/index.js.map | 4 +- docs/gamelan/shakerxy/index.js | 72 +- docs/gamelan/sinusoide/dsp-meta.json | 6 +- docs/gamelan/sinusoide/dsp-module.wasm | Bin 17927 -> 17928 bytes docs/gamelan/sinusoide/faustwasm/index.d.ts | 10 +- docs/gamelan/sinusoide/faustwasm/index.js | 99 +- docs/gamelan/sinusoide/faustwasm/index.js.map | 4 +- docs/gamelan/sinusoide/index.js | 72 +- docs/gamelan/sinusoide2.png | Bin 0 -> 616 bytes docs/gamelan/sinusoide2/create-node.js | 138 + docs/gamelan/sinusoide2/dsp-meta.json | 597 +++ docs/gamelan/sinusoide2/dsp-module.wasm | Bin 0 -> 68937 bytes docs/gamelan/sinusoide2/faust-ui/index.css | 442 ++ .../gamelan/sinusoide2/faust-ui/index.css.map | 1 + docs/gamelan/sinusoide2/faust-ui/index.d.ts | 1 + docs/gamelan/sinusoide2/faust-ui/index.js | 3844 ++++++++++++++ docs/gamelan/sinusoide2/faust-ui/index.js.map | 1 + docs/gamelan/sinusoide2/faustwasm/index.d.ts | 1585 ++++++ docs/gamelan/sinusoide2/faustwasm/index.js | 4639 +++++++++++++++++ .../gamelan/sinusoide2/faustwasm/index.js.map | 7 + docs/gamelan/sinusoide2/icon.png | Bin 0 -> 5497 bytes docs/gamelan/sinusoide2/index.html | 76 + docs/gamelan/sinusoide2/index.js | 149 + docs/gamelan/sinusoide2/manifest.json | 17 + docs/gamelan/sinusoide2/service-worker.js | 73 + docs/index.html | 4 +- docs/js/jquery-1.10.2.min.js | 6 - docs/js/jquery-3.6.0.min.js | 2 + docs/search/search_index.json | 2 +- docs/sitemap.xml.gz | Bin 127 -> 127 bytes docs/smartfaust/sfcapture/dsp-meta.json | 6 +- docs/smartfaust/sfcapture/dsp-module.wasm | Bin 7806 -> 7807 bytes .../smartfaust/sfcapture/faustwasm/index.d.ts | 10 +- docs/smartfaust/sfcapture/faustwasm/index.js | 99 +- .../sfcapture/faustwasm/index.js.map | 4 +- docs/smartfaust/sfcapture/index.js | 72 +- docs/smartfaust/sfgretchenscat/dsp-meta.json | 6 +- .../smartfaust/sfgretchenscat/dsp-module.wasm | Bin 8017 -> 8018 bytes .../sfgretchenscat/faustwasm/index.d.ts | 10 +- .../sfgretchenscat/faustwasm/index.js | 99 +- .../sfgretchenscat/faustwasm/index.js.map | 4 +- docs/smartfaust/sfgretchenscat/index.js | 72 +- docs/smartfaust/sfhell/dsp-meta.json | 6 +- docs/smartfaust/sfhell/dsp-module.wasm | Bin 18931 -> 18932 bytes docs/smartfaust/sfhell/faustwasm/index.d.ts | 10 +- docs/smartfaust/sfhell/faustwasm/index.js | 99 +- docs/smartfaust/sfhell/faustwasm/index.js.map | 4 +- docs/smartfaust/sfhell/index.js | 72 +- docs/smartfaust/sfiter/dsp-meta.json | 6 +- docs/smartfaust/sfiter/dsp-module.wasm | Bin 18682 -> 18683 bytes docs/smartfaust/sfiter/faustwasm/index.d.ts | 10 +- docs/smartfaust/sfiter/faustwasm/index.js | 99 +- docs/smartfaust/sfiter/faustwasm/index.js.map | 4 +- docs/smartfaust/sfiter/index.js | 72 +- docs/smartfaust/sfsiren/dsp-meta.json | 6 +- docs/smartfaust/sfsiren/dsp-module.wasm | Bin 7229 -> 7230 bytes docs/smartfaust/sfsiren/faustwasm/index.d.ts | 10 +- docs/smartfaust/sfsiren/faustwasm/index.js | 99 +- .../smartfaust/sfsiren/faustwasm/index.js.map | 4 +- docs/smartfaust/sfsiren/index.js | 72 +- docs/smartfaust/sftrashcomb/dsp-meta.json | 6 +- docs/smartfaust/sftrashcomb/dsp-module.wasm | Bin 5107 -> 5108 bytes .../sftrashcomb/faustwasm/index.d.ts | 10 +- .../smartfaust/sftrashcomb/faustwasm/index.js | 99 +- .../sftrashcomb/faustwasm/index.js.map | 4 +- docs/smartfaust/sftrashcomb/index.js | 72 +- docs/smartfaust/sftrashring/dsp-meta.json | 6 +- docs/smartfaust/sftrashring/dsp-module.wasm | Bin 5608 -> 5609 bytes .../sftrashring/faustwasm/index.d.ts | 10 +- .../smartfaust/sftrashring/faustwasm/index.js | 99 +- .../sftrashring/faustwasm/index.js.map | 4 +- docs/smartfaust/sftrashring/index.js | 72 +- docs/smartfaust/sftrashshift/dsp-meta.json | 6 +- docs/smartfaust/sftrashshift/dsp-module.wasm | Bin 6043 -> 6044 bytes .../sftrashshift/faustwasm/index.d.ts | 10 +- .../sftrashshift/faustwasm/index.js | 99 +- .../sftrashshift/faustwasm/index.js.map | 4 +- docs/smartfaust/sftrashshift/index.js | 72 +- docs/smartfaust/sftrumpet/dsp-meta.json | 8 +- docs/smartfaust/sftrumpet/dsp-module.wasm | Bin 19639 -> 19594 bytes .../smartfaust/sftrumpet/faustwasm/index.d.ts | 10 +- docs/smartfaust/sftrumpet/faustwasm/index.js | 99 +- .../sftrumpet/faustwasm/index.js.map | 4 +- docs/smartfaust/sftrumpet/index.js | 72 +- docs/smartfaust/sfwindy/dsp-meta.json | 8 +- docs/smartfaust/sfwindy/dsp-module.wasm | Bin 12141 -> 12188 bytes docs/smartfaust/sfwindy/faustwasm/index.d.ts | 10 +- docs/smartfaust/sfwindy/faustwasm/index.js | 99 +- .../smartfaust/sfwindy/faustwasm/index.js.map | 4 +- docs/smartfaust/sfwindy/index.js | 72 +- 125 files changed, 13965 insertions(+), 878 deletions(-) create mode 100644 docs/gamelan/sinusoide2.png create mode 100644 docs/gamelan/sinusoide2/create-node.js create mode 100644 docs/gamelan/sinusoide2/dsp-meta.json create mode 100644 docs/gamelan/sinusoide2/dsp-module.wasm create mode 100644 docs/gamelan/sinusoide2/faust-ui/index.css create mode 100644 docs/gamelan/sinusoide2/faust-ui/index.css.map create mode 100644 docs/gamelan/sinusoide2/faust-ui/index.d.ts create mode 100644 docs/gamelan/sinusoide2/faust-ui/index.js create mode 100644 docs/gamelan/sinusoide2/faust-ui/index.js.map create mode 100644 docs/gamelan/sinusoide2/faustwasm/index.d.ts create mode 100644 docs/gamelan/sinusoide2/faustwasm/index.js create mode 100644 docs/gamelan/sinusoide2/faustwasm/index.js.map create mode 100644 docs/gamelan/sinusoide2/icon.png create mode 100644 docs/gamelan/sinusoide2/index.html create mode 100644 docs/gamelan/sinusoide2/index.js create mode 100644 docs/gamelan/sinusoide2/manifest.json create mode 100644 docs/gamelan/sinusoide2/service-worker.js delete mode 100644 docs/js/jquery-1.10.2.min.js create mode 100644 docs/js/jquery-3.6.0.min.js diff --git a/docs/gamelan/atomicro/dsp-meta.json b/docs/gamelan/atomicro/dsp-meta.json index a3fba85..d438c32 100644 --- a/docs/gamelan/atomicro/dsp-meta.json +++ b/docs/gamelan/atomicro/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "atomicro", "filename": "atomicro.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,7 @@ "." ], "size": 5041144, - "code": "wJa+", + "code": "8Ia+", "inputs": 1, "outputs": 1, "meta": [ @@ -87,7 +87,7 @@ "signals_lib_version": "1.6.0" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/atomicro/dsp-module.wasm b/docs/gamelan/atomicro/dsp-module.wasm index 949b690f6c13ad186c449c0e54ef1d4a00eea471..c1944ee65a81a2d978de83658ce2b3605b81751b 100644 GIT binary patch delta 45 zcmV+|0Mh@AD~&6#rV0zi3PAxklk*D50ys&ty$jO>0x>YNkr4X? DbSe-e delta 44 zcmV+{0Mq}CD~v0!rV0z;m4JW%0RTY&3)+*h3PAxglk*D50(VNYy$jO>0XMUf5c>pZ CeGoJN diff --git a/docs/gamelan/atomicro/faustwasm/index.d.ts b/docs/gamelan/atomicro/faustwasm/index.d.ts index 671a916..1443906 100644 --- a/docs/gamelan/atomicro/faustwasm/index.d.ts +++ b/docs/gamelan/atomicro/faustwasm/index.d.ts @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/atomicro/faustwasm/index.js b/docs/gamelan/atomicro/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/atomicro/faustwasm/index.js +++ b/docs/gamelan/atomicro/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/atomicro/faustwasm/index.js.map b/docs/gamelan/atomicro/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/atomicro/faustwasm/index.js.map +++ b/docs/gamelan/atomicro/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,a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M;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,KAAK;AAC5C,QAAI,SAAU,MAAM,GAAG,SAAS,QAAQ,EAAE,UAAU,QAAQ,CAAC;AAC7D,aAAS;AAAA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AG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/atomicro/index.js b/docs/gamelan/atomicro/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/atomicro/index.js +++ b/docs/gamelan/atomicro/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/attackey/dsp-meta.json b/docs/gamelan/attackey/dsp-meta.json index 943b953..ca5e651 100644 --- a/docs/gamelan/attackey/dsp-meta.json +++ b/docs/gamelan/attackey/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "attackey", "filename": "attackey.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,6 +10,7 @@ "." ], "size": 844636, + "code": "MPs0AZQTHw==", "inputs": 0, "outputs": 2, "meta": [ @@ -185,7 +186,7 @@ "soundfiles": "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/attacKey" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/attackey/dsp-module.wasm b/docs/gamelan/attackey/dsp-module.wasm index 111a6300730c9f373e7a1f42e8e395065d2cfe30..5b57c59c9be10fa6fd56defbbb4cd987ac07f120 100644 GIT binary patch delta 66 zcmV-I0KNaNodL$30kDTW3%aC$fB*piK>!Q0laf3^0XLJ>JiirVZ)9a6Iv^rVP;)Rr YT2WL;cRf8Kvyna83<5DQvusL21R9tYYXATM delta 43 zcmV+`0M!4+odK?$0kDTW3!!Pzlaf3^0W*`-JioK5J=hEZH?xFFLIiBc B5E1|Y diff --git a/docs/gamelan/attackey/faustwasm/index.d.ts b/docs/gamelan/attackey/faustwasm/index.d.ts index 671a916..1443906 100644 --- a/docs/gamelan/attackey/faustwasm/index.d.ts +++ b/docs/gamelan/attackey/faustwasm/index.d.ts @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/attackey/faustwasm/index.js b/docs/gamelan/attackey/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/attackey/faustwasm/index.js +++ b/docs/gamelan/attackey/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/attackey/faustwasm/index.js.map b/docs/gamelan/attackey/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/attackey/faustwasm/index.js.map +++ b/docs/gamelan/attackey/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,UAAM,EAAE,cAAc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Faust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAA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A,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/attackey/index.js b/docs/gamelan/attackey/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/attackey/index.js +++ b/docs/gamelan/attackey/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/baliphone/dsp-meta.json b/docs/gamelan/baliphone/dsp-meta.json index 7ec7db0..89ff867 100644 --- a/docs/gamelan/baliphone/dsp-meta.json +++ b/docs/gamelan/baliphone/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "baliphone", "filename": "baliphone.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,7 @@ "." ], "size": 844728, - "code": "ZCMf", + "code": "lBMf", "inputs": 0, "outputs": 2, "meta": [ @@ -162,7 +162,7 @@ "soundfiles": "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/baliphone" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/baliphone/dsp-module.wasm b/docs/gamelan/baliphone/dsp-module.wasm index eb71d51a3dfaa3d7d8ce520b9beaedd2ba4766d4..aa8e7110d354c6c97315c0f8073cb29f26f79cc4 100644 GIT binary patch delta 47 zcmbQaiE-8@#tppg+#O3A8W extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/baliphone/faustwasm/index.js b/docs/gamelan/baliphone/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/baliphone/faustwasm/index.js +++ b/docs/gamelan/baliphone/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/baliphone/faustwasm/index.js.map b/docs/gamelan/baliphone/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/baliphone/faustwasm/index.js.map +++ b/docs/gamelan/baliphone/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM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CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,KAAK;AAC5C,QAAI,SAAU,MAAM,GAAG,SAAS,QAAQ,EAAE,UAAU,QAAQ,CA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,cAAc,OAAO,EAAE,GAAG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/baliphone/index.js b/docs/gamelan/baliphone/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/baliphone/index.js +++ b/docs/gamelan/baliphone/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/drone/dsp-meta.json b/docs/gamelan/drone/dsp-meta.json index 54d04b9..cf494dd 100644 --- a/docs/gamelan/drone/dsp-meta.json +++ b/docs/gamelan/drone/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "drone", "filename": "drone.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,6 @@ "." ], "size": 256, - "code": "kBbT", "inputs": 0, "outputs": 2, "meta": [ @@ -129,7 +128,7 @@ "soundfiles_lib_version": "1.7.0" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/drone/dsp-module.wasm b/docs/gamelan/drone/dsp-module.wasm index f2b78cd7ecb329ff935cddceb2e842cac55827fc..942538995d76765afd3daf50c4bfeca24b6671cf 100644 GIT binary patch delta 695 zcmXYqJxE(o7>4hOHo5s#?ohb_FL*Z#uu=6#a`x1*e122 zo+xWwCWQ~sk=ou8;7ZT{@gf11=vMVEdA zlE{JS)auoq13ySJDe@8I%vR91nE3Y?@)YtgJOibW1Ji-ctGxi;k!DKdFOgp&|0Ll! z@-*@YJOibX1JkD6tGxoQN;56;3FJq1pMEUi6!Hx6Nq7dzAO|M1!>dgLpGh+#@)_h$ z96tSrgi+*K|$UzoeNJ`8@J3j!w^S31i4}4E+K`gXI_w;DM~pj@Cu+ zJL%?_xbPYmo;f=`50Wn9LcV@s38umF^$U2Qcetn` z9=1&hd_U8ktCyY7IrvZd2XaH*O+D;SWxnZ~YX7*uv7s;}sMz0ApSz#+(Ym`@3A7!n Mre1%g;c>$JA3~ec=>Px# delta 708 zcmXYqPe_wt9LL{B*7oZD7;hb{)3d#EVvv96AY`dCEz*K%p@k-HHjCzH(4fI!INEOU z6#HH35Om9ANo`}usIpNXBs@^6oCX(ik* z`xO22WSx6h4k=0=()XwwQS^=PF_}bClQmW#})OqSgosm(4>5 zPd}iqF*^>u0DTP9OO6U!zXHALk6H;7E?a;Op4R;_`xCR*pckP}g4*DysP*g6J%Ok- zfx=~r(81H0K+OKm><#E8=+mISa#Yg#4D<)kr%vg%@sP;Sm zp-_kTLuW&s;vr@6F4MD6w|GNekZ;m|BwN(c+$nbIGtHk(|Lf extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/drone/faustwasm/index.js b/docs/gamelan/drone/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/drone/faustwasm/index.js +++ b/docs/gamelan/drone/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/drone/faustwasm/index.js.map b/docs/gamelan/drone/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/drone/faustwasm/index.js.map +++ b/docs/gamelan/drone/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,k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A,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,KAAK;AAC5C,QAAI,SAAU,MAAM,GAAG,SAAS,QAAQ,EAAE,UAAU,QAAQ,CAAC;AAC7D,aAAS;AAAA;AAAA;AAAA;AAAA;AAAA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AM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/drone/index.js b/docs/gamelan/drone/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/drone/index.js +++ b/docs/gamelan/drone/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/index.html b/docs/gamelan/index.html index 7f37d87..7a0e1e8 100644 --- a/docs/gamelan/index.html +++ b/docs/gamelan/index.html @@ -109,6 +109,10 @@ + @@ -121,7 +125,7 @@

GameLAN applications

GameLAN is a set of musical applications designed by Grame, Centre National de Création Musicale.

-

The 7 applications in the "GameLAN" family (atomicro, attackey, baliphone, drone, sequenceur, shakerxy, sinusoide) can be played solo or in orchestra.

+

The 8 applications in the "GameLAN" family (atomicro, attackey, baliphone, drone, sequenceur, shakerxy, sinusoide, sinusoide2) can be played solo or in orchestra.

Privacy Policy

This smartphone application is a ​musical instrument​. It doesn’t collect any personal data of any kind. The microphone input is only used for real-time sound production and no audio recording is ever collected or transmitted.

Applications

@@ -153,6 +157,10 @@

shakerxy

sinusoide

+

+

sinusoide2

+

+

diff --git a/docs/gamelan/sequenceur/dsp-meta.json b/docs/gamelan/sequenceur/dsp-meta.json index bfba31b..7e7d183 100644 --- a/docs/gamelan/sequenceur/dsp-meta.json +++ b/docs/gamelan/sequenceur/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "sequenceur", "filename": "sequenceur.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,7 @@ "." ], "size": 336, - "code": "EP3i", + "code": "QO3i", "inputs": 0, "outputs": 2, "meta": [ @@ -84,7 +84,7 @@ "soundfiles": "https://raw.githubusercontent.com/grame-cncm/GameLAN/master/sequenceur" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/sequenceur/dsp-module.wasm b/docs/gamelan/sequenceur/dsp-module.wasm index 8980f8837c895d9df91acdd10c0af8466b60f9da..8090f4188e036c5c4104a35a8a68e8e46e0deca6 100644 GIT binary patch delta 51 zcmV-30L=fiRkc;H&J_*fseph00RTY&3)?AslaLw|lkXKT0XLH$7Q_NkPqXC~;sgRQ JFtf-T><<0!6Au6Y delta 50 zcmV-20L}lkRkT&G&J_*eseph00RTY&3)(4rlaLw|lkXKT0W*^y7Q_NYP_yM0;sgOV Iv&kFm4(o0b)Bpeg diff --git a/docs/gamelan/sequenceur/faustwasm/index.d.ts b/docs/gamelan/sequenceur/faustwasm/index.d.ts index 671a916..1443906 100644 --- a/docs/gamelan/sequenceur/faustwasm/index.d.ts +++ b/docs/gamelan/sequenceur/faustwasm/index.d.ts @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/sequenceur/faustwasm/index.js b/docs/gamelan/sequenceur/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/sequenceur/faustwasm/index.js +++ b/docs/gamelan/sequenceur/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/sequenceur/faustwasm/index.js.map b/docs/gamelan/sequenceur/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/sequenceur/faustwasm/index.js.map +++ b/docs/gamelan/sequenceur/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,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A,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,UAAM,EAAE,cAAc,IAAI,MAAM,OAAO,KAAK;AAC5C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,OAAO;AAAA,QAAa,OAAO;AAAA,UACvC,EAAE,MAAM,UAAU,OAAO,cAAc,OAAO,EAAE,GAAG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/sequenceur/index.js b/docs/gamelan/sequenceur/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/sequenceur/index.js +++ b/docs/gamelan/sequenceur/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/shakerxy/dsp-meta.json b/docs/gamelan/shakerxy/dsp-meta.json index 68a5e70..cd47269 100644 --- a/docs/gamelan/shakerxy/dsp-meta.json +++ b/docs/gamelan/shakerxy/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "shakerxy", "filename": "shakerxy.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,7 @@ "." ], "size": 132, - "code": "KCO5", + "code": "WBO5", "inputs": 0, "outputs": 2, "meta": [ @@ -120,7 +120,7 @@ "soundfiles_lib_version": "1.7.0" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/shakerxy/dsp-module.wasm b/docs/gamelan/shakerxy/dsp-module.wasm index ffb175bd63b857afab9b34e039d4d84b7ad8d717..23e07f95ba75ff98fa154ff91511d1414d3f0e0c 100644 GIT binary patch delta 45 zcmcbje^r0Oe=hEeGaDKh7#SQHxKB;y;&x;-pX|eZgelxz;&x;-p6tVYgvr}^vk;FiJEQq#N8u?f0A8aF Af&c&j diff --git a/docs/gamelan/shakerxy/faustwasm/index.d.ts b/docs/gamelan/shakerxy/faustwasm/index.d.ts index 671a916..1443906 100644 --- a/docs/gamelan/shakerxy/faustwasm/index.d.ts +++ b/docs/gamelan/shakerxy/faustwasm/index.d.ts @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/shakerxy/faustwasm/index.js b/docs/gamelan/shakerxy/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/shakerxy/faustwasm/index.js +++ b/docs/gamelan/shakerxy/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/shakerxy/faustwasm/index.js.map b/docs/gamelan/shakerxy/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/shakerxy/faustwasm/index.js.map +++ b/docs/gamelan/shakerxy/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], - "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAAA,EAC3E,OAAO;AACH,UAAM,EAAE,UAAU,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1C,U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ust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAA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AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/shakerxy/index.js b/docs/gamelan/shakerxy/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/shakerxy/index.js +++ b/docs/gamelan/shakerxy/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/sinusoide/dsp-meta.json b/docs/gamelan/sinusoide/dsp-meta.json index 4af9c77..a663bed 100644 --- a/docs/gamelan/sinusoide/dsp-meta.json +++ b/docs/gamelan/sinusoide/dsp-meta.json @@ -1,7 +1,7 @@ { "name": "sinusoide", "filename": "sinusoide.dsp", - "version": "2.75.3", + "version": "2.75.7", "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", "include_pathnames": [ "/share/faust", @@ -10,7 +10,7 @@ "." ], "size": 1106788, - "code": "4Po0AWQjHw==", + "code": "EOs0AZQTHw==", "inputs": 0, "outputs": 1, "meta": [ @@ -168,7 +168,7 @@ "signals_lib_version": "1.6.0" }, { - "version": "2.75.7" + "version": "2.75.10" } ], "ui": [ diff --git a/docs/gamelan/sinusoide/dsp-module.wasm b/docs/gamelan/sinusoide/dsp-module.wasm index 2361d34647ca60caeb5c95179c1c5460f8024a3f..709c423185b34676f9e52f9f4bfd5177137e06b2 100644 GIT binary patch delta 53 zcmZqgVeIH(+_1)k`}(4W1_nk3M+WW-lee2VGn!BSZE}Lc)xX%lF)A=*^J&utZYD#6 J%|4F1SpW}C68!)G delta 52 zcmeC^VQlYV+_1)k``V(01_nk3M+WZmlee2VGa66+ZE}LcBp~0wF+4D9^J&utZbtLX IzK*+D0Q@Tw%m4rY diff --git a/docs/gamelan/sinusoide/faustwasm/index.d.ts b/docs/gamelan/sinusoide/faustwasm/index.d.ts index 671a916..1443906 100644 --- a/docs/gamelan/sinusoide/faustwasm/index.d.ts +++ b/docs/gamelan/sinusoide/faustwasm/index.d.ts @@ -1289,8 +1289,11 @@ export declare class FaustAudioWorkletNode extends protected fUICallback: UIHandler; protected fDescriptor: FaustUIInputItem[]; constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; setOutputParamHandler(handler: OutputParamHandler | null): void; getOutputParamHandler(): OutputParamHandler | null; setComputeHandler(handler: ComputeHandler | null): void; @@ -1353,8 +1356,11 @@ export declare class FaustScriptProcessorNode exte protected fInputs: Float32Array[]; protected fOutputs: Float32Array[]; init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; /** Setup accelerometer and gyroscope handlers */ - listenSensors(): Promise; + startSensors(): Promise; + stopSensors(): void; compute(input: Float32Array[], output: Float32Array[]): boolean; setOutputParamHandler(handler: OutputParamHandler): void; getOutputParamHandler(): OutputParamHandler | null; diff --git a/docs/gamelan/sinusoide/faustwasm/index.js b/docs/gamelan/sinusoide/faustwasm/index.js index 60bd836..125645c 100644 --- a/docs/gamelan/sinusoide/faustwasm/index.js +++ b/docs/gamelan/sinusoide/faustwasm/index.js @@ -783,8 +783,8 @@ function __generator(thisArg, body) { if (t[0] & 1) throw t[1]; return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { @@ -3696,6 +3696,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) }); __privateAdd(this, _hasAccInput, false); __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; this.fJSONDsp = JSONObj; this.fJSON = factory.json; this.fOutputHandler = null; @@ -3727,56 +3739,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) } }; } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); - if (response !== "granted") + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + } } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } setOutputParamHandler(handler) { this.fOutputHandler = handler; } @@ -3966,6 +3981,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { // src/FaustScriptProcessorNode.ts var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } init(instance) { this.fDSPCode = instance; this.fInputs = new Array(this.fDSPCode.getNumInputs()); @@ -3981,56 +4011,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || }; this.start(); } - // Public API /** Setup accelerometer and gyroscope handlers */ - async listenSensors() { + async startSensors() { if (this.hasAccInput) { - const isAndroid = /Android/i.test(navigator.userAgent); - const handleDeviceMotion = ({ accelerationIncludingGravity }) => { - if (!accelerationIncludingGravity) - return; - const { x, y, z } = accelerationIncludingGravity; - this.propagateAcc({ x, y, z }, isAndroid); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceMotionEvent.requestPermission === "function") { try { const response = await window.DeviceMotionEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the accelerometer."); - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } catch (error) { console.error(error); } } else { - window.addEventListener("devicemotion", handleDeviceMotion, true); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); } } else { console.log("Cannot set the accelerometer handler."); } } if (this.hasGyrInput) { - const handleDeviceOrientation = ({ alpha, beta, gamma }) => { - this.propagateGyr({ alpha, beta, gamma }); - }; if (window.DeviceMotionEvent) { if (typeof window.DeviceOrientationEvent.requestPermission === "function") { try { const response = await window.DeviceOrientationEvent.requestPermission(); if (response !== "granted") throw new Error("Unable to access the gyroscope."); - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } catch (error) { console.error(error); } } else { - window.addEventListener("deviceorientation", handleDeviceOrientation, true); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); } } else { console.log("Cannot set the gyroscope handler."); } } } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } compute(input, output) { return this.fDSPCode.compute(input, output); } diff --git a/docs/gamelan/sinusoide/faustwasm/index.js.map b/docs/gamelan/sinusoide/faustwasm/index.js.map index 3125448..599e3fa 100644 --- a/docs/gamelan/sinusoide/faustwasm/index.js.map +++ b/docs/gamelan/sinusoide/faustwasm/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], - "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n /** Setup accelerometer and gyroscope handlers */\n async listenSensors() {\n if (this.hasAccInput) {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n const handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.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IAAI;AACvE,UAAM,IAAI,EAAE,GAAG,EAAE;AACjB,QAAI,GAAG;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAa,OAAO;AAAA,UACvC,EAAE,MAAM,UAAU,OAAO,cAAc,OAAO,EAAE,GAAG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAg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D;AAAA,EAEA,UAAU;AACN,UAAM,IAAK,KAAK,eAAgB,KAAK,MAAM,KAAK,aAAa,IAAI,IAAI;AACrE,UAAM,IAAK,KAAK,gBAAiB,KAAK,MAAM,KAAK,cAAc,IAAI,IAAI;AACvE,UAAM,IAAI,EAAE,GAAG,EAAE;AACjB,QAAI,GAAG;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAa,OAAO;AAAA,UACvC,EAAE,MAAM,UAAU,OAAO,cAAc,OAAO,EAAE,GAAG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] } diff --git a/docs/gamelan/sinusoide/index.js b/docs/gamelan/sinusoide/index.js index 107254b..02fbaff 100644 --- a/docs/gamelan/sinusoide/index.js +++ b/docs/gamelan/sinusoide/index.js @@ -31,9 +31,9 @@ audioContext.suspend(); (async () => { + const { createFaustNode } = await import("./create-node.js"); // To test the ScriptProcessorNode mode // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); - const { createFaustNode } = await import("./create-node.js"); const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); if (!faustNode) throw new Error("Faust DSP not compiled"); @@ -50,8 +50,8 @@ audioContext.suspend(); await connectToAudioInput(audioContext, null, faustNode, null); } - // Function to initialize MIDI - function initMIDI() { + // Function to start MIDI + function startMIDI() { // Check if the browser supports the Web MIDI API if (navigator.requestMIDIAccess) { navigator.requestMIDIAccess().then( @@ -69,25 +69,81 @@ audioContext.suspend(); } } + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + // Function to resume AudioContext, activate MIDI and Sensors on user interaction - function activateAudioMIDISensors() { + async function activateAudioMIDISensors() { // Resume the AudioContext if (audioContext.state === 'suspended') { - audioContext.resume(); + await audioContext.resume(); } // Activate sensor listeners - faustNode.listenSensors(); + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } // Initialize the MIDI setup - if (FAUST_DSP_VOICES > 0) { - initMIDI(); + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; } } // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction window.addEventListener('click', activateAudioMIDISensors); window.addEventListener('touchstart', activateAudioMIDISensors); + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + })(); diff --git a/docs/gamelan/sinusoide2.png b/docs/gamelan/sinusoide2.png new file mode 100644 index 0000000000000000000000000000000000000000..f2982df783b6e10423ae2d2328979ab7163fcd9f GIT binary patch literal 616 zcmV-u0+;=XP)9kvq~XG4p5UkW zY0A^`6hFab3d3B^jFe3l3v9ilnncRDFu^&*nEkbyV?FJ5XlL%HEwSgh-?IR4K0g;f zR)668g{|3b=L3ZRQJI;A*=@TAeu}y+$8BGuOxXaa1K-@IC`9av0?+^}c;JH<*#K($ zcyZeRu<7jEPhMmPNCruS2Y7LHzz?1L=YY2*nY$*c|8FZZ0EIed)P#jHhuX(3)L?r= zJ7fW%0fO({+(Caosd7ddQ~^X~f(RY}v_l*8N8Ox-$^mF57jv1r!Q5Ggv8@8|NxY!B zgC*C9cFJ~%04xOE+|>3@Mb<_;C;>otn_XFb!>`5%y3&(4830f@q&GicYH?G8*dxhH z{L27%WqF+-%kic*R51&HZ;q_qJAimS5av!^lmNi?W}V3OF5XzF{j$Xz0E9QLmHbzG zfCVN~D+3t3h|)0RFw;^DhE65`G!U7BLI8!>KA_;(jaL{(+ICL@up9v%w45UM>LbJYHPw;B1dg^Qck)X1Dmk`i)gXb+a^p(Ez)K z$rJuW;UA{kaJ>?Mmkb(itj_Tx&vvs} - An object containing the Faust audio node and the DSP metadata. + */ +const createFaustNode = async (audioContext, dspName = "template", voices = 0, sp = false) => { + // Set to true if the DSP has an effect + const FAUST_DSP_HAS_EFFECT = false; + + // Import necessary Faust modules and data + const { FaustMonoDspGenerator, FaustPolyDspGenerator } = await import("./faustwasm/index.js"); + + // Load DSP metadata from JSON + /** @type {FaustDspMeta} */ + const dspMeta = await (await fetch("./dsp-meta.json")).json(); + + // Compile the DSP module from WebAssembly binary data + const dspModule = await WebAssembly.compileStreaming(await fetch("./dsp-module.wasm")); + + // Create an object representing Faust DSP with metadata and module + /** @type {FaustDspDistribution} */ + const faustDsp = { dspMeta, dspModule }; + + /** @type {FaustNode | null} */ + let faustNode = null; + + // Create either a polyphonic or monophonic Faust audio node based on the number of voices + if (voices > 0) { + + // Try to load optional mixer and effect modules + faustDsp.mixerModule = await WebAssembly.compileStreaming(await fetch("./mixer-module.wasm")); + + if (FAUST_DSP_HAS_EFFECT) { + faustDsp.effectMeta = await (await fetch("./effect-meta.json")).json(); + faustDsp.effectModule = await WebAssembly.compileStreaming(await fetch("./effect-module.wasm")); + } + + // Create a polyphonic Faust audio node + const generator = new FaustPolyDspGenerator(); + faustNode = await generator.createNode( + audioContext, + voices, + dspName, + { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta), soundfiles: {} }, + faustDsp.mixerModule, + faustDsp.effectModule ? { module: faustDsp.effectModule, json: JSON.stringify(faustDsp.effectMeta), soundfiles: {} } : undefined, + sp + ); + } else { + // Create a standard Faust audio node + const generator = new FaustMonoDspGenerator(); + faustNode = await generator.createNode( + audioContext, + dspName, + { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta), soundfiles: {} }, + sp + ); + } + + // Return an object with the Faust audio node and the DSP metadata + return { faustNode, dspMeta }; +} + +/** + * Connects an audio input stream to a Faust audio node. + * + * @param {AudioContext} audioContext - The Web Audio API AudioContext to which the Faust audio node is connected. + * @param {string} id - The ID of the audio input device to connect. + * @param {FaustNode} faustNode - The Faust audio node to which the audio input stream will be connected. + * @param {MediaStreamAudioSourceNode} inputStreamNode - The audio input stream node to be disconnected from the Faust audio node. + * @returns {Promise} - The audio input stream node connected to the Faust audio node. + */ +async function connectToAudioInput(audioContext, id, faustNode, inputStreamNode) { + // Create an audio input stream node + const constraints = { + audio: { + echoCancellation: false, + noiseSuppression: false, + autoGainControl: false, + deviceId: id ? { exact: id } : undefined, + }, + }; + // Get the audio input stream + const stream = await navigator.mediaDevices.getUserMedia(constraints); + if (stream) { + if (inputStreamNode) inputStreamNode.disconnect(); + inputStreamNode = audioContext.createMediaStreamSource(stream); + inputStreamNode.connect(faustNode); + } + return inputStreamNode; +}; + +/** + * @param {FaustAudioWorkletNode} faustNode + */ +async function createFaustUI(divFaustUI, faustNode) { + const { FaustUI } = await import("./faust-ui/index.js"); + const $container = document.createElement("div"); + $container.style.margin = "0"; + $container.style.position = "absolute"; + $container.style.overflow = "auto"; + $container.style.display = "flex"; + $container.style.flexDirection = "column"; + $container.style.width = "100%"; + $container.style.height = "100%"; + divFaustUI.appendChild($container); + const faustUI = new FaustUI({ + ui: faustNode.getUI(), + root: $container, + listenWindowMessage: false, + listenWindowResize: true, + }); + faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value); + faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value)); + $container.style.minWidth = `${faustUI.minWidth}px`; + $container.style.minHeight = `${faustUI.minHeight}px`; + faustUI.resize(); +}; + +// Export the functions +export { createFaustNode, createFaustUI, connectToAudioInput }; + diff --git a/docs/gamelan/sinusoide2/dsp-meta.json b/docs/gamelan/sinusoide2/dsp-meta.json new file mode 100644 index 0000000..026f53c --- /dev/null +++ b/docs/gamelan/sinusoide2/dsp-meta.json @@ -0,0 +1,597 @@ +{ + "name": "sinusoide2", + "filename": "sinusoide2.dsp", + "version": "2.75.7", + "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2", + "include_pathnames": [ + "/share/faust", + "/usr/local/share/faust", + "/usr/share/faust", + "." + ], + "size": 1196740, + "code": "iLYgBZQTHw==", + "inputs": 0, + "outputs": 1, + "meta": [ + { + "basics_lib_name": "Faust Basic Element Library" + }, + { + "basics_lib_tabulateNd": "Copyright (C) 2023 Bart Brouns " + }, + { + "basics_lib_version": "1.19.1" + }, + { + "compile_options": "-single -scal -e ../sinusoide2.dsp -o sinusoide2.dsp" + }, + { + "delays_lib_fdelay4_author": "Julius O. Smith III" + }, + { + "delays_lib_fdelayltv_author": "Julius O. Smith III" + }, + { + "delays_lib_name": "Faust Delay Library" + }, + { + "delays_lib_version": "1.1.0" + }, + { + "envelopes_lib_ar_author": "Yann Orlarey, Stéphane Letz" + }, + { + "envelopes_lib_author": "GRAME" + }, + { + "envelopes_lib_copyright": "GRAME" + }, + { + "envelopes_lib_license": "LGPL with exception" + }, + { + "envelopes_lib_name": "Faust Envelope Library" + }, + { + "envelopes_lib_version": "1.3.0" + }, + { + "filename": "sinusoide2.dsp" + }, + { + "filters_lib_allpass_comb_author": "Julius O. Smith III" + }, + { + "filters_lib_allpass_comb_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_allpass_comb_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_fir_author": "Julius O. Smith III" + }, + { + "filters_lib_fir_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_fir_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_highpass_author": "Julius O. Smith III" + }, + { + "filters_lib_highpass_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_iir_author": "Julius O. Smith III" + }, + { + "filters_lib_iir_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_iir_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_lowpass0_highpass1": "MIT-style STK-4.3 license" + }, + { + "filters_lib_lowpass0_highpass1_author": "Julius O. Smith III" + }, + { + "filters_lib_lowpass_author": "Julius O. Smith III" + }, + { + "filters_lib_lowpass_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_lowpass_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_name": "Faust Filters Library" + }, + { + "filters_lib_pole_author": "Julius O. Smith III" + }, + { + "filters_lib_pole_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_pole_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_resonbp_author": "Julius O. Smith III" + }, + { + "filters_lib_resonbp_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_resonbp_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_resonlp_author": "Julius O. Smith III" + }, + { + "filters_lib_resonlp_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_resonlp_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_tf1_author": "Julius O. Smith III" + }, + { + "filters_lib_tf1_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_tf1_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_tf1s_author": "Julius O. Smith III" + }, + { + "filters_lib_tf1s_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_tf1s_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_tf2_author": "Julius O. Smith III" + }, + { + "filters_lib_tf2_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_tf2_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_tf2s_author": "Julius O. Smith III" + }, + { + "filters_lib_tf2s_copyright": "Copyright (C) 2003-2019 by Julius O. Smith III " + }, + { + "filters_lib_tf2s_license": "MIT-style STK-4.3 license" + }, + { + "filters_lib_version": "1.3.0" + }, + { + "library_path0": "/usr/local/share/faust/stdfaust.lib" + }, + { + "library_path1": "/usr/local/share/faust/basics.lib" + }, + { + "library_path10": "/usr/local/share/faust/delays.lib" + }, + { + "library_path11": "/usr/local/share/faust/routes.lib" + }, + { + "library_path12": "/usr/local/share/faust/misceffects.lib" + }, + { + "library_path13": "/usr/local/share/faust/envelopes.lib" + }, + { + "library_path2": "/usr/local/share/faust/signals.lib" + }, + { + "library_path3": "/usr/local/share/faust/maths.lib" + }, + { + "library_path4": "/usr/local/share/faust/platform.lib" + }, + { + "library_path5": "/usr/local/share/faust/oscillators.lib" + }, + { + "library_path6": "/usr/local/share/faust/filters.lib" + }, + { + "library_path7": "/usr/local/share/faust/noises.lib" + }, + { + "library_path8": "/usr/local/share/faust/physmodels.lib" + }, + { + "library_path9": "/usr/local/share/faust/reverbs.lib" + }, + { + "maths_lib_author": "GRAME" + }, + { + "maths_lib_copyright": "GRAME" + }, + { + "maths_lib_license": "LGPL with exception" + }, + { + "maths_lib_name": "Faust Math Library" + }, + { + "maths_lib_version": "2.8.0" + }, + { + "misceffects_lib_cubicnl_author": "Julius O. Smith III" + }, + { + "misceffects_lib_cubicnl_license": "STK-4.3" + }, + { + "misceffects_lib_name": "Misc Effects Library" + }, + { + "misceffects_lib_version": "2.5.0" + }, + { + "name": "sinusoide2" + }, + { + "noises_lib_name": "Faust Noise Generator Library" + }, + { + "noises_lib_version": "1.4.1" + }, + { + "oscillators_lib_lf_sawpos_author": "Bart Brouns, revised by Stéphane Letz" + }, + { + "oscillators_lib_lf_sawpos_licence": "STK-4.3" + }, + { + "oscillators_lib_name": "Faust Oscillator Library" + }, + { + "oscillators_lib_sawN_author": "Julius O. Smith III" + }, + { + "oscillators_lib_sawN_license": "STK-4.3" + }, + { + "oscillators_lib_version": "1.5.1" + }, + { + "physmodels_lib_name": "Faust Physical Models Library" + }, + { + "physmodels_lib_version": "1.1.0" + }, + { + "platform_lib_name": "Generic Platform Library" + }, + { + "platform_lib_version": "1.3.0" + }, + { + "reverbs_lib_name": "Faust Reverb Library" + }, + { + "reverbs_lib_version": "1.3.0" + }, + { + "routes_lib_hadamard_author": "Remy Muller, revised by Romain Michon" + }, + { + "routes_lib_name": "Faust Signal Routing Library" + }, + { + "routes_lib_version": "1.2.0" + }, + { + "signals_lib_name": "Faust Signal Routing Library" + }, + { + "signals_lib_version": "1.6.0" + }, + { + "version": "2.75.10" + } + ], + "ui": [ + { + "type": "vgroup", + "label": "sinusoide2", + "items": [ + { + "type": "hslider", + "label": "Volume", + "shortname": "Volume", + "address": "/sinusoide2/Volume", + "index": 264628, + "meta": [ + { + "acc": "1 0 -9 0 10" + }, + { + "hidden": "1" + } + ], + "init": 0.35, + "min": 0, + "max": 0.7, + "step": 0.001 + }, + { + "type": "checkbox", + "label": "SLIDE", + "shortname": "SLIDE", + "address": "/sinusoide2/SLIDE", + "index": 264592, + "meta": [ + { + "0": "" + } + ] + }, + { + "type": "vslider", + "label": "Dry/Wet Mix", + "shortname": "Wet_Mix", + "address": "/sinusoide2/Dry/Wet_Mix", + "index": 264652, + "meta": [ + { + "1": "" + }, + { + "hidden": "1" + }, + { + "style": "knob" + } + ], + "init": 1, + "min": 0, + "max": 1, + "step": 0.01 + }, + { + "type": "hslider", + "label": "bouger", + "shortname": "bouger", + "address": "/sinusoide2/bouger", + "index": 264680, + "meta": [ + { + "acc": "0 0 -10 0 10" + }, + { + "hidden": "1" + } + ], + "init": 1, + "min": 0, + "max": 2, + "step": 0.01 + }, + { + "type": "vgroup", + "label": "gamme", + "items": [ + { + "type": "hgroup", + "label": ".", + "meta": [ + { + "0": "" + } + ], + "items": [ + { + "type": "checkbox", + "label": "do", + "shortname": "P4_sinusoide2_gamme___do", + "address": "/sinusoide2/gamme/./do", + "index": 264544, + "meta": [ + { + "0": "" + } + ] + }, + { + "type": "checkbox", + "label": "do#", + "shortname": "P5_sinusoide2_gamme___do", + "address": "/sinusoide2/gamme/./do_", + "index": 264548, + "meta": [ + { + "1": "" + } + ] + }, + { + "type": "checkbox", + "label": "ré", + "shortname": "P6_sinusoide2_gamme___r", + "address": "/sinusoide2/gamme/./ré", + "index": 264552, + "meta": [ + { + "2": "" + } + ] + } + ] + }, + { + "type": "hgroup", + "label": ".", + "meta": [ + { + "1": "" + } + ], + "items": [ + { + "type": "checkbox", + "label": "ré#", + "shortname": "P7_sinusoide2_gamme___r", + "address": "/sinusoide2/gamme/./ré_", + "index": 264556, + "meta": [ + { + "0": "" + } + ] + }, + { + "type": "checkbox", + "label": "mi", + "shortname": "mi", + "address": "/sinusoide2/gamme/./mi", + "index": 264560, + "meta": [ + { + "1": "" + } + ] + }, + { + "type": "checkbox", + "label": "fa", + "shortname": "P9_sinusoide2_gamme___fa", + "address": "/sinusoide2/gamme/./fa", + "index": 264564, + "meta": [ + { + "2": "" + } + ] + } + ] + }, + { + "type": "hgroup", + "label": ".", + "meta": [ + { + "2": "" + } + ], + "items": [ + { + "type": "checkbox", + "label": "fa#", + "shortname": "P10_sinusoide2_gamme___fa", + "address": "/sinusoide2/gamme/./fa_", + "index": 264568, + "meta": [ + { + "0": "" + } + ] + }, + { + "type": "checkbox", + "label": "sol", + "shortname": "P11_sinusoide2_gamme___sol", + "address": "/sinusoide2/gamme/./sol", + "index": 264572, + "meta": [ + { + "1": "" + } + ] + }, + { + "type": "checkbox", + "label": "sol#", + "shortname": "P12_sinusoide2_gamme___sol", + "address": "/sinusoide2/gamme/./sol_", + "index": 264576, + "meta": [ + { + "2": "" + } + ] + } + ] + }, + { + "type": "hgroup", + "label": ".", + "meta": [ + { + "3": "" + } + ], + "items": [ + { + "type": "checkbox", + "label": "la", + "shortname": "P13_sinusoide2_gamme___la", + "address": "/sinusoide2/gamme/./la", + "index": 264580, + "meta": [ + { + "0": "" + } + ] + }, + { + "type": "checkbox", + "label": "la#", + "shortname": "P14_sinusoide2_gamme___la", + "address": "/sinusoide2/gamme/./la_", + "index": 264584, + "meta": [ + { + "1": "" + } + ] + }, + { + "type": "checkbox", + "label": "si", + "shortname": "si", + "address": "/sinusoide2/gamme/./si", + "index": 264588, + "meta": [ + { + "2": "" + } + ] + } + ] + } + ] + }, + { + "type": "hslider", + "label": "son", + "shortname": "son", + "address": "/sinusoide2/son", + "index": 264672, + "init": 0, + "min": 0, + "max": 4, + "step": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/dsp-module.wasm b/docs/gamelan/sinusoide2/dsp-module.wasm new file mode 100644 index 0000000000000000000000000000000000000000..901feb42b8ab89cff3d77eaca331cc4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`V){Dgp&lOVw`JwR&dNtt=Mn6tZ66A zWKAC9Pv3T!*@u4}__y8Jz|o9#yQ~RL9DAHKN68(Aez<|{O&va%SjiauLB-!~wBoT9 z@z%(i#tAUBrg7BrLfi7HCUjn-@!~p!dIv)`&8`0CMjM@XCcI|lJxx;}>*mLL?dlo0yj>ml-By7(eMpiUy zuvgc0p~M4jttN{XI&LMt{v%NW@VQjk|h=);~ z;r<+Hv0yOg8Mtw`T58xN}gE_0x_8sGDc6?TYolZja!J*uPtuv?`u;}2WK;`vJy+X>TP4_E$K8qrHgg3LsECg2+1HW&a z3-C(8TC|JYS|WQ{BJ*~vK}0tVPo|41R>d^U{YehTOxYT4{Q?eowehSMG|)IQHN}f=HG5R_IOPLj<^3huhyo zHcm#h90!hWs0VKDvridX*}NM#{5H&X`WyYu)%I*;R7F=v~4hh(Vg5A}t;PxlVu zxmvNwstV347rEK33XK>SszxiHOXqW|nD484_nmu5h)XLHQ5K|y yc(k6Nc1cRA@gbd5jQ6n( .faust-ui-component-label { + position: relative; + margin-top: 4px; + width: 100%; + user-select: none; +} +.faust-ui-component > .faust-ui-component-label > canvas { + position: relative; + display: block; + max-width: 100%; + max-height: 100%; +} +.faust-ui-component input { + box-shadow: none; +} +/*!**********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/VSlider.scss ***! + \**********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-vslider { + align-items: center; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-label { + flex: 0 0 auto; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv { + position: relative; + display: flex; + flex-direction: column; + flex: 1 1 auto; + width: 100%; + height: auto; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv > .faust-ui-component-vslider-canvasdiv { + position: relative; + display: block; + flex: 1 1 auto; + width: 100%; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv > .faust-ui-component-vslider-canvasdiv > canvas { + position: absolute; + display: block; + height: 100%; + width: 100%; + touch-action: none; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: 5px auto auto auto; + border-width: 0px; + border-radius: 4px; + height: 5%; + max-width: calc(100% - 8px); + padding: 2px 4px; + -moz-appearance: textfield; +} +.faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv input::-webkit-inner-spin-button, .faust-ui-component.faust-ui-component-vslider > .faust-ui-component-vslider-flexdiv input::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} +/*!**********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/HSlider.scss ***! + \**********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-label { + flex: 0 0 auto; +} +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv { + position: relative; + display: flex; + flex-direction: row-reverse; + flex: 1 1 auto; + width: 100%; + height: auto; +} +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv > .faust-ui-component-hslider-canvasdiv { + position: relative; + display: block; + flex: 1 1 auto; + height: 100%; + margin: auto; +} +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv > .faust-ui-component-hslider-canvasdiv > canvas { + position: absolute; + display: block; + height: 100%; + width: 100%; + touch-action: none; +} +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv > input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: auto 5px auto auto; + border-width: 0px; + border-radius: 4px; + width: calc(20% - 13px); + padding: 2px 4px; + -moz-appearance: textfield; +} +.faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv > input::-webkit-inner-spin-button, .faust-ui-component.faust-ui-component-hslider > .faust-ui-component-hslider-flexdiv > input::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} +/*!*********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Nentry.scss ***! + \*********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-nentry { + align-items: center; +} +.faust-ui-component.faust-ui-component-nentry input { + margin: 0px; + text-align: center; + border-width: 1px; + border-radius: 4px; + padding: 2px 4px; + width: calc(100% - 8px); +} +.faust-ui-component.faust-ui-component-nentry input::-webkit-inner-spin-button, .faust-ui-component.faust-ui-component-nentry input::-webkit-outer-spin-button { + opacity: 1; +} +/*!************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Soundfile.scss ***! + \************************************************************************************************************************/ +.faust-ui-component.faust-ui-component-soundfile > div { + display: flex; + position: relative; + cursor: pointer; + border-width: 1px; + text-align: center; + border-radius: 4px; + flex: 1 0 auto; + border-style: solid; +} +.faust-ui-component.faust-ui-component-soundfile > div > span { + user-select: none; + margin: auto; +} +/*!*********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Button.scss ***! + \*********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-button > div { + display: flex; + position: relative; + cursor: pointer; + border-width: 1px; + text-align: center; + border-radius: 4px; + flex: 1 0 auto; + border-style: solid; + touch-action: none; +} +.faust-ui-component.faust-ui-component-button > div > span { + user-select: none; + margin: auto; +} +/*!***********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Checkbox.scss ***! + \***********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-checkbox > div { + display: flex; + position: relative; + cursor: pointer; + border-width: 1px; + text-align: center; + border-radius: 1px; + flex: 1 0 auto; + border-style: solid; + touch-action: none; +} +.faust-ui-component.faust-ui-component-checkbox > div > span { + margin: auto; + user-select: none; +} +/*!*******************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Knob.scss ***! + \*******************************************************************************************************************/ +.faust-ui-component.faust-ui-component-knob { + align-items: center; +} +.faust-ui-component.faust-ui-component-knob > canvas { + position: relative; + display: block; + flex: 1 1 auto; + min-height: 50%; + width: 100%; + touch-action: none; +} +.faust-ui-component.faust-ui-component-knob > input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: 0px; + border-width: 0px; + border-radius: 4px; + max-width: calc(100% - 8px); + padding: 2px 4px; + -moz-appearance: textfield; +} +.faust-ui-component.faust-ui-component-knob > input::-webkit-inner-spin-button, .faust-ui-component.faust-ui-component-knob > input::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} +/*!*******************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Menu.scss ***! + \*******************************************************************************************************************/ +.faust-ui-component.faust-ui-component-menu { + align-items: center; +} +.faust-ui-component.faust-ui-component-menu > select { + margin: 0px; + text-align: center; + border-width: 1px; + border-radius: 4px; + padding: 2px 4px; + width: calc(100% - 8px); +} +/*!********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Radio.scss ***! + \********************************************************************************************************************/ +.faust-ui-component.faust-ui-component-radio { + align-items: center; +} +.faust-ui-component.faust-ui-component-radio > .faust-ui-component-label { + flex: 0 0 auto; + margin-top: auto; +} +.faust-ui-component.faust-ui-component-radio > .faust-ui-component-radio-group { + flex: 0 1 auto; + margin-bottom: auto; + border-width: 1px; + border-radius: 4px; + padding: 2px 4px; + width: calc(100% - 8px); + overflow: auto; +} +.faust-ui-component.faust-ui-component-radio > .faust-ui-component-radio-group > div { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; +} +/*!******************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Led.scss ***! + \******************************************************************************************************************/ +.faust-ui-component.faust-ui-component-led { + align-items: center; +} +.faust-ui-component.faust-ui-component-led > .faust-ui-component-label { + flex: 0 0 auto; +} +.faust-ui-component.faust-ui-component-led > .faust-ui-component-led-canvasdiv { + position: relative; + display: block; + flex: 1 1 auto; + width: 100%; +} +.faust-ui-component.faust-ui-component-led > .faust-ui-component-led-canvasdiv > canvas { + position: absolute; + display: block; + height: 100%; + width: 100%; + touch-action: none; +} +/*!************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Numerical.scss ***! + \************************************************************************************************************************/ +.faust-ui-component.faust-ui-component-numerical { + align-items: center; +} +.faust-ui-component.faust-ui-component-numerical > input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: auto; + border-width: 0px; + border-radius: 4px; + width: calc(100% - 8px); + padding: 2px 4px; +} +/*!************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/VBargraph.scss ***! + \************************************************************************************************************************/ +.faust-ui-component.faust-ui-component-vbargraph { + align-items: center; +} +.faust-ui-component.faust-ui-component-vbargraph > .faust-ui-component-label { + flex: 0 0 auto; +} +.faust-ui-component.faust-ui-component-vbargraph > .faust-ui-component-vbargraph-flexdiv { + position: relative; + display: flex; + flex-direction: column; + flex: 1 1 auto; + width: 100%; + height: inherit; +} +.faust-ui-component.faust-ui-component-vbargraph > .faust-ui-component-vbargraph-flexdiv > .faust-ui-component-vbargraph-canvasdiv { + position: relative; + display: block; + flex: 1 1 auto; + width: 100%; +} +.faust-ui-component.faust-ui-component-vbargraph > .faust-ui-component-vbargraph-flexdiv > .faust-ui-component-vbargraph-canvasdiv > canvas { + position: absolute; + display: block; + height: 100%; + width: 100%; + touch-action: none; +} +.faust-ui-component.faust-ui-component-vbargraph > .faust-ui-component-vbargraph-flexdiv > input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: 5px auto auto auto; + border-width: 0px; + border-radius: 4px; + height: 5%; + width: calc(100% - 8px); + padding: 2px 4px; +} +/*!************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/HBargraph.scss ***! + \************************************************************************************************************************/ +.faust-ui-component.faust-ui-component-hbargraph > .faust-ui-component-label { + flex: 0 0 auto; +} +.faust-ui-component.faust-ui-component-hbargraph > .faust-ui-component-hbargraph-flexdiv { + position: relative; + display: flex; + flex-direction: row-reverse; + flex: 1 1 auto; + width: 100%; + height: auto; +} +.faust-ui-component.faust-ui-component-hbargraph > .faust-ui-component-hbargraph-flexdiv > .faust-ui-component-hbargraph-canvasdiv { + position: relative; + display: block; + flex: 1 1 auto; + height: 100%; + margin: auto; +} +.faust-ui-component.faust-ui-component-hbargraph > .faust-ui-component-hbargraph-flexdiv > .faust-ui-component-hbargraph-canvasdiv > canvas { + position: absolute; + display: block; + height: 100%; + width: 100%; + touch-action: none; +} +.faust-ui-component.faust-ui-component-hbargraph > .faust-ui-component-hbargraph-flexdiv > input { + position: relative; + display: block; + flex: 0 1 auto; + text-align: center; + background-color: rgba(255, 255, 255, 0.25); + margin: auto 5px auto auto; + border-width: 0px; + border-radius: 4px; + width: calc(20% - 13px); + padding: 2px 4px; +} +/*!********************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/components/Group.scss ***! + \********************************************************************************************************************/ +.faust-ui-group { + position: absolute; + display: block; + background-color: rgba(80, 80, 80, 0.75); + border-radius: 4px; + border: 1px rgba(255, 255, 255, 0.25) solid; +} +.faust-ui-group > .faust-ui-group-label { + position: relative; + margin: 4px; + width: calc(100% - 8px); + user-select: none; +} +.faust-ui-group > .faust-ui-group-label > canvas { + position: relative; + display: block; + max-width: 100%; + max-height: 100%; +} +.faust-ui-group .faust-ui-tgroup-tabs { + position: absolute; + display: inline-block; + white-space: nowrap; + left: 0px; +} +.faust-ui-group .faust-ui-tgroup-tabs .faust-ui-tgroup-tab { + position: relative; + display: inline-block; + border-radius: 5px; + cursor: pointer; + text-overflow: ellipsis; + white-space: nowrap; + user-select: none; + margin: 10px; + text-align: center; + background-color: rgba(255, 255, 255, 0.5); +} +.faust-ui-group .faust-ui-tgroup-tabs .faust-ui-tgroup-tab:hover { + background-color: rgb(255, 255, 255); +} +.faust-ui-group .faust-ui-tgroup-tabs .faust-ui-tgroup-tab.active { + background-color: rgb(40, 40, 40); + color: white; +} +/*!*********************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/index.scss ***! + \*********************************************************************************************************/ +.faust-ui-root { + margin: 0px auto; + flex: 1 0 auto; + position: relative !important; + background-color: transparent !important; + border: none !important; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; +} + +/*# sourceMappingURL=index.css.map*/ \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/faust-ui/index.css.map b/docs/gamelan/sinusoide2/faust-ui/index.css.map new file mode 100644 index 0000000..0142fee --- /dev/null +++ b/docs/gamelan/sinusoide2/faust-ui/index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"index.css","mappings":";;;AAAA;EACI;EACA;EACA;EACA;AACJ;AAAI;EACI;AAER;AAAI;EACI;EACA;EACA;EACA;AAER;AADQ;EACI;EACA;EACA;EACA;AAGZ;AAAI;EACI;AAER,C;;;;ACvBA;EACI;AACJ;AAAI;EACI;AAER;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;AAER;AADQ;EACI;EACA;EACA;EACA;AAGZ;AAFY;EACI;EACA;EACA;EACA;EACA;AAIhB;AADQ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAGZ;AAFY;EAEI;EACA;AAGhB,C;;;;AC3CI;EACI;AAAR;AAEI;EACI;EACA;EACA;EACA;EACA;EACA;AAAR;AACQ;EACI;EACA;EACA;EACA;EACA;AACZ;AAAY;EACI;EACA;EACA;EACA;EACA;AAEhB;AACQ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACZ;AAAY;EAEI;EACA;AAChB,C;;;;ACzCA;EACI;AACJ;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;AAER;AADQ;EAEI;AAEZ,C;;;;ACZI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAAR;AACQ;EACI;EACA;AACZ,C;;;;ACZI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAAR;AACQ;EACI;EACA;AACZ,C;;;;ACbI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAAR;AACQ;EACI;EACA;AACZ,C;;;;ACdA;EACI;AACJ;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;AAER;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAER;AADQ;EAEI;EACA;AAEZ,C;;;;AC3BA;EACI;AACJ;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;AAER,C;;;;ACVA;EACI;AACJ;AAAI;EACI;EACA;AAER;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;AAER;AADQ;EACI;EACA;EACA;AAGZ,C;;;;ACpBA;EACI;AACJ;AAAI;EACI;AAER;AAAI;EACI;EACA;EACA;EACA;AAER;AADQ;EACI;EACA;EACA;EACA;EACA;AAGZ,C;;;;AClBA;EACI;AACJ;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAER,C;;;;ACdA;EACI;AACJ;AAAI;EACI;AAER;AAAI;EACI;EACA;EACA;EACA;EACA;EACA;AAER;AADQ;EACI;EACA;EACA;EACA;AAGZ;AAFY;EACI;EACA;EACA;EACA;EACA;AAIhB;AADQ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAGZ,C;;;;ACtCI;EACI;AAAR;AAEI;EACI;EACA;EACA;EACA;EACA;EACA;AAAR;AACQ;EACI;EACA;EACA;EACA;EACA;AACZ;AAAY;EACI;EACA;EACA;EACA;EACA;AAEhB;AACQ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACZ,C;;;;ACnCA;EACI;EACA;EACA;EACA;EACA;AAAJ;AACI;EACI;EACA;EACA;EACA;AACR;AAAQ;EACI;EACA;EACA;EACA;AAEZ;AACI;EACI;EACA;EACA;EACA;AACR;AAAQ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAEZ;AADY;EACI;AAGhB;AADY;EACI;EACA;AAGhB,C;;;;AC3CA;EACI;EACA;EACA;EACA;EACA;EACA;AACJ,C","sources":["webpack://@shren/faust-ui/./src/components/Base.scss","webpack://@shren/faust-ui/./src/components/VSlider.scss","webpack://@shren/faust-ui/./src/components/HSlider.scss","webpack://@shren/faust-ui/./src/components/Nentry.scss","webpack://@shren/faust-ui/./src/components/Soundfile.scss","webpack://@shren/faust-ui/./src/components/Button.scss","webpack://@shren/faust-ui/./src/components/Checkbox.scss","webpack://@shren/faust-ui/./src/components/Knob.scss","webpack://@shren/faust-ui/./src/components/Menu.scss","webpack://@shren/faust-ui/./src/components/Radio.scss","webpack://@shren/faust-ui/./src/components/Led.scss","webpack://@shren/faust-ui/./src/components/Numerical.scss","webpack://@shren/faust-ui/./src/components/VBargraph.scss","webpack://@shren/faust-ui/./src/components/HBargraph.scss","webpack://@shren/faust-ui/./src/components/Group.scss","webpack://@shren/faust-ui/./src/index.scss"],"sourcesContent":[".faust-ui-component {\n display: flex;\n position: absolute;\n flex-direction: column;\n overflow: hidden;\n &:focus {\n outline: none;\n }\n & > .faust-ui-component-label {\n position: relative;\n margin-top: 4px;\n width: 100%;\n user-select: none;\n & > canvas {\n position: relative;\n display: block;\n max-width: 100%;\n max-height: 100%;\n }\n }\n & input {\n box-shadow: none;\n }\n}",".faust-ui-component.faust-ui-component-vslider {\n align-items: center;\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n }\n & > .faust-ui-component-vslider-flexdiv {\n position: relative;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n width: 100%;\n height: auto;\n & > .faust-ui-component-vslider-canvasdiv {\n position: relative;\n display: block;\n flex: 1 1 auto;\n width: 100%;\n & > canvas {\n position: absolute;\n display: block;\n height: 100%;\n width: 100%;\n touch-action: none;\n }\n }\n & input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: 5px auto auto auto;\n border-width: 0px;\n border-radius: 4px;\n height: 5%;\n max-width: calc(100% - 8px);\n padding: 2px 4px;\n -moz-appearance:textfield;\n &::-webkit-inner-spin-button, \n &::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n }\n }\n}",".faust-ui-component.faust-ui-component-hslider {\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n }\n & > .faust-ui-component-hslider-flexdiv {\n position: relative;\n display: flex;\n flex-direction: row-reverse;\n flex: 1 1 auto;\n width: 100%;\n height: auto;\n & > .faust-ui-component-hslider-canvasdiv {\n position: relative;\n display: block;\n flex: 1 1 auto;\n height: 100%;\n margin: auto;\n & > canvas {\n position: absolute;\n display: block;\n height: 100%;\n width: 100%;\n touch-action: none;\n }\n }\n & > input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: auto 5px auto auto;\n border-width: 0px;\n border-radius: 4px;\n width: calc(20% - 13px);\n padding: 2px 4px;\n -moz-appearance: textfield;\n &::-webkit-inner-spin-button, \n &::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n }\n }\n}\n",".faust-ui-component.faust-ui-component-nentry {\n align-items: center;\n & input {\n margin: 0px;\n text-align: center;\n border-width: 1px;\n border-radius: 4px;\n padding: 2px 4px;\n width: calc(100% - 8px);\n &::-webkit-inner-spin-button, \n &::-webkit-outer-spin-button {\n opacity: 1;\n }\n }\n}",".faust-ui-component.faust-ui-component-soundfile {\n & > div {\n display: flex;\n position: relative;\n cursor: pointer;\n border-width: 1px;\n text-align: center;\n border-radius: 4px;\n flex: 1 0 auto;\n border-style: solid;\n & > span {\n user-select: none;\n margin: auto;\n }\n }\n}",".faust-ui-component.faust-ui-component-button {\n & > div {\n display: flex;\n position: relative;\n cursor: pointer;\n border-width: 1px;\n text-align: center;\n border-radius: 4px;\n flex: 1 0 auto;\n border-style: solid;\n touch-action: none;\n & > span {\n user-select: none;\n margin: auto;\n }\n }\n}",".faust-ui-component.faust-ui-component-checkbox {\n & > div {\n display: flex;\n position: relative;\n cursor: pointer;\n border-width: 1px;\n text-align: center;\n border-radius: 1px;\n flex: 1 0 auto;\n border-style: solid;\n touch-action: none;\n & > span {\n margin: auto;\n user-select: none;\n }\n }\n}",".faust-ui-component.faust-ui-component-knob {\n align-items: center;\n & > canvas {\n position: relative;\n display: block;\n flex: 1 1 auto;\n min-height: 50%;\n width: 100%;\n touch-action: none;\n }\n & > input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: 0px;\n border-width: 0px;\n border-radius: 4px;\n max-width: calc(100% - 8px);\n padding: 2px 4px;\n -moz-appearance: textfield;\n &::-webkit-inner-spin-button, \n &::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n }\n}",".faust-ui-component.faust-ui-component-menu {\n align-items: center;\n & > select {\n margin: 0px;\n text-align: center;\n border-width: 1px;\n border-radius: 4px;\n padding: 2px 4px;\n width: calc(100% - 8px);\n }\n}",".faust-ui-component.faust-ui-component-radio {\n align-items: center;\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n margin-top: auto;\n }\n & > .faust-ui-component-radio-group {\n flex: 0 1 auto;\n margin-bottom: auto;\n border-width: 1px;\n border-radius: 4px;\n padding: 2px 4px;\n width: calc(100% - 8px);\n overflow: auto;\n & > div {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n }\n }\n}",".faust-ui-component.faust-ui-component-led {\n align-items: center;\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n }\n & > .faust-ui-component-led-canvasdiv {\n position: relative;\n display: block;\n flex: 1 1 auto;\n width: 100%;\n & > canvas {\n position: absolute;\n display: block;\n height: 100%;\n width: 100%;\n touch-action: none;\n }\n }\n}\n",".faust-ui-component.faust-ui-component-numerical {\n align-items: center;\n & > input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: auto;\n border-width: 0px;\n border-radius: 4px;\n width: calc(100% - 8px);\n padding: 2px 4px;\n }\n}",".faust-ui-component.faust-ui-component-vbargraph {\n align-items: center;\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n }\n & > .faust-ui-component-vbargraph-flexdiv {\n position: relative;\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n width: 100%;\n height: inherit;\n & > .faust-ui-component-vbargraph-canvasdiv {\n position: relative;\n display: block;\n flex: 1 1 auto;\n width: 100%;\n & > canvas {\n position: absolute;\n display: block;\n height: 100%;\n width: 100%;\n touch-action: none;\n }\n }\n & > input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: 5px auto auto auto;\n border-width: 0px;\n border-radius: 4px;\n height: 5%;\n width: calc(100% - 8px);\n padding: 2px 4px;\n }\n }\n}\n",".faust-ui-component.faust-ui-component-hbargraph {\n & > .faust-ui-component-label {\n flex: 0 0 auto;\n }\n & > .faust-ui-component-hbargraph-flexdiv {\n position: relative;\n display: flex;\n flex-direction: row-reverse;\n flex: 1 1 auto;\n width: 100%;\n height: auto;\n & > .faust-ui-component-hbargraph-canvasdiv {\n position: relative;\n display: block;\n flex: 1 1 auto;\n height: 100%;\n margin: auto;\n & > canvas {\n position: absolute;\n display: block;\n height: 100%;\n width: 100%;\n touch-action: none;\n }\n }\n & > input {\n position: relative;\n display: block;\n flex: 0 1 auto;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.25);\n margin: auto 5px auto auto;\n border-width: 0px;\n border-radius: 4px;\n width: calc(20% - 13px);\n padding: 2px 4px;\n }\n }\n}","\n.faust-ui-group {\n position: absolute;\n display: block;\n background-color: rgba(80, 80, 80, 0.75);\n border-radius: 4px;\n border: 1px rgba(255, 255, 255, 0.25) solid;\n & > .faust-ui-group-label {\n position: relative;\n margin: 4px;\n width: calc(100% - 8px);\n user-select: none;\n & > canvas {\n position: relative;\n display: block;\n max-width: 100%;\n max-height: 100%;\n }\n }\n & .faust-ui-tgroup-tabs {\n position: absolute;\n display: inline-block;\n white-space: nowrap;\n left: 0px;\n & .faust-ui-tgroup-tab {\n position: relative;\n display: inline-block;\n border-radius: 5px;\n cursor: pointer;\n text-overflow: ellipsis;\n white-space: nowrap;\n user-select: none;\n margin: 10px;\n text-align: center;\n background-color: rgba(255, 255, 255, 0.5);\n &:hover {\n background-color: rgba(255, 255, 255, 1);\n }\n &.active {\n background-color: rgba(40, 40, 40, 1);\n color: white;\n }\n }\n }\n}",".faust-ui-root {\n margin: 0px auto;\n flex: 1 0 auto;\n position: relative !important;\n background-color: transparent !important;\n border: none !important;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n}"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/faust-ui/index.d.ts b/docs/gamelan/sinusoide2/faust-ui/index.d.ts new file mode 100644 index 0000000..8c3c600 --- /dev/null +++ b/docs/gamelan/sinusoide2/faust-ui/index.d.ts @@ -0,0 +1 @@ +export * from "@shren/faust-ui"; diff --git a/docs/gamelan/sinusoide2/faust-ui/index.js b/docs/gamelan/sinusoide2/faust-ui/index.js new file mode 100644 index 0000000..9e63562 --- /dev/null +++ b/docs/gamelan/sinusoide2/faust-ui/index.js @@ -0,0 +1,3844 @@ +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/@shren/typed-event-emitter/dist/index.js": +/*!***************************************************************!*\ + !*** ./node_modules/@shren/typed-event-emitter/dist/index.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.TypedEventEmitter = exports.$AnyEventType = void 0; +exports.$AnyEventType = Symbol("__TypedEventListener_AnyEventType"); +class TypedEventEmitter { + constructor() { + this._listeners = { [exports.$AnyEventType]: [] }; + } + get listeners() { + return this._listeners; + } + getListeners(eventName) { + if (!(eventName in this._listeners)) + this._listeners[eventName] = []; + return this._listeners[eventName]; + } + on(eventName, listener) { + if (this.getListeners(eventName).indexOf(listener) === -1) + this.getListeners(eventName).push(listener); + } + once(eventName, listener) { + const listenerWithOff = (arg, emitter) => { + const returnValue = listener(arg, emitter); + this.off(eventName, listenerWithOff); + return returnValue; + }; + this.on(eventName, listenerWithOff); + } + onAny(listener) { + this._listeners[exports.$AnyEventType].push(listener); + } + off(eventName, listener) { + const i = this.getListeners(eventName).indexOf(listener); + if (i !== -1) + this.getListeners(eventName).splice(i, 1); + } + offAny(listener) { + const i = this._listeners[exports.$AnyEventType].indexOf(listener); + if (i !== -1) + this._listeners[exports.$AnyEventType].splice(i, 1); + } + async emit(eventName, eventData, options) { + var _a; + let listeners = this.getListeners(eventName); + let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType]; + if (!listeners.length && !anyListeners.length) + return []; + if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) { + const { exclude } = options; + listeners = listeners.filter(l => exclude.indexOf(l) === -1); + anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1); + } + return Promise.all([...listeners.map(f => f(eventData, this)), ...anyListeners.map(f => f(eventName, eventData, this))]); + } + async emitSerial(eventName, eventData, options) { + var _a; + let listeners = this.getListeners(eventName); + let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType]; + if (!listeners.length && !anyListeners.length) + return []; + if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) { + const { exclude } = options; + listeners = listeners.filter(l => exclude.indexOf(l) === -1); + anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1); + } + const returnValues = []; + for (let i = 0; i < listeners.length; i++) { + const listener = listeners[i]; + returnValues[i] = await listener(eventData, this); + } + for (let i = 0; i < anyListeners.length; i++) { + const listener = anyListeners[i]; + returnValues[listeners.length + i] = await listener(eventName, eventData, this); + } + return returnValues; + } + emitSync(eventName, eventData, options) { + var _a; + let listeners = this.getListeners(eventName); + let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType]; + if (!listeners.length && !anyListeners.length) + return []; + if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) { + const { exclude } = options; + listeners = listeners.filter(l => exclude.indexOf(l) === -1); + anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1); + } + return [...listeners.map(f => f(eventData, this)), ...anyListeners.map(f => f(eventName, eventData, this))]; + } + offAll(eventName) { + if (eventName) { + this._listeners[eventName] = []; + } + else { + this._listeners = { [exports.$AnyEventType]: [] }; + } + } + listenerCount(eventName) { + const anyListenerCount = this._listeners[exports.$AnyEventType].length; + if (!(eventName in this._listeners)) + return anyListenerCount; + return this._listeners[eventName].length + anyListenerCount; + } +} +exports.TypedEventEmitter = TypedEventEmitter; +exports["default"] = TypedEventEmitter; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ "./src/FaustUI.ts": +/*!************************!*\ + !*** ./src/FaustUI.ts ***! + \************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ FaustUI) +/* harmony export */ }); +/* harmony import */ var _layout_Layout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./layout/Layout */ "./src/layout/Layout.ts"); +/* harmony import */ var _components_Group__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/Group */ "./src/components/Group.ts"); +/* harmony import */ var _index_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./index.scss */ "./src/index.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + + +class FaustUI { + /** + * Calculate incoming UI's layout, bind window events + */ + constructor(options) { + this.componentMap = {}; + /** + * Can be overriden, called by components when its value is changed by user. + */ + this.paramChangeByUI = (path, value) => { + if (!this.hostWindow) + return; + this.hostWindow.postMessage({ path, value, type: "param" }, "*"); + }; + const { root, ui: uiIn, listenWindowResize, listenWindowMessage } = options; + this.DOMroot = root; + this.ui = uiIn || []; + if (typeof listenWindowResize === "undefined" || listenWindowResize === true) { + window.addEventListener("resize", () => { + this.resize(); + }); + } + if (typeof listenWindowMessage === "undefined" || listenWindowMessage === true) { + window.addEventListener("message", (e) => { + const { data, source } = e; + this.hostWindow = source; + const { type } = data; + if (!type) + return; + if (type === "ui") { + this.ui = data.ui; + } else if (type === "param") { + const { path, value } = data; + this.paramChangeByDSP(path, value); + } + }); + } + } + /** + * Render the UI to DOM root + */ + mount() { + this.componentMap = {}; + this.DOMroot.innerHTML = ""; + const props = { + label: "", + type: "vgroup", + items: this.ui, + style: { + grid: this.grid, + width: this.layout.width, + height: this.layout.height, + left: this.layout.offsetLeft, + top: this.layout.offsetTop + }, + isRoot: true, + emitter: this + }; + this.faustUIRoot = new _components_Group__WEBPACK_IMPORTED_MODULE_1__["default"](props); + this.faustUIRoot.componentWillMount(); + this.faustUIRoot.mount(); + this.DOMroot.appendChild(this.faustUIRoot.container); + this.faustUIRoot.componentDidMount(); + } + /** + * This method should be called by components to register itself to map. + */ + register(path, item) { + if (this.componentMap[path]) + this.componentMap[path].push(item); + else + this.componentMap[path] = [item]; + } + /** + * Notify the component to change its value. + */ + paramChangeByDSP(path, value) { + if (this.componentMap[path]) + this.componentMap[path].forEach((item) => item.setState({ value })); + } + /** + * Calculate UI layout in grid then calculate grid size. + */ + calc() { + const { items, layout } = _layout_Layout__WEBPACK_IMPORTED_MODULE_0__["default"].calc(this.ui); + this._ui = items; + this._layout = layout; + this.calcGrid(); + } + /** + * Calculate grid size by DOM root size and layout size in grids. + */ + calcGrid() { + const { width, height } = this.DOMroot.getBoundingClientRect(); + const grid = Math.max(40, Math.min(width / this._layout.width, height / this._layout.height)); + this.grid = grid; + return grid; + } + /** + * Force recalculate grid size and resize UI + */ + resize() { + if (!this.faustUIRoot) + return; + this.calcGrid(); + this.faustUIRoot.setState({ style: { grid: this.grid } }); + } + /** Filter out items with `hidden` metadata and `soundfile` items */ + filter(ui) { + const callback = (items, item) => { + var _a; + if (item.type === "soundfile") + return items; + if (item.type === "hgroup" || item.type === "vgroup" || item.type === "tgroup") { + items.push(__spreadProps(__spreadValues({}, item), { items: item.items.reduce(callback, []) })); + return items; + } + if ((_a = item.meta) == null ? void 0 : _a.find((m) => m.hidden && m.hidden === "1")) + return items; + items.push(item); + return items; + }; + return ui.reduce(callback, []); + } + get ui() { + return this._ui; + } + set ui(uiIn) { + this._ui = this.filter(uiIn); + this.calc(); + this.mount(); + } + get layout() { + return this._layout; + } + get minWidth() { + return this._layout.width * 40 + 1; + } + get minHeight() { + return this._layout.height * 40 + 1; + } +} + + +/***/ }), + +/***/ "./src/components/AbstractComponent.ts": +/*!*********************************************!*\ + !*** ./src/components/AbstractComponent.ts ***! + \*********************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractComponent) +/* harmony export */ }); +/* harmony import */ var _shren_typed_event_emitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @shren/typed-event-emitter */ "./node_modules/@shren/typed-event-emitter/dist/index.js"); +var __defProp = Object.defineProperty; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; + +class AbstractComponent extends _shren_typed_event_emitter__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Initiate default state with incoming state. + */ + constructor(props) { + super(); + /** + * Frame count in order to reduce frame rate + */ + this.$frame = 0; + /** + * Frame reducing factor, 1 = render at every browser rendering tick, 2 will skip one every two ticks. + */ + this.frameReduce = 1; + /** + * `requestAnimationFrame` callback + */ + this.raf = () => { + this.$frame++; + if (this.$frame % this.frameReduce !== 0) { + this.$raf = window.requestAnimationFrame(this.raf); + return; + } + this.$raf = void 0; + this.tasks.forEach((f) => f()); + this.tasks = []; + }; + /** + * tasks to execute in next redering tick + */ + this.tasks = []; + this.state = __spreadValues(__spreadValues({}, this.defaultProps), props); + } + get defaultProps() { + return this.constructor.defaultProps; + } + /** + * set internal state and fire events for UI parts subscribed + */ + setState(newState) { + let shouldUpdate = false; + for (const stateKey in newState) { + const stateValue = newState[stateKey]; + if (stateKey in this.state && this.state[stateKey] !== stateValue) { + this.state[stateKey] = stateValue; + shouldUpdate = true; + } else + return; + if (shouldUpdate) + this.emit(stateKey, this.state[stateKey]); + } + } + /** + * Use this method to request a new rendering + * schedule what you need to do in next render tick in `raf` callback + */ + schedule(func) { + if (this.tasks.indexOf(func) === -1) + this.tasks.push(func); + if (this.$raf) + return; + this.$raf = window.requestAnimationFrame(this.raf); + } +} +/** + * The default state of the component. + */ +AbstractComponent.defaultProps = {}; + + +/***/ }), + +/***/ "./src/components/AbstractItem.ts": +/*!****************************************!*\ + !*** ./src/components/AbstractItem.ts ***! + \****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractItem) +/* harmony export */ }); +/* harmony import */ var _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractComponent */ "./src/components/AbstractComponent.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/components/utils.ts"); +/* harmony import */ var _Base_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Base.scss */ "./src/components/Base.scss"); +var __defProp = Object.defineProperty; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; + + + +const _AbstractItem = class extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] { + /** + * Initiate default state with incoming state. + */ + constructor(props) { + super(props); + this.frameReduce = 3; + /** + * Default DOM event listeners, unify mousedown and touchstart events + * For mouse or touch events, please use `handlePointerDown` `handlePointerUp` `handlePointerDrag` callbacks + */ + this.handleKeyDown = (e) => { + }; + this.handleKeyUp = (e) => { + }; + this.handleTouchStart = (e) => { + e.preventDefault(); + const rect = e.currentTarget.getBoundingClientRect(); + let prevX = e.touches[0].clientX; + let prevY = e.touches[0].clientY; + const fromX = prevX - rect.left; + const fromY = prevY - rect.top; + const prevValue = this.state.value; + this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e }); + const handleTouchMove = (e2) => { + e2.preventDefault(); + const clientX = e2.changedTouches[0].clientX; + const clientY = e2.changedTouches[0].clientY; + const movementX = clientX - prevX; + const movementY = clientY - prevY; + prevX = clientX; + prevY = clientY; + const x = clientX - rect.left; + const y = clientY - rect.top; + this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX, movementY, originalEvent: e2 }); + }; + const handleTouchEnd = (e2) => { + e2.preventDefault(); + const x = e2.changedTouches[0].clientX - rect.left; + const y = e2.changedTouches[0].clientY - rect.top; + this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e2 }); + document.removeEventListener("touchmove", handleTouchMove); + document.removeEventListener("touchend", handleTouchEnd); + }; + document.addEventListener("touchmove", handleTouchMove, { passive: false }); + document.addEventListener("touchend", handleTouchEnd, { passive: false }); + }; + this.handleWheel = (e) => { + }; + this.handleClick = (e) => { + }; + this.handleMouseDown = (e) => { + e.preventDefault(); + e.currentTarget.focus(); + const rect = e.currentTarget.getBoundingClientRect(); + const fromX = e.clientX - rect.left; + const fromY = e.clientY - rect.top; + const prevValue = this.state.value; + this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e }); + const handleMouseMove = (e2) => { + e2.preventDefault(); + const x = e2.clientX - rect.left; + const y = e2.clientY - rect.top; + this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 }); + }; + const handleMouseUp = (e2) => { + e2.preventDefault(); + const x = e2.clientX - rect.left; + const y = e2.clientY - rect.top; + this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e2 }); + document.removeEventListener("mousemove", handleMouseMove); + document.removeEventListener("mouseup", handleMouseUp); + }; + document.addEventListener("mousemove", handleMouseMove); + document.addEventListener("mouseup", handleMouseUp); + }; + this.handleMouseOver = (e) => { + }; + this.handleMouseOut = (e) => { + }; + this.handleContextMenu = (e) => { + }; + this.handlePointerDown = (e) => { + e.preventDefault(); + e.currentTarget.focus(); + const { pointerId } = e; + const rect = e.currentTarget.getBoundingClientRect(); + const fromX = e.clientX - rect.left; + const fromY = e.clientY - rect.top; + const prevValue = this.state.value; + this.handleMouseOrTouchDown({ pointerId, x: fromX, y: fromY, originalEvent: e }); + const handlePointerMove = (e2) => { + if (e2.pointerId !== pointerId) + return; + e2.preventDefault(); + const x = e2.clientX - rect.left; + const y = e2.clientY - rect.top; + this.handleMouseOrTouchMove({ pointerId, prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 }); + }; + const handlePointerUp = (e2) => { + if (e2.pointerId !== pointerId) + return; + e2.preventDefault(); + const x = e2.clientX - rect.left; + const y = e2.clientY - rect.top; + this.handleMouseOrTouchUp({ pointerId, x, y, originalEvent: e2 }); + document.removeEventListener("pointermove", handlePointerMove); + document.removeEventListener("pointerup", handlePointerUp); + }; + document.addEventListener("pointermove", handlePointerMove); + document.addEventListener("pointerup", handlePointerUp); + }; + this.handleMouseOrTouchDown = (e) => { + }; + this.handleMouseOrTouchMove = (e) => { + }; + this.handleMouseOrTouchUp = (e) => { + }; + this.handleFocusIn = (e) => this.setState({ focus: true }); + this.handleFocusOut = (e) => this.setState({ focus: false }); + this.state.style = __spreadValues(__spreadValues({}, this.defaultProps.style), props.style); + if (this.state.emitter) + this.state.emitter.register(this.state.address, this); + } + /** + * Get a nearest valid number + */ + toValidNumber(value) { + const { min, max, step } = this.state; + if (typeof min !== "number" || typeof max !== "number") + return value; + const v = Math.min(max, Math.max(min, value)); + if (!step) + return v; + return min + Math.floor((v - min) / step) * step; + } + /** + * Use this method if you want the emitter to send value to DSP + */ + setValue(valueIn) { + const value = this.toValidNumber(valueIn); + const changed = this.setState({ value }); + if (changed) + this.change(value); + return changed; + } + /** + * Send value to DSP + */ + change(valueIn) { + if (this.state.emitter) + this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === "number" ? valueIn : this.state.value); + } + /** + * set internal state and fire events for UI parts subscribed + * This will not send anything to DSP + * @returns is state updated + */ + setState(newState) { + let shouldUpdate = false; + for (const key in newState) { + const stateKey = key; + const stateValue = newState[stateKey]; + if (stateKey === "style") { + for (const styleKey in newState.style) { + if (styleKey in this.state.style) { + this.state.style[styleKey] = newState.style[styleKey]; + shouldUpdate = true; + } + } + } else if (stateKey in this.state && this.state[stateKey] !== stateValue) { + this.state[stateKey] = stateValue; + shouldUpdate = true; + } else + return false; + if (shouldUpdate) + this.emit(stateKey, this.state[stateKey]); + } + return shouldUpdate; + } + /** + * Create container with class name + * override it with `super.componentWillMount();` + */ + componentWillMount() { + this.container = document.createElement("div"); + this.container.className = ["faust-ui-component", "faust-ui-component-" + this.className].join(" "); + this.container.tabIndex = 1; + this.container.id = this.state.address; + if (this.state.tooltip) + this.container.title = this.state.tooltip; + this.label = document.createElement("div"); + this.label.className = "faust-ui-component-label"; + this.labelCanvas = document.createElement("canvas"); + this.labelCtx = this.labelCanvas.getContext("2d"); + return this; + } + /** + * Here append all child DOM to container + */ + mount() { + this.label.appendChild(this.labelCanvas); + return this; + } + paintLabel(align) { + const label = this.state.label; + const color = this.state.style.labelcolor; + const ctx = this.labelCtx; + const canvas = this.labelCanvas; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.label.getBoundingClientRect(); + if (!width || !height) + return this; + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + ctx.clearRect(0, 0, width, height); + ctx.fillStyle = color; + ctx.textBaseline = "middle"; + ctx.textAlign = align || "center"; + ctx.font = `bold ${height * 0.9}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`; + ctx.fillText(label, align === "left" ? 0 : align === "right" ? width : width / 2, height / 2, width); + return this; + } + /** + * will call this method when mounted + */ + componentDidMount() { + const handleResize = () => { + const { grid, left, top, width, height } = this.state.style; + this.container.style.width = `${width * grid}px`; + this.container.style.height = `${height * grid}px`; + this.container.style.left = `${left * grid}px`; + this.container.style.top = `${top * grid}px`; + this.label.style.height = `${grid * 0.25}px`; + this.paintLabel(); + }; + this.on("style", () => this.schedule(handleResize)); + handleResize(); + return this; + } + /** + * Count steps in range min-max with step + */ + get stepsCount() { + const { type, max, min, step, enums } = this.state; + const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step; + if (step) { + if (type === "enum") + return enums.length; + if (type === "int") + return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps); + return Math.floor((max - min) / step); + } + return maxSteps; + } + /** + * Normalized value between 0 - 1. + */ + get distance() { + const { type, max, min, value, enums, scale } = this.state; + return _AbstractItem.getDistance({ type, max, min, value, enums, scale }); + } + static getDistance(state) { + const { type, max, min, value, enums, scale } = state; + if (type === "enum") + return value / (enums.length - 1); + const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(value, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(value, min, max) : value; + return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max); + } + /** + * Mousemove pixels for each step + */ + get stepRange() { + const full = 100; + const stepsCount = this.stepsCount; + return full / stepsCount; + } +}; +let AbstractItem = _AbstractItem; +/** + * The default state of the component. + */ +AbstractItem.defaultProps = { + value: 0, + active: true, + focus: false, + label: "", + address: "", + min: 0, + max: 1, + enums: {}, + type: "float", + unit: "", + scale: "linear", + step: 0.01, + style: { width: 45, height: 15, left: 0, top: 0, labelcolor: "rgba(226, 222, 255, 0.5)" } +}; + + + +/***/ }), + +/***/ "./src/components/Button.ts": +/*!**********************************!*\ + !*** ./src/components/Button.ts ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Button) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Button_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Button.scss */ "./src/components/Button.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Button extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "button"; + this.setStyle = () => { + const { value, style } = this.state; + const { height, grid, fontsize, fontname, fontface, textcolor, textoncolor, bgoncolor, bgcolor, bordercolor, borderoncolor } = style; + this.btn.style.backgroundColor = value ? bgoncolor : bgcolor; + this.btn.style.borderColor = value ? borderoncolor : bordercolor; + this.btn.style.color = value ? textoncolor : textcolor; + this.btn.style.fontSize = `${fontsize || height * grid / 4}px`; + this.btn.style.fontFamily = `${fontname}, sans-serif`; + this.btn.style.fontStyle = fontface; + }; + this.handleContextMenu = (e) => { + e.preventDefault(); + }; + this.handleMouseOrTouchDown = () => { + this.setValue(1); + }; + this.handleMouseOrTouchUp = () => { + this.setValue(0); + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "normal", + bgcolor: "rgba(40, 40, 40, 1)", + bgoncolor: "rgba(18, 18, 18, 1)", + bordercolor: "rgba(80, 80, 80, 1)", + borderoncolor: "rgba(255, 165, 0, 1)", + textcolor: "rgba(226, 222, 255, 0.5)", + textoncolor: "rgba(255, 165, 0, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.btn = document.createElement("div"); + this.span = document.createElement("span"); + this.span.innerText = this.state.label; + this.setStyle(); + return this; + } + mount() { + this.btn.appendChild(this.span); + this.container.appendChild(this.btn); + return super.mount(); + } + componentDidMount() { + super.componentDidMount(); + this.btn.addEventListener("pointerdown", this.handlePointerDown); + this.btn.addEventListener("contextmenu", this.handleContextMenu); + this.on("style", () => this.schedule(this.setStyle)); + const labelChange = () => this.span.innerText = this.state.label; + this.on("label", () => this.schedule(labelChange)); + this.on("value", () => this.schedule(this.setStyle)); + return this; + } +} + + +/***/ }), + +/***/ "./src/components/Checkbox.ts": +/*!************************************!*\ + !*** ./src/components/Checkbox.ts ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Checkbox) +/* harmony export */ }); +/* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Button */ "./src/components/Button.ts"); +/* harmony import */ var _Checkbox_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Checkbox.scss */ "./src/components/Checkbox.scss"); + + +class Checkbox extends _Button__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "checkbox"; + this.handleMouseOrTouchDown = () => { + this.setValue(1 - this.state.value); + }; + this.handleMouseOrTouchUp = () => { + }; + } +} + + +/***/ }), + +/***/ "./src/components/Group.ts": +/*!*********************************!*\ + !*** ./src/components/Group.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Group) +/* harmony export */ }); +/* harmony import */ var _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractComponent */ "./src/components/AbstractComponent.ts"); +/* harmony import */ var _HSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HSlider */ "./src/components/HSlider.ts"); +/* harmony import */ var _VSlider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./VSlider */ "./src/components/VSlider.ts"); +/* harmony import */ var _Nentry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Nentry */ "./src/components/Nentry.ts"); +/* harmony import */ var _Soundfile__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Soundfile */ "./src/components/Soundfile.ts"); +/* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Button */ "./src/components/Button.ts"); +/* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Checkbox */ "./src/components/Checkbox.ts"); +/* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Knob */ "./src/components/Knob.ts"); +/* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Menu */ "./src/components/Menu.ts"); +/* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Radio */ "./src/components/Radio.ts"); +/* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Led */ "./src/components/Led.ts"); +/* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Numerical */ "./src/components/Numerical.ts"); +/* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./HBargraph */ "./src/components/HBargraph.ts"); +/* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./VBargraph */ "./src/components/VBargraph.ts"); +/* harmony import */ var _layout_Layout__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../layout/Layout */ "./src/layout/Layout.ts"); +/* harmony import */ var _Group_scss__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Group.scss */ "./src/components/Group.scss"); + + + + + + + + + + + + + + + + +class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.updateUI = () => { + this.children = []; + const { style, type, items, emitter, isRoot } = this.state; + const { grid, left, top, width, height } = style; + if (!this.state.isRoot) + this.label.style.height = `${grid * 0.3}px`; + this.container.style.left = `${left * grid}px`; + this.container.style.top = `${top * grid}px`; + this.container.style.width = `${width * grid}px`; + this.container.style.height = `${height * grid}px`; + this.container.className = ["faust-ui-group", `faust-ui-${type}`, `${isRoot ? "faust-ui-root" : ""}`].join(" "); + items.forEach((item) => { + if (item.type.endsWith("group")) { + const component = Group.getComponent(item, emitter, grid); + if (component) + this.children.push(component); + } else { + const ioItem = item; + const itemComponent = Group.getComponent(ioItem, this.state.emitter, grid); + if (itemComponent) + this.children.push(itemComponent); + } + }); + if (type === "tgroup") { + this.tabs.innerHTML = ""; + this.tabs.style.height = `${grid}px`; + this.tabs.style.top = `${0.25 * grid}px`; + this.state.items.forEach((item, i) => { + const label = item.label; + const tab = document.createElement("span"); + tab.innerText = label; + tab.className = "faust-ui-tgroup-tab"; + tab.style.fontSize = `${0.25 * grid}px`; + tab.style.width = `${2 * grid - 20}px`; + tab.style.height = `${grid - 20}px`; + tab.style.lineHeight = `${grid - 20}px`; + tab.addEventListener("click", () => { + const groups = []; + for (let j = 0; j < this.container.children.length; j++) { + const element = this.container.children[j]; + if (j > 1) + groups.push(element); + } + for (let j = 0; j < groups.length; j++) { + const element = groups[j]; + element.style.visibility = i === j ? "visible" : "hidden"; + } + for (let j = 0; j < this.tabs.children.length; j++) { + const e = this.tabs.children[j]; + if (i !== j) { + if (e.classList.contains("active")) + e.classList.remove("active"); + } else + e.classList.add("active"); + } + }); + this.tabs.appendChild(tab); + }); + } + }; + } + static parseMeta(metaIn) { + const metaObject = {}; + if (!metaIn) + return { metaObject }; + metaIn.forEach((m) => Object.assign(metaObject, m)); + if (metaObject.style) { + const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?))\}/; + const matched = metaObject.style.match(enumsRegex); + if (matched) { + const itemsRegex = /(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+?))/g; + const enums = {}; + let item; + while (item = itemsRegex.exec(matched[0])) { + enums[item[1]] = +item[2]; + } + return { metaObject, enums }; + } + } + return { metaObject }; + } + static getComponent(item, emitter, grid) { + const type = _layout_Layout__WEBPACK_IMPORTED_MODULE_14__["default"].predictType(item); + if (type.endsWith("group")) { + const { label: label2, items, type: type2, layout: layout2 } = item; + const props2 = { + label: label2, + type: type2, + items, + style: { + grid, + width: layout2.width, + height: layout2.height, + left: layout2.offsetLeft, + top: layout2.offsetTop, + labelcolor: "rgba(255, 255, 255, 0.7)" + }, + emitter + }; + return new Group(props2); + } + const ioItem = item; + const { metaObject, enums } = this.parseMeta(ioItem.meta); + const { tooltip, unit, scale } = metaObject; + const { label, min, max, address, layout } = ioItem; + const props = { + label, + address, + tooltip, + unit, + scale: scale || "linear", + emitter, + enums, + style: { + grid, + width: layout.width, + height: layout.height, + left: layout.offsetLeft, + top: layout.offsetTop + }, + type: "float", + min: isFinite(min) ? min : 0, + max: isFinite(max) ? max : 1, + step: "step" in item ? +item.step : 1, + value: "init" in item ? +item.init || 0 : 0 + }; + if (type === "button") + return new _Button__WEBPACK_IMPORTED_MODULE_5__["default"](props); + if (type === "checkbox") + return new _Checkbox__WEBPACK_IMPORTED_MODULE_6__["default"](props); + if (type === "nentry") + return new _Nentry__WEBPACK_IMPORTED_MODULE_3__["default"](props); + if (type === "soundfile") + return new _Soundfile__WEBPACK_IMPORTED_MODULE_4__["default"](props); + if (type === "knob") + return new _Knob__WEBPACK_IMPORTED_MODULE_7__["default"](props); + if (type === "menu") + return new _Menu__WEBPACK_IMPORTED_MODULE_8__["default"](props); + if (type === "radio") + return new _Radio__WEBPACK_IMPORTED_MODULE_9__["default"](props); + if (type === "hslider") + return new _HSlider__WEBPACK_IMPORTED_MODULE_1__["default"](props); + if (type === "vslider") + return new _VSlider__WEBPACK_IMPORTED_MODULE_2__["default"](props); + if (type === "hbargraph") + return new _HBargraph__WEBPACK_IMPORTED_MODULE_12__["default"](props); + if (type === "vbargraph") + return new _VBargraph__WEBPACK_IMPORTED_MODULE_13__["default"](props); + if (type === "numerical") + return new _Numerical__WEBPACK_IMPORTED_MODULE_11__["default"](props); + if (type === "led") + return new _Led__WEBPACK_IMPORTED_MODULE_10__["default"](props); + return null; + } + setState(newState) { + let shouldUpdate = false; + for (const key in newState) { + const stateKey = key; + const stateValue = newState[stateKey]; + if (stateKey === "style") { + for (const key2 in newState.style) { + const styleKey = key2; + if (styleKey in this.state.style) { + this.state.style[styleKey] = newState.style[styleKey]; + shouldUpdate = true; + } + } + } else if (stateKey in this.state && this.state[stateKey] !== stateValue) { + this.state[stateKey] = stateValue; + shouldUpdate = true; + } else + return; + if (shouldUpdate) + this.emit(stateKey, this.state[stateKey]); + } + } + componentWillMount() { + this.container = document.createElement("div"); + this.tabs = document.createElement("div"); + this.tabs.className = "faust-ui-tgroup-tabs"; + if (!this.state.isRoot) { + this.label = document.createElement("div"); + this.label.className = "faust-ui-group-label"; + this.labelCanvas = document.createElement("canvas"); + this.labelCtx = this.labelCanvas.getContext("2d"); + } + this.updateUI(); + this.children.forEach((item) => item.componentWillMount()); + return this; + } + paintLabel() { + if (this.state.isRoot) + return this; + const label = this.state.label; + const color = this.state.style.labelcolor; + const ctx = this.labelCtx; + const canvas = this.labelCanvas; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.label.getBoundingClientRect(); + if (!width || !height) + return this; + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + ctx.clearRect(0, 0, width, height); + ctx.fillStyle = color; + ctx.textBaseline = "middle"; + ctx.textAlign = "left"; + ctx.font = `bold ${height * 0.9}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`; + ctx.fillText(label, 0, height / 2, width); + return this; + } + mount() { + if (!this.state.isRoot) { + this.label.appendChild(this.labelCanvas); + this.container.appendChild(this.label); + } + if (this.tabs.children.length) + this.container.appendChild(this.tabs); + this.children.forEach((item) => { + item.mount(); + this.container.appendChild(item.container); + }); + return this; + } + componentDidMount() { + var _a; + const handleResize = () => { + const { grid, left, top, width, height } = this.state.style; + if (!this.state.isRoot) + this.label.style.height = `${grid * 0.3}px`; + this.container.style.width = `${width * grid}px`; + this.container.style.height = `${height * grid}px`; + this.container.style.left = `${left * grid}px`; + this.container.style.top = `${top * grid}px`; + if (this.state.type === "tgroup") { + this.tabs.style.height = `${grid}px`; + this.tabs.style.top = `${0.25 * grid}px`; + for (let i = 0; i < this.tabs.children.length; i++) { + const tab = this.tabs.children[i]; + tab.style.fontSize = `${0.25 * grid}px`; + tab.style.width = `${2 * grid - 20}px`; + tab.style.height = `${grid - 20}px`; + tab.style.lineHeight = `${grid - 20}px`; + } + } + this.paintLabel(); + this.children.forEach((item) => item.setState({ style: { grid } })); + }; + this.on("style", () => this.schedule(handleResize)); + const itemsChange = () => { + this.updateUI(); + this.children.forEach((item) => item.componentWillMount()); + }; + this.on("items", () => this.schedule(itemsChange)); + const labelChange = () => { + this.paintLabel(); + this.label.title = this.state.label; + }; + this.on("label", () => this.schedule(labelChange)); + this.paintLabel(); + if ((_a = this.tabs) == null ? void 0 : _a.children.length) + this.tabs.children[0].click(); + this.children.forEach((item) => item.componentDidMount()); + return this; + } +} + + +/***/ }), + +/***/ "./src/components/HBargraph.ts": +/*!*************************************!*\ + !*** ./src/components/HBargraph.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ HBargraph) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./VBargraph */ "./src/components/VBargraph.ts"); +/* harmony import */ var _HBargraph_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HBargraph.scss */ "./src/components/HBargraph.scss"); + + + +class HBargraph extends _VBargraph__WEBPACK_IMPORTED_MODULE_1__["default"] { + constructor() { + super(...arguments); + this.className = "hbargraph"; + this.setStyle = () => { + const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + this.input.style.fontSize = `${fontsize || height * grid * 0.2}px`; + this.input.style.color = textcolor; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paint = () => { + const { barwidth, barbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style; + const { type, max, min, enums, scale, value } = this.state; + const ctx = this.ctx; + const canvas = this.canvas; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.canvasDiv.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const drawWidth = width * 0.9; + const drawHeight = barwidth || Math.min(height / 3, drawWidth * 0.05); + const left = width * 0.05; + const top = (height - drawHeight) * 0.5; + this.paintValue = value; + const paintValue = this.paintValue; + if (paintValue > this.maxValue) { + this.maxValue = paintValue; + if (this.maxTimer) + window.clearTimeout(this.maxTimer); + this.maxTimer = window.setTimeout(() => { + this.maxValue = this.paintValue; + this.maxTimer = void 0; + this.schedule(this.paint); + }, 1e3); + } + if (paintValue < this.maxValue && typeof this.maxTimer === "undefined") { + this.maxTimer = window.setTimeout(() => { + this.maxValue = this.paintValue; + this.maxTimer = void 0; + this.schedule(this.paint); + }, 1e3); + } + const maxValue = this.maxValue; + const coldStop = (-18 - min) / (max - min); + const warmStop = (-6 - min) / (max - min); + const hotStop = (-3 - min) / (max - min); + const overloadStop = Math.max(0, -min / (max - min)); + const gradient = ctx.createLinearGradient(left, 0, drawWidth, 0); + if (coldStop <= 1 && coldStop >= 0) + gradient.addColorStop(coldStop, coldcolor); + else if (coldStop > 1) + gradient.addColorStop(1, coldcolor); + if (warmStop <= 1 && warmStop >= 0) + gradient.addColorStop(warmStop, warmcolor); + if (hotStop <= 1 && hotStop >= 0) + gradient.addColorStop(hotStop, hotcolor); + if (overloadStop <= 1 && overloadStop >= 0) + gradient.addColorStop(overloadStop, overloadcolor); + else if (overloadStop < 0) + gradient.addColorStop(0, coldcolor); + ctx.fillStyle = barbgcolor; + if (paintValue < 0) + ctx.fillRect(left, top, drawWidth * overloadStop, drawHeight); + if (paintValue < max) + ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight); + ctx.fillStyle = gradient; + if (paintValue > min) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) })); + ctx.fillRect(left, top, distance * drawWidth, drawHeight); + } + if (paintValue > 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(max, paintValue) }) - overloadStop); + ctx.fillRect(left + overloadStop * drawWidth + 1, top, distance * drawWidth - 1, drawHeight); + } + if (maxValue > paintValue) { + if (maxValue <= 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, maxValue) })); + ctx.fillRect(left + distance * drawWidth - 1, top, 1, drawHeight); + } + if (maxValue > 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(max, maxValue) }) - overloadStop); + ctx.fillRect(left + Math.min(drawWidth - 1, (overloadStop + distance) * drawWidth), top, 1, drawHeight); + } + } + }; + } + paintLabel() { + return super.paintLabel("left"); + } +} + + +/***/ }), + +/***/ "./src/components/HSlider.ts": +/*!***********************************!*\ + !*** ./src/components/HSlider.ts ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ HSlider) +/* harmony export */ }); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/components/utils.ts"); +/* harmony import */ var _VSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./VSlider */ "./src/components/VSlider.ts"); +/* harmony import */ var _HSlider_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HSlider.scss */ "./src/components/HSlider.scss"); + + + +class HSlider extends _VSlider__WEBPACK_IMPORTED_MODULE_1__["default"] { + constructor() { + super(...arguments); + this.className = "hslider"; + this.setStyle = () => { + const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + this.input.style.fontSize = `${fontsize || height * grid * 0.2}px`; + this.input.style.color = textcolor; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paint = () => { + const { sliderwidth, sliderbgcolor, sliderbgoncolor, slidercolor } = this.state.style; + const ctx = this.ctx; + const canvas = this.canvas; + const distance = this.distance; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.canvasDiv.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const drawWidth = width * 0.9; + const drawHeight = sliderwidth || Math.min(height / 3, drawWidth * 0.05); + const left = width * 0.05; + const top = (height - drawHeight) * 0.5; + const borderRadius = drawHeight * 0.25; + this.interactionRect = [left, 0, drawWidth, height]; + const grd = ctx.createLinearGradient(left, 0, left + drawWidth, 0); + grd.addColorStop(Math.max(0, Math.min(1, distance)), sliderbgoncolor); + grd.addColorStop(Math.max(0, Math.min(1, distance)), sliderbgcolor); + ctx.fillStyle = grd; + (0,_utils__WEBPACK_IMPORTED_MODULE_0__.fillRoundedRect)(ctx, left, top, drawWidth, drawHeight, borderRadius); + ctx.fillStyle = slidercolor; + (0,_utils__WEBPACK_IMPORTED_MODULE_0__.fillRoundedRect)(ctx, left + drawWidth * distance - drawHeight, top - drawHeight, drawHeight * 2, drawHeight * 3, borderRadius); + }; + } + paintLabel() { + return super.paintLabel("left"); + } +} + + +/***/ }), + +/***/ "./src/components/Knob.ts": +/*!********************************!*\ + !*** ./src/components/Knob.ts ***! + \********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Knob) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/components/utils.ts"); +/* harmony import */ var _Knob_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Knob.scss */ "./src/components/Knob.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + + +class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "knob"; + this.handleChange = (e) => { + const value = parseFloat(e.currentTarget.value); + if (isFinite(value)) { + const changed = this.setValue(+value); + if (changed) + return; + } + this.input.value = this.inputNumber.value + (this.state.unit || ""); + }; + this.setStyle = () => { + const { fontsize, height, grid, textcolor, bgcolor, bordercolor } = this.state.style; + this.input.style.fontSize = `${fontsize || height * grid * 0.1}px`; + this.input.style.color = textcolor; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paint = () => { + const { knobwidth, knobcolor, knoboncolor, needlecolor } = this.state.style; + const ctx = this.ctx; + const canvas = this.canvas; + const distance = this.distance; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.canvas.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const start = 5 / 8 * Math.PI; + const end = 19 / 8 * Math.PI; + const valPos = start + (0,_utils__WEBPACK_IMPORTED_MODULE_1__.toRad)(distance * 315); + const dialHeight = Math.min(width, height) * 0.75; + const dialRadius = dialHeight * 0.5; + const dialCenterX = width * 0.5; + const dialCenterY = height * 0.5; + const valuePosX = dialCenterX + dialHeight * 0.5 * Math.cos(valPos); + const valuePosY = dialCenterY + dialHeight * 0.5 * Math.sin(valPos); + const lineWidth = knobwidth || dialRadius * 0.2; + ctx.strokeStyle = knobcolor; + ctx.lineWidth = lineWidth; + ctx.lineCap = "round"; + ctx.beginPath(); + ctx.arc(dialCenterX, dialCenterY, dialRadius, valPos, end); + ctx.stroke(); + if (distance) { + ctx.strokeStyle = knoboncolor; + ctx.beginPath(); + ctx.arc(dialCenterX, dialCenterY, dialRadius, start, valPos); + ctx.stroke(); + } + ctx.strokeStyle = needlecolor; + ctx.beginPath(); + ctx.moveTo(dialCenterX, dialCenterY); + ctx.lineTo(valuePosX, valuePosY); + ctx.stroke(); + }; + this.handleMouseOrTouchMove = (e) => { + const newValue = this.getValueFromDelta(e); + if (newValue !== this.state.value) + this.setValue(newValue); + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(18, 18, 18, 0)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)", + knobwidth: void 0, + knobcolor: "rgba(18, 18, 18, 1)", + knoboncolor: "rgba(255, 165, 0, 1)", + needlecolor: "rgba(200, 200, 200, 0.75)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.canvas = document.createElement("canvas"); + this.canvas.width = 10; + this.canvas.height = 10; + this.ctx = this.canvas.getContext("2d"); + this.inputNumber = document.createElement("input"); + this.inputNumber.type = "number"; + this.inputNumber.value = (+this.state.value.toFixed(3)).toString(); + this.inputNumber.max = this.state.max.toString(); + this.inputNumber.min = this.state.min.toString(); + this.inputNumber.step = this.state.step.toString(); + this.input = document.createElement("input"); + this.input.value = this.inputNumber.value + (this.state.unit || ""); + this.input.spellcheck = false; + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.input.addEventListener("change", this.handleChange); + this.canvas.addEventListener("pointerdown", this.handlePointerDown); + this.on("style", () => { + this.schedule(this.setStyle); + this.schedule(this.paint); + }); + this.on("label", () => this.schedule(this.paintLabel)); + const valueChange = () => { + this.inputNumber.value = (+this.state.value.toFixed(3)).toString(); + this.input.value = this.inputNumber.value + (this.state.unit || ""); + }; + this.on("value", () => { + this.schedule(valueChange); + this.schedule(this.paint); + }); + const maxChange = () => this.inputNumber.max = this.state.max.toString(); + this.on("max", () => { + this.schedule(maxChange); + this.schedule(this.paint); + }); + const minChange = () => this.inputNumber.min = this.state.min.toString(); + this.on("min", () => { + this.schedule(minChange); + this.schedule(this.paint); + }); + const stepChange = () => this.inputNumber.step = this.state.step.toString(); + this.on("step", () => { + this.schedule(stepChange); + this.schedule(this.paint); + }); + this.schedule(this.paint); + return this; + } + mount() { + this.container.appendChild(this.label); + this.container.appendChild(this.canvas); + this.container.appendChild(this.input); + return super.mount(); + } + getValueFromDelta(e) { + const { type, min, max, enums, scale } = this.state; + const step = type === "enum" ? 1 : this.state.step || 1; + const stepRange = this.stepRange; + const stepsCount = this.stepsCount; + const range = 100; + const prevDistance = _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ value: e.prevValue, type, min, max, enums, scale }) * range; + const distance = prevDistance + e.fromY - e.y; + const denormalized = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.denormalize)(distance / range, min, max); + const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(denormalized, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(denormalized, min, max) : denormalized; + let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange); + steps = Math.min(stepsCount, Math.max(0, steps)); + if (type === "enum") + return steps; + if (type === "int") + return Math.round(steps * step + min); + return steps * step + min; + } +} + + +/***/ }), + +/***/ "./src/components/Led.ts": +/*!*******************************!*\ + !*** ./src/components/Led.ts ***! + \*******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Led) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Led_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Led.scss */ "./src/components/Led.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Led extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "led"; + this.setStyle = () => { + const { bgcolor, bordercolor } = this.state.style; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paint = () => { + const { shape, ledbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style; + const { min, max } = this.state; + const { canvas, ctx, tempCanvas, tempCtx, distance } = this; + const ratio = window.devicePixelRatio || 1; + let { width, height } = canvas.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const drawHeight = Math.min(height, width) * 0.75; + const drawWidth = drawHeight; + const left = (width - drawWidth) * 0.5; + const top = (height - drawHeight) * 0.5; + const coldStop = (-18 - min) / (max - min); + const warmStop = (-6 - min) / (max - min); + const hotStop = (-3 - min) / (max - min); + const overloadStop = -min / (max - min); + const gradient = tempCtx.createLinearGradient(0, 0, tempCanvas.width, 0); + if (coldStop <= 1 && coldStop >= 0) + gradient.addColorStop(coldStop, coldcolor); + else if (coldStop > 1) + gradient.addColorStop(1, coldcolor); + if (warmStop <= 1 && warmStop >= 0) + gradient.addColorStop(warmStop, warmcolor); + if (hotStop <= 1 && hotStop >= 0) + gradient.addColorStop(hotStop, hotcolor); + if (overloadStop <= 1 && overloadStop >= 0) + gradient.addColorStop(overloadStop, overloadcolor); + else if (overloadStop < 0) + gradient.addColorStop(0, coldcolor); + tempCtx.fillStyle = gradient; + tempCtx.fillRect(0, 0, tempCanvas.width, 10); + const d = tempCtx.getImageData(Math.min(tempCanvas.width - 1, distance * tempCanvas.width), 0, 1, 1).data; + if (distance) + ctx.fillStyle = `rgb(${d[0]}, ${d[1]}, ${d[2]})`; + else + ctx.fillStyle = ledbgcolor; + if (shape === "circle") + ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI); + else + ctx.rect(left, top, drawWidth, drawHeight); + ctx.fill(); + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(18, 18, 18, 0)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)", + shape: "circle", + ledbgcolor: "rgba(18, 18, 18, 1)", + coldcolor: "rgba(12, 248, 100, 1)", + warmcolor: "rgba(195, 248, 100, 1)", + hotcolor: "rgba(255, 193, 10, 1)", + overloadcolor: "rgba(255, 10, 10, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.canvasDiv = document.createElement("div"); + this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`; + this.canvas = document.createElement("canvas"); + this.canvas.width = 10; + this.canvas.height = 10; + this.ctx = this.canvas.getContext("2d"); + this.tempCanvas = document.createElement("canvas"); + this.tempCtx = this.tempCanvas.getContext("2d"); + this.tempCanvas.width = 128; + this.tempCanvas.height = 1; + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.canvas.addEventListener("pointerdown", this.handlePointerDown); + this.on("style", () => this.schedule(this.setStyle)); + this.on("label", () => this.schedule(this.paintLabel)); + this.on("value", () => this.schedule(this.paint)); + this.on("max", () => this.schedule(this.paint)); + this.on("min", () => this.schedule(this.paint)); + this.on("step", () => this.schedule(this.paint)); + this.schedule(this.paint); + return this; + } + mount() { + this.canvasDiv.appendChild(this.canvas); + this.container.appendChild(this.label); + this.container.appendChild(this.canvasDiv); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/Menu.ts": +/*!********************************!*\ + !*** ./src/components/Menu.ts ***! + \********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Menu) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Menu_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Menu.scss */ "./src/components/Menu.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Menu extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "menu"; + this.handleChange = (e) => { + this.setValue(+e.currentTarget.value); + }; + this.setStyle = () => { + const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + this.select.style.backgroundColor = bgcolor; + this.select.style.borderColor = bordercolor; + this.select.style.color = textcolor; + this.select.style.fontSize = `${fontsize || height * grid / 4}px`; + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(255, 255, 255, 0.25)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.select = document.createElement("select"); + this.getOptions(); + this.setStyle(); + return this; + } + getOptions() { + const { enums } = this.state; + this.select.innerHTML = ""; + if (enums) { + let i = 0; + for (const key in enums) { + const option = document.createElement("option"); + option.value = enums[key].toString(); + option.text = key; + if (i === 0) + option.selected = true; + this.select.appendChild(option); + i++; + } + } + } + componentDidMount() { + super.componentDidMount(); + this.select.addEventListener("change", this.handleChange); + this.on("style", () => this.schedule(this.setStyle)); + this.on("label", () => this.schedule(this.paintLabel)); + this.on("enums", () => this.schedule(this.getOptions)); + const valueChange = () => { + for (let i = this.select.children.length - 1; i >= 0; i--) { + const option = this.select.children[i]; + if (+option.value === this.state.value) + this.select.selectedIndex = i; + } + }; + this.on("value", () => this.schedule(valueChange)); + valueChange(); + return this; + } + mount() { + this.container.appendChild(this.label); + this.container.appendChild(this.select); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/Nentry.ts": +/*!**********************************!*\ + !*** ./src/components/Nentry.ts ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Nentry) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Nentry_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Nentry.scss */ "./src/components/Nentry.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Nentry extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "nentry"; + this.handleChange = (e) => { + this.setValue(+e.currentTarget.value); + }; + this.setStyle = () => { + const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + this.input.style.backgroundColor = bgcolor; + this.input.style.borderColor = bordercolor; + this.input.style.color = textcolor; + this.input.style.fontSize = `${fontsize || height * grid / 4}px`; + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(255, 255, 255, 0.25)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.input = document.createElement("input"); + this.input.type = "number"; + this.input.value = (+this.state.value.toFixed(3)).toString(); + this.input.max = this.state.max.toString(); + this.input.min = this.state.min.toString(); + this.input.step = this.state.step.toString(); + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.input.addEventListener("change", this.handleChange); + this.on("style", () => this.schedule(this.setStyle)); + this.on("label", () => this.schedule(this.paintLabel)); + const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString(); + this.on("value", () => this.schedule(valueChange)); + const maxChange = () => this.input.max = this.state.max.toString(); + this.on("max", () => this.schedule(maxChange)); + const minChange = () => this.input.min = this.state.min.toString(); + this.on("min", () => this.schedule(minChange)); + const stepChange = () => this.input.step = this.state.step.toString(); + this.on("step", () => this.schedule(stepChange)); + return this; + } + mount() { + this.container.appendChild(this.label); + this.container.appendChild(this.input); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/Numerical.ts": +/*!*************************************!*\ + !*** ./src/components/Numerical.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Numerical) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Numerical_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Numerical.scss */ "./src/components/Numerical.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Numerical extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "numerical"; + this.setStyle = () => { + const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + this.input.style.backgroundColor = bgcolor; + this.input.style.borderColor = bordercolor; + this.input.style.color = textcolor; + this.input.style.fontSize = `${fontsize || height * grid / 4}px`; + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(255, 255, 255, 0.25)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.input = document.createElement("input"); + this.input.disabled = true; + this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || ""); + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.on("style", () => this.schedule(this.setStyle)); + this.on("label", () => this.schedule(this.paintLabel)); + const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || ""); + this.on("value", () => this.schedule(valueChange)); + return this; + } + mount() { + this.container.appendChild(this.label); + this.container.appendChild(this.input); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/Radio.ts": +/*!*********************************!*\ + !*** ./src/components/Radio.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Radio) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Radio_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Radio.scss */ "./src/components/Radio.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Radio extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "radio"; + this.getOptions = () => { + const { enums, address } = this.state; + this.group.innerHTML = ""; + if (enums) { + let i = 0; + for (const key in enums) { + const input = document.createElement("input"); + const div = document.createElement("div"); + input.value = enums[key].toString(); + input.name = address; + input.type = "radio"; + if (i === 0) + input.checked = true; + input.addEventListener("change", () => { + if (input.checked) + this.setValue(enums[key]); + }); + div.appendChild(input); + div.append(key); + this.group.appendChild(div); + i++; + } + } + }; + this.setStyle = () => { + const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + const fontSize = Math.min(height * grid * 0.1, width * grid * 0.1); + this.group.style.backgroundColor = bgcolor; + this.group.style.borderColor = bordercolor; + this.group.style.color = textcolor; + this.group.style.fontSize = `${fontsize || fontSize}px`; + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(255, 255, 255, 0.25)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.group = document.createElement("div"); + this.group.className = "faust-ui-component-radio-group"; + this.getOptions(); + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.on("style", () => this.schedule(this.setStyle)); + this.on("label", () => this.schedule(this.paintLabel)); + this.on("enums", () => this.schedule(this.getOptions)); + const valueChange = () => { + for (let i = this.group.children.length - 1; i >= 0; i--) { + const input = this.group.children[i].querySelector("input"); + if (+input.value === this.state.value) + input.checked = true; + } + }; + this.on("value", () => this.schedule(valueChange)); + valueChange(); + return this; + } + mount() { + this.container.appendChild(this.label); + this.container.appendChild(this.group); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/Soundfile.ts": +/*!*************************************!*\ + !*** ./src/components/Soundfile.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Soundfile) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _Soundfile_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Soundfile.scss */ "./src/components/Soundfile.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class Soundfile extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "soundfile"; + this.setStyle = () => { + const { value, style } = this.state; + const { height, grid, fontsize, fontname, fontface, textcolor, textoncolor, bgoncolor, bgcolor, bordercolor, borderoncolor } = style; + this.btn.style.backgroundColor = value ? bgoncolor : bgcolor; + this.btn.style.borderColor = value ? borderoncolor : bordercolor; + this.btn.style.color = value ? textoncolor : textcolor; + this.btn.style.fontSize = `${fontsize || height * grid / 4}px`; + this.btn.style.fontFamily = `${fontname}, sans-serif`; + this.btn.style.fontStyle = fontface; + }; + this.handleMouseOrTouchDown = () => { + }; + this.handleMouseOrTouchUp = () => { + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "normal", + bgcolor: "rgba(40, 40, 40, 1)", + bgoncolor: "rgba(18, 18, 18, 1)", + bordercolor: "rgba(80, 80, 80, 1)", + borderoncolor: "rgba(255, 165, 0, 1)", + textcolor: "rgba(226, 222, 255, 0.5)", + textoncolor: "rgba(255, 165, 0, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.btn = document.createElement("div"); + this.span = document.createElement("span"); + this.span.innerText = this.state.label; + this.setStyle(); + return this; + } + mount() { + this.btn.appendChild(this.span); + this.container.appendChild(this.btn); + return super.mount(); + } + componentDidMount() { + super.componentDidMount(); + this.btn.addEventListener("pointerdown", this.handlePointerDown); + this.on("style", () => this.schedule(this.setStyle)); + const labelChange = () => this.span.innerText = this.state.label; + this.on("label", () => this.schedule(labelChange)); + this.on("value", () => this.schedule(this.setStyle)); + return this; + } +} + + +/***/ }), + +/***/ "./src/components/VBargraph.ts": +/*!*************************************!*\ + !*** ./src/components/VBargraph.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ VBargraph) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _VBargraph_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./VBargraph.scss */ "./src/components/VBargraph.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + +class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "vbargraph"; + this.setStyle = () => { + const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + const fontSize = Math.min(height * grid * 0.05, width * grid * 0.2); + this.input.style.fontSize = `${fontsize || fontSize}px`; + this.input.style.color = textcolor; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paintValue = 0; + this.maxValue = -Infinity; + this.paint = () => { + const { barwidth, barbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style; + const { type, max, min, enums, scale, value } = this.state; + const ctx = this.ctx; + const canvas = this.canvas; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.canvasDiv.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const drawHeight = height * 0.9; + const drawWidth = barwidth || Math.min(width / 3, drawHeight * 0.05); + const left = (width - drawWidth) * 0.5; + const top = height * 0.05; + this.paintValue = value; + const paintValue = this.paintValue; + if (paintValue > this.maxValue) { + this.maxValue = paintValue; + if (this.maxTimer) + window.clearTimeout(this.maxTimer); + this.maxTimer = window.setTimeout(() => { + this.maxValue = this.paintValue; + this.maxTimer = void 0; + this.schedule(this.paint); + }, 1e3); + } + if (paintValue < this.maxValue && typeof this.maxTimer === "undefined") { + this.maxTimer = window.setTimeout(() => { + this.maxValue = this.paintValue; + this.maxTimer = void 0; + this.schedule(this.paint); + }, 1e3); + } + const maxValue = this.maxValue; + const coldStop = (-18 - min) / (max - min); + const warmStop = (-6 - min) / (max - min); + const hotStop = (-3 - min) / (max - min); + const overloadStop = Math.max(0, -min / (max - min)); + const gradient = ctx.createLinearGradient(0, drawHeight, 0, top); + if (coldStop <= 1 && coldStop >= 0) + gradient.addColorStop(coldStop, coldcolor); + else if (coldStop > 1) + gradient.addColorStop(1, coldcolor); + if (warmStop <= 1 && warmStop >= 0) + gradient.addColorStop(warmStop, warmcolor); + if (hotStop <= 1 && hotStop >= 0) + gradient.addColorStop(hotStop, hotcolor); + if (overloadStop <= 1 && overloadStop >= 0) + gradient.addColorStop(overloadStop, overloadcolor); + else if (overloadStop < 0) + gradient.addColorStop(0, coldcolor); + ctx.fillStyle = barbgcolor; + if (paintValue < 0) + ctx.fillRect(left, top + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop); + if (paintValue < max) + ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1); + ctx.fillStyle = gradient; + if (paintValue > min) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) })); + ctx.fillRect(left, top + (1 - distance) * drawHeight, drawWidth, drawHeight * distance); + } + if (paintValue > 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(max, paintValue) }) - overloadStop); + ctx.fillRect(left, top + (1 - overloadStop - distance) * drawHeight, drawWidth, drawHeight * distance - 1); + } + if (maxValue > paintValue) { + if (maxValue <= 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(0, maxValue) })); + ctx.fillRect(left, top + (1 - distance) * drawHeight, drawWidth, 1); + } + if (maxValue > 0) { + const distance = Math.max(0, _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"].getDistance({ type, max, min, enums, scale, value: Math.min(max, maxValue) }) - overloadStop); + ctx.fillRect(left, Math.max(top, top + (1 - overloadStop - distance) * drawHeight - 1), drawWidth, 1); + } + } + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(18, 18, 18, 0)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)", + barwidth: void 0, + barbgcolor: "rgba(18, 18, 18, 1)", + coldcolor: "rgba(12, 248, 100, 1)", + warmcolor: "rgba(195, 248, 100, 1)", + hotcolor: "rgba(255, 193, 10, 1)", + overloadcolor: "rgba(255, 10, 10, 1)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.flexDiv = document.createElement("div"); + this.flexDiv.className = `faust-ui-component-${this.className}-flexdiv`; + this.canvasDiv = document.createElement("div"); + this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`; + this.canvas = document.createElement("canvas"); + this.canvas.width = 10; + this.canvas.height = 10; + this.ctx = this.canvas.getContext("2d"); + this.input = document.createElement("input"); + this.input.disabled = true; + this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || ""); + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.canvas.addEventListener("pointerdown", this.handlePointerDown); + this.on("style", () => { + this.schedule(this.setStyle); + this.schedule(this.paint); + }); + this.on("label", () => this.schedule(this.paintLabel)); + const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || ""); + this.on("value", () => { + this.schedule(valueChange); + this.schedule(this.paint); + }); + this.on("max", () => this.schedule(this.paint)); + this.on("min", () => this.schedule(this.paint)); + this.on("step", () => this.schedule(this.paint)); + this.schedule(this.paint); + return this; + } + mount() { + this.canvasDiv.appendChild(this.canvas); + this.flexDiv.appendChild(this.canvasDiv); + this.flexDiv.appendChild(this.input); + this.container.appendChild(this.label); + this.container.appendChild(this.flexDiv); + return super.mount(); + } +} + + +/***/ }), + +/***/ "./src/components/VSlider.ts": +/*!***********************************!*\ + !*** ./src/components/VSlider.ts ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ VSlider) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/components/AbstractItem.ts"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/components/utils.ts"); +/* harmony import */ var _VSlider_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./VSlider.scss */ "./src/components/VSlider.scss"); +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); + + + +class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.className = "vslider"; + this.interactionRect = [0, 0, 0, 0]; + this.handleChange = (e) => { + const value = parseFloat(e.currentTarget.value); + if (isFinite(value)) { + const changed = this.setValue(+value); + if (changed) + return; + } + this.input.value = this.inputNumber.value + (this.state.unit || ""); + }; + this.setStyle = () => { + const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style; + const fontSize = Math.min(height * grid * 0.05, width * grid * 0.2); + this.input.style.fontSize = `${fontsize || fontSize}px`; + this.input.style.color = textcolor; + this.container.style.backgroundColor = bgcolor; + this.container.style.borderColor = bordercolor; + }; + this.paint = () => { + const { sliderwidth, sliderbgcolor, sliderbgoncolor, slidercolor } = this.state.style; + const ctx = this.ctx; + const canvas = this.canvas; + const distance = this.distance; + const ratio = window.devicePixelRatio || 1; + let { width, height } = this.canvasDiv.getBoundingClientRect(); + width = Math.floor(width); + height = Math.floor(height); + const scaledWidth = Math.floor(width * ratio); + const scaledHeight = Math.floor(height * ratio); + canvas.width = scaledWidth; + canvas.height = scaledHeight; + ctx.scale(ratio, ratio); + const drawHeight = height * 0.9; + const drawWidth = sliderwidth || Math.min(width / 3, drawHeight * 0.05); + const left = (width - drawWidth) * 0.5; + const top = height * 0.05; + const borderRadius = drawWidth * 0.25; + this.interactionRect = [0, top, width, drawHeight]; + const grd = ctx.createLinearGradient(0, top, 0, top + drawHeight); + grd.addColorStop(Math.max(0, Math.min(1, 1 - distance)), sliderbgcolor); + grd.addColorStop(Math.max(0, Math.min(1, 1 - distance)), sliderbgoncolor); + ctx.fillStyle = grd; + (0,_utils__WEBPACK_IMPORTED_MODULE_1__.fillRoundedRect)(ctx, left, top, drawWidth, drawHeight, borderRadius); + ctx.fillStyle = slidercolor; + (0,_utils__WEBPACK_IMPORTED_MODULE_1__.fillRoundedRect)(ctx, left - drawWidth, top + drawHeight * (1 - distance) - drawWidth, drawWidth * 3, drawWidth * 2, borderRadius); + }; + this.handleMouseOrTouchDown = (e) => { + const { value } = this.state; + if (e.x < this.interactionRect[0] || e.x > this.interactionRect[0] + this.interactionRect[2] || e.y < this.interactionRect[1] || e.y > this.interactionRect[1] + this.interactionRect[3]) + return; + const newValue = this.getValueFromPos(e); + if (newValue !== value) + this.setValue(this.getValueFromPos(e)); + }; + this.handleMouseOrTouchMove = (e) => { + const newValue = this.getValueFromPos(e); + if (newValue !== this.state.value) + this.setValue(newValue); + }; + } + static get defaultProps() { + const inherited = super.defaultProps; + return __spreadProps(__spreadValues({}, inherited), { + style: __spreadProps(__spreadValues({}, inherited.style), { + fontname: "Arial", + fontsize: void 0, + fontface: "regular", + bgcolor: "rgba(18, 18, 18, 0)", + bordercolor: "rgba(80, 80, 80, 0)", + labelcolor: "rgba(226, 222, 255, 0.5)", + textcolor: "rgba(18, 18, 18, 1)", + sliderwidth: void 0, + sliderbgcolor: "rgba(18, 18, 18, 1)", + sliderbgoncolor: "rgba(255, 165, 0, 1)", + slidercolor: "rgba(200, 200, 200, 0.75)" + }) + }); + } + componentWillMount() { + super.componentWillMount(); + this.flexDiv = document.createElement("div"); + this.flexDiv.className = `faust-ui-component-${this.className}-flexdiv`; + this.canvasDiv = document.createElement("div"); + this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`; + this.canvas = document.createElement("canvas"); + this.canvas.width = 10; + this.canvas.height = 10; + this.ctx = this.canvas.getContext("2d"); + this.inputNumber = document.createElement("input"); + this.inputNumber.type = "number"; + this.inputNumber.value = (+this.state.value.toFixed(3)).toString(); + this.inputNumber.max = this.state.max.toString(); + this.inputNumber.min = this.state.min.toString(); + this.inputNumber.step = this.state.step.toString(); + this.input = document.createElement("input"); + this.input.value = this.inputNumber.value + (this.state.unit || ""); + this.input.spellcheck = false; + this.setStyle(); + return this; + } + componentDidMount() { + super.componentDidMount(); + this.input.addEventListener("change", this.handleChange); + this.canvas.addEventListener("pointerdown", this.handlePointerDown); + this.on("style", () => { + this.schedule(this.setStyle); + this.schedule(this.paint); + }); + this.on("label", () => this.schedule(this.paintLabel)); + const valueChange = () => { + this.inputNumber.value = (+this.state.value.toFixed(3)).toString(); + this.input.value = this.inputNumber.value + (this.state.unit || ""); + }; + this.on("value", () => { + this.schedule(valueChange); + this.schedule(this.paint); + }); + const maxChange = () => this.inputNumber.max = this.state.max.toString(); + this.on("max", () => { + this.schedule(maxChange); + this.schedule(this.paint); + }); + const minChange = () => this.inputNumber.min = this.state.min.toString(); + this.on("min", () => { + this.schedule(minChange); + this.schedule(this.paint); + }); + const stepChange = () => this.inputNumber.step = this.state.step.toString(); + this.on("step", () => { + this.schedule(stepChange); + this.schedule(this.paint); + }); + this.schedule(this.paint); + return this; + } + mount() { + this.canvasDiv.appendChild(this.canvas); + this.flexDiv.appendChild(this.canvasDiv); + this.flexDiv.appendChild(this.input); + this.container.appendChild(this.label); + this.container.appendChild(this.flexDiv); + return super.mount(); + } + get stepsCount() { + const { type, max, min, step, enums } = this.state; + const maxSteps = type === "enum" ? enums.length : type === "int" ? max - min : (max - min) / step; + if (step) { + if (type === "enum") + return enums.length; + if (type === "int") + return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps); + return Math.floor((max - min) / step); + } + return maxSteps; + } + get stepRange() { + const full = this.interactionRect[this.className === "vslider" ? 3 : 2]; + const stepsCount = this.stepsCount; + return full / stepsCount; + } + getValueFromPos(e) { + const { type, min, max, scale } = this.state; + const step = type === "enum" ? 1 : this.state.step || 1; + const stepRange = this.stepRange; + const stepsCount = this.stepsCount; + const distance = this.className === "vslider" ? this.interactionRect[3] - (e.y - this.interactionRect[1]) : e.x - this.interactionRect[0]; + const range = this.className === "vslider" ? this.interactionRect[3] : this.interactionRect[2]; + const denormalized = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.denormalize)(distance / range, min, max); + const v = scale === "exp" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normExp)(denormalized, min, max) : scale === "log" ? (0,_utils__WEBPACK_IMPORTED_MODULE_1__.normLog)(denormalized, min, max) : denormalized; + let steps = Math.round((0,_utils__WEBPACK_IMPORTED_MODULE_1__.normalize)(v, min, max) * range / stepRange); + steps = Math.min(stepsCount, Math.max(0, steps)); + if (type === "enum") + return steps; + if (type === "int") + return Math.round(steps * step + min); + return steps * step + min; + } +} + + +/***/ }), + +/***/ "./src/components/utils.ts": +/*!*********************************!*\ + !*** ./src/components/utils.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ atodb: () => (/* binding */ atodb), +/* harmony export */ dbtoa: () => (/* binding */ dbtoa), +/* harmony export */ denormalize: () => (/* binding */ denormalize), +/* harmony export */ fillRoundedRect: () => (/* binding */ fillRoundedRect), +/* harmony export */ iNormExp: () => (/* binding */ iNormExp), +/* harmony export */ iNormLog: () => (/* binding */ iNormLog), +/* harmony export */ normExp: () => (/* binding */ normExp), +/* harmony export */ normLog: () => (/* binding */ normLog), +/* harmony export */ normalize: () => (/* binding */ normalize), +/* harmony export */ roundedRect: () => (/* binding */ roundedRect), +/* harmony export */ toMIDI: () => (/* binding */ toMIDI), +/* harmony export */ toRad: () => (/* binding */ toRad) +/* harmony export */ }); +const toMIDI = (f) => ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"][(f % 12 + 12) % 12] + Math.round(f / 12 - 2); +const toRad = (degrees) => degrees * Math.PI / 180; +const atodb = (a) => 20 * Math.log10(a); +const dbtoa = (db) => 10 ** (db / 20); +const denormalize = (x, min, max) => min + (max - min) * x; +const normalize = (x, min, max) => (x - min) / (max - min) || 0; +const normLog = (x, min, max) => { + const normalized = normalize(x, min, max); + const logMin = Math.log(Math.max(Number.EPSILON, min)); + const logMax = Math.log(Math.max(Number.EPSILON, max)); + const vLog = denormalize(normalized, logMin, logMax); + const v = Math.exp(vLog); + return Math.max(min, Math.min(max, v)); +}; +const iNormLog = (vIn, min, max) => { + const v = Math.max(min, Math.min(max, vIn)); + const vLog = Math.log(Math.max(Number.EPSILON, v)); + const logMin = Math.log(Math.max(Number.EPSILON, min)); + const logMax = Math.log(Math.max(Number.EPSILON, max)); + const normalized = normalize(vLog, logMin, logMax); + return denormalize(normalized, min, max); +}; +const normExp = iNormLog; +const iNormExp = normLog; +const roundedRect = (ctx, x, y, width, height, radius) => { + const radii = [0, 0, 0, 0]; + if (typeof radius === "number") + radii.fill(radius); + else + radius.forEach((v, i) => radii[i] = v); + ctx.beginPath(); + ctx.moveTo(x + radii[0], y); + ctx.lineTo(x + width - radii[1], y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radii[1]); + ctx.lineTo(x + width, y + height - radii[2]); + ctx.quadraticCurveTo(x + width, y + height, x + width - radii[2], y + height); + ctx.lineTo(x + radii[3], y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radii[3]); + ctx.lineTo(x, y + radii[0]); + ctx.quadraticCurveTo(x, y, x + radii[0], y); + ctx.closePath(); + ctx.stroke(); +}; +const fillRoundedRect = (ctx, x, y, width, height, radius) => { + const radii = [0, 0, 0, 0]; + if (typeof radius === "number") + radii.fill(radius); + else + radius.forEach((v, i) => radii[i] = v); + ctx.beginPath(); + ctx.moveTo(x + radii[0], y); + ctx.lineTo(x + width - radii[1], y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radii[1]); + ctx.lineTo(x + width, y + height - radii[2]); + ctx.quadraticCurveTo(x + width, y + height, x + width - radii[2], y + height); + ctx.lineTo(x + radii[3], y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radii[3]); + ctx.lineTo(x, y + radii[0]); + ctx.quadraticCurveTo(x, y, x + radii[0], y); + ctx.closePath(); + ctx.fill(); +}; + + +/***/ }), + +/***/ "./src/instantiate.ts": +/*!****************************!*\ + !*** ./src/instantiate.ts ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _FaustUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FaustUI */ "./src/FaustUI.ts"); + +const instantiate = () => { + const faustUI = new _FaustUI__WEBPACK_IMPORTED_MODULE_0__["default"]({ + root: document.getElementById("root"), + listenWindowResize: true, + listenWindowMessage: true + }); + let host; + window.addEventListener("message", (e) => { + const { source } = e; + host = source; + }); + window.addEventListener("keydown", (e) => { + if (host) + host.postMessage({ type: "keydown", key: e.key }, "*"); + }); + window.addEventListener("keyup", (e) => { + if (host) + host.postMessage({ type: "keyup", key: e.key }, "*"); + }); + window.faustUI = faustUI; +}; +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (instantiate); + + +/***/ }), + +/***/ "./src/layout/AbstractGroup.ts": +/*!*************************************!*\ + !*** ./src/layout/AbstractGroup.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractGroup) +/* harmony export */ }); +const _AbstractGroup = class { + constructor(group, isRoot) { + this.isRoot = !!isRoot; + Object.assign(this, group); + const { hasHSizingDesc, hasVSizingDesc } = this; + const sizing = hasHSizingDesc && hasVSizingDesc ? "both" : hasHSizingDesc ? "horizontal" : hasVSizingDesc ? "vertical" : "none"; + this.layout = { + type: group.type, + width: _AbstractGroup.padding * 2, + height: _AbstractGroup.padding * 2 + (this.isRoot ? 0 : _AbstractGroup.labelHeight), + sizing + }; + } + /** + * find recursively if the group has horizontal-sizable item + */ + get hasHSizingDesc() { + return !!this.items.find((item) => { + if (item instanceof _AbstractGroup) + return item.hasHSizingDesc; + return item.layout.sizing === "horizontal" || item.layout.sizing === "both"; + }); + } + /** + * find recursively if the group has vertical-sizable item + */ + get hasVSizingDesc() { + return !!this.items.find((item) => { + if (item instanceof _AbstractGroup) + return item.hasVSizingDesc; + return item.layout.sizing === "vertical" || item.layout.sizing === "both"; + }); + } + adjust() { + return this; + } + expand(dX, dY) { + return this; + } + offset() { + return this; + } +}; +let AbstractGroup = _AbstractGroup; +AbstractGroup.padding = 0.2; +AbstractGroup.labelHeight = 0.25; +AbstractGroup.spaceBetween = 0.1; + + + +/***/ }), + +/***/ "./src/layout/AbstractInputItem.ts": +/*!*****************************************!*\ + !*** ./src/layout/AbstractInputItem.ts ***! + \*****************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractInputItem) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/layout/AbstractItem.ts"); + +class AbstractInputItem extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor(item) { + super(item); + this.init = +item.init || 0; + this.step = +item.step || 1; + } +} + + +/***/ }), + +/***/ "./src/layout/AbstractItem.ts": +/*!************************************!*\ + !*** ./src/layout/AbstractItem.ts ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractItem) +/* harmony export */ }); +class AbstractItem { + constructor(item) { + Object.assign(this, item); + this.min = isFinite(+this.min) ? +this.min : 0; + this.max = isFinite(+this.max) ? +this.max : 1; + } + adjust() { + return this; + } + expand(dX, dY) { + return this; + } + offset() { + return this; + } +} + + +/***/ }), + +/***/ "./src/layout/AbstractOutputItem.ts": +/*!******************************************!*\ + !*** ./src/layout/AbstractOutputItem.ts ***! + \******************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ AbstractOutputItem) +/* harmony export */ }); +/* harmony import */ var _AbstractItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractItem */ "./src/layout/AbstractItem.ts"); + +class AbstractOutputItem extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] { +} + + +/***/ }), + +/***/ "./src/layout/Button.ts": +/*!******************************!*\ + !*** ./src/layout/Button.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Button) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Button extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "button", + width: 2, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Checkbox.ts": +/*!********************************!*\ + !*** ./src/layout/Checkbox.ts ***! + \********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Checkbox) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Checkbox extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "checkbox", + width: 2, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/HBargraph.ts": +/*!*********************************!*\ + !*** ./src/layout/HBargraph.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ HBargraph) +/* harmony export */ }); +/* harmony import */ var _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractOutputItem */ "./src/layout/AbstractOutputItem.ts"); + +class HBargraph extends _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "hbargraph", + width: 5, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/HGroup.ts": +/*!******************************!*\ + !*** ./src/layout/HGroup.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ HGroup) +/* harmony export */ }); +/* harmony import */ var _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractGroup */ "./src/layout/AbstractGroup.ts"); + +class HGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] { + adjust() { + this.items.forEach((item) => { + item.adjust(); + this.layout.width += item.layout.width; + this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding + (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight)); + }); + this.layout.width += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1); + if (this.layout.width < 1) + this.layout.width += 1; + return this; + } + expand(dX) { + let hExpandItems = 0; + this.items.forEach((item) => { + if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") + hExpandItems++; + }); + this.items.forEach((item) => { + let dX$ = 0; + let dY$ = 0; + if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") { + dX$ = hExpandItems ? dX / hExpandItems : 0; + item.layout.width += dX$; + } + if (item.layout.sizing === "both" || item.layout.sizing === "vertical") { + dY$ = this.layout.height - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight) - item.layout.height; + item.layout.height += dY$; + } + item.expand(dX$, dY$); + }); + return this; + } + offset() { + const { labelHeight, padding, spaceBetween } = _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"]; + let $left = padding; + const $top = padding + (this.isRoot ? 0 : labelHeight); + const { height } = this.layout; + this.items.forEach((item) => { + item.layout.offsetLeft = $left; + item.layout.offsetTop = $top; + item.layout.offsetTop += (height - (this.isRoot ? 0 : labelHeight) - item.layout.height) / 2 - padding; + item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft; + item.layout.top = (this.layout.top || 0) + item.layout.offsetTop; + item.offset(); + $left += item.layout.width + spaceBetween; + }); + return this; + } +} + + +/***/ }), + +/***/ "./src/layout/HSlider.ts": +/*!*******************************!*\ + !*** ./src/layout/HSlider.ts ***! + \*******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ HSlider) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class HSlider extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "hslider", + width: 5, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Knob.ts": +/*!****************************!*\ + !*** ./src/layout/Knob.ts ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Knob) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Knob extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "knob", + width: 1, + height: 1.75, + sizing: "none" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Layout.ts": +/*!******************************!*\ + !*** ./src/layout/Layout.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Layout) +/* harmony export */ }); +/* harmony import */ var _HSlider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HSlider */ "./src/layout/HSlider.ts"); +/* harmony import */ var _VSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./VSlider */ "./src/layout/VSlider.ts"); +/* harmony import */ var _Nentry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Nentry */ "./src/layout/Nentry.ts"); +/* harmony import */ var _Soundfile__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Soundfile */ "./src/layout/Soundfile.ts"); +/* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Button */ "./src/layout/Button.ts"); +/* harmony import */ var _Checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Checkbox */ "./src/layout/Checkbox.ts"); +/* harmony import */ var _Knob__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Knob */ "./src/layout/Knob.ts"); +/* harmony import */ var _Menu__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Menu */ "./src/layout/Menu.ts"); +/* harmony import */ var _Radio__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Radio */ "./src/layout/Radio.ts"); +/* harmony import */ var _Led__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Led */ "./src/layout/Led.ts"); +/* harmony import */ var _Numerical__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Numerical */ "./src/layout/Numerical.ts"); +/* harmony import */ var _HBargraph__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./HBargraph */ "./src/layout/HBargraph.ts"); +/* harmony import */ var _VBargraph__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./VBargraph */ "./src/layout/VBargraph.ts"); +/* harmony import */ var _HGroup__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./HGroup */ "./src/layout/HGroup.ts"); +/* harmony import */ var _VGroup__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./VGroup */ "./src/layout/VGroup.ts"); +/* harmony import */ var _TGroup__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./TGroup */ "./src/layout/TGroup.ts"); + + + + + + + + + + + + + + + + +class Layout { + /** + * Get the rendering type of an item by parsing its metadata + */ + static predictType(item) { + var _a, _b, _c, _d, _e; + if (item.type === "hbargraph" || item.type === "vbargraph") { + if ((_a = item.meta) == null ? void 0 : _a.find((meta) => { + var _a2; + return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("led"); + })) + return "led"; + if ((_b = item.meta) == null ? void 0 : _b.find((meta) => { + var _a2; + return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("numerical"); + })) + return "numerical"; + return item.type; + } + if (item.type === "hslider" || item.type === "nentry" || item.type === "vslider") { + if ((_c = item.meta) == null ? void 0 : _c.find((meta) => { + var _a2; + return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("knob"); + })) + return "knob"; + if ((_d = item.meta) == null ? void 0 : _d.find((meta) => { + var _a2; + return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("menu"); + })) + return "menu"; + if ((_e = item.meta) == null ? void 0 : _e.find((meta) => { + var _a2; + return (_a2 = meta.style) == null ? void 0 : _a2.startsWith("radio"); + })) + return "radio"; + } + return item.type; + } + /** + * Get the Layout class constructor of an item + */ + static getItem(item) { + const Ctor = { + hslider: _HSlider__WEBPACK_IMPORTED_MODULE_0__["default"], + vslider: _VSlider__WEBPACK_IMPORTED_MODULE_1__["default"], + nentry: _Nentry__WEBPACK_IMPORTED_MODULE_2__["default"], + soundfile: _Soundfile__WEBPACK_IMPORTED_MODULE_3__["default"], + button: _Button__WEBPACK_IMPORTED_MODULE_4__["default"], + checkbox: _Checkbox__WEBPACK_IMPORTED_MODULE_5__["default"], + knob: _Knob__WEBPACK_IMPORTED_MODULE_6__["default"], + menu: _Menu__WEBPACK_IMPORTED_MODULE_7__["default"], + radio: _Radio__WEBPACK_IMPORTED_MODULE_8__["default"], + led: _Led__WEBPACK_IMPORTED_MODULE_9__["default"], + numerical: _Numerical__WEBPACK_IMPORTED_MODULE_10__["default"], + hbargraph: _HBargraph__WEBPACK_IMPORTED_MODULE_11__["default"], + vbargraph: _VBargraph__WEBPACK_IMPORTED_MODULE_12__["default"], + hgroup: _HGroup__WEBPACK_IMPORTED_MODULE_13__["default"], + vgroup: _VGroup__WEBPACK_IMPORTED_MODULE_14__["default"], + tgroup: _TGroup__WEBPACK_IMPORTED_MODULE_15__["default"] + }; + const layoutType = this.predictType(item); + return new Ctor[layoutType](item); + } + static getItems(items) { + return items.map((item) => { + if ("items" in item) + item.items = this.getItems(item.items); + return this.getItem(item); + }); + } + static calc(ui) { + const rootGroup = new _VGroup__WEBPACK_IMPORTED_MODULE_14__["default"]({ items: this.getItems(ui), type: "vgroup", label: "" }, true); + rootGroup.adjust(); + rootGroup.expand(0, 0); + rootGroup.offset(); + return rootGroup; + } +} + + +/***/ }), + +/***/ "./src/layout/Led.ts": +/*!***************************!*\ + !*** ./src/layout/Led.ts ***! + \***************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Led) +/* harmony export */ }); +/* harmony import */ var _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractOutputItem */ "./src/layout/AbstractOutputItem.ts"); + +class Led extends _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "led", + width: 1, + height: 1, + sizing: "none" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Menu.ts": +/*!****************************!*\ + !*** ./src/layout/Menu.ts ***! + \****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Menu) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Menu extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "menu", + width: 2, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Nentry.ts": +/*!******************************!*\ + !*** ./src/layout/Nentry.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Nentry) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Nentry extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "nentry", + width: 1, + height: 1, + sizing: "none" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Numerical.ts": +/*!*********************************!*\ + !*** ./src/layout/Numerical.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Numerical) +/* harmony export */ }); +/* harmony import */ var _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractOutputItem */ "./src/layout/AbstractOutputItem.ts"); + +class Numerical extends _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "numerical", + width: 1, + height: 1, + sizing: "none" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Radio.ts": +/*!*****************************!*\ + !*** ./src/layout/Radio.ts ***! + \*****************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Radio) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Radio extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "radio", + width: 2, + height: 2, + // TODO: vradio and hradio + sizing: "both" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/Soundfile.ts": +/*!*********************************!*\ + !*** ./src/layout/Soundfile.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ Soundfile) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class Soundfile extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "soundfile", + width: 2, + height: 1, + sizing: "horizontal" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/TGroup.ts": +/*!******************************!*\ + !*** ./src/layout/TGroup.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ TGroup) +/* harmony export */ }); +/* harmony import */ var _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractGroup */ "./src/layout/AbstractGroup.ts"); + +const _TGroup = class extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] { + adjust() { + this.items.forEach((item) => { + item.adjust(); + this.layout.width = Math.max(this.layout.width, item.layout.width + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding); + this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding + _TGroup.labelHeight); + }); + const tabsCount = this.items.length; + this.layout.width = Math.max(this.layout.width, tabsCount * _TGroup.tabLayout.width); + this.layout.height += _TGroup.tabLayout.height; + if (this.layout.width < 1) + this.layout.width += 1; + return this; + } + expand() { + const tabsCount = this.items.length; + this.items.forEach((item) => { + let dY$ = 0; + let dX$ = 0; + if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") + dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width; + if (item.layout.sizing === "both" || item.layout.sizing === "vertical") + dY$ = this.layout.height - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - (this.isRoot ? 0 : _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].labelHeight) - (tabsCount ? _TGroup.tabLayout.height : 0) - item.layout.height; + item.expand(dX$, dY$); + }); + return this; + } + offset() { + const { labelHeight, padding } = _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"]; + const $left = padding; + const $top = padding + (this.isRoot ? 0 : labelHeight) + _TGroup.tabLayout.height; + this.items.forEach((item) => { + item.layout.offsetLeft = $left; + item.layout.offsetTop = $top; + item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft; + item.layout.top = (this.layout.top || 0) + item.layout.offsetTop; + item.offset(); + }); + return this; + } +}; +let TGroup = _TGroup; +TGroup.tabLayout = { + width: 2, + height: 1 +}; + + + +/***/ }), + +/***/ "./src/layout/VBargraph.ts": +/*!*********************************!*\ + !*** ./src/layout/VBargraph.ts ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ VBargraph) +/* harmony export */ }); +/* harmony import */ var _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractOutputItem */ "./src/layout/AbstractOutputItem.ts"); + +class VBargraph extends _AbstractOutputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "vbargraph", + width: 1, + height: 5, + sizing: "vertical" + }; + } +} + + +/***/ }), + +/***/ "./src/layout/VGroup.ts": +/*!******************************!*\ + !*** ./src/layout/VGroup.ts ***! + \******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ VGroup) +/* harmony export */ }); +/* harmony import */ var _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractGroup */ "./src/layout/AbstractGroup.ts"); + +class VGroup extends _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"] { + adjust() { + this.items.forEach((item) => { + item.adjust(); + this.layout.width = Math.max(this.layout.width, item.layout.width + 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding); + this.layout.height += item.layout.height; + }); + this.layout.height += _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].spaceBetween * (this.items.length - 1); + if (this.layout.width < 1) + this.layout.width += 1; + return this; + } + expand(dX, dY) { + let vExpandItems = 0; + this.items.forEach((item) => { + if (item.layout.sizing === "both" || item.layout.sizing === "vertical") + vExpandItems++; + }); + this.items.forEach((item) => { + let dX$ = 0; + let dY$ = 0; + if (item.layout.sizing === "both" || item.layout.sizing === "horizontal") { + dX$ = this.layout.width - 2 * _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"].padding - item.layout.width; + item.layout.width += dX$; + } + if (item.layout.sizing === "both" || item.layout.sizing === "vertical") { + dY$ = vExpandItems ? dY / vExpandItems : 0; + item.layout.height += dY$; + } + item.expand(dX$, dY$); + }); + return this; + } + offset() { + const { labelHeight, padding, spaceBetween } = _AbstractGroup__WEBPACK_IMPORTED_MODULE_0__["default"]; + const $left = padding; + let $top = padding + (this.isRoot ? 0 : labelHeight); + const { width } = this.layout; + this.items.forEach((item) => { + item.layout.offsetLeft = $left; + item.layout.offsetTop = $top; + item.layout.offsetLeft += (width - item.layout.width) / 2 - padding; + item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft; + item.layout.top = (this.layout.top || 0) + item.layout.offsetTop; + item.offset(); + $top += item.layout.height + spaceBetween; + }); + return this; + } +} + + +/***/ }), + +/***/ "./src/layout/VSlider.ts": +/*!*******************************!*\ + !*** ./src/layout/VSlider.ts ***! + \*******************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ VSlider) +/* harmony export */ }); +/* harmony import */ var _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AbstractInputItem */ "./src/layout/AbstractInputItem.ts"); + +class VSlider extends _AbstractInputItem__WEBPACK_IMPORTED_MODULE_0__["default"] { + constructor() { + super(...arguments); + this.layout = { + type: "vslider", + width: 1, + height: 5, + sizing: "vertical" + }; + } +} + + +/***/ }), + +/***/ "./src/components/Base.scss": +/*!**********************************!*\ + !*** ./src/components/Base.scss ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Button.scss": +/*!************************************!*\ + !*** ./src/components/Button.scss ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Checkbox.scss": +/*!**************************************!*\ + !*** ./src/components/Checkbox.scss ***! + \**************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Group.scss": +/*!***********************************!*\ + !*** ./src/components/Group.scss ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/HBargraph.scss": +/*!***************************************!*\ + !*** ./src/components/HBargraph.scss ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/HSlider.scss": +/*!*************************************!*\ + !*** ./src/components/HSlider.scss ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Knob.scss": +/*!**********************************!*\ + !*** ./src/components/Knob.scss ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Led.scss": +/*!*********************************!*\ + !*** ./src/components/Led.scss ***! + \*********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Menu.scss": +/*!**********************************!*\ + !*** ./src/components/Menu.scss ***! + \**********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Nentry.scss": +/*!************************************!*\ + !*** ./src/components/Nentry.scss ***! + \************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Numerical.scss": +/*!***************************************!*\ + !*** ./src/components/Numerical.scss ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Radio.scss": +/*!***********************************!*\ + !*** ./src/components/Radio.scss ***! + \***********************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/Soundfile.scss": +/*!***************************************!*\ + !*** ./src/components/Soundfile.scss ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/VBargraph.scss": +/*!***************************************!*\ + !*** ./src/components/VBargraph.scss ***! + \***************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/components/VSlider.scss": +/*!*************************************!*\ + !*** ./src/components/VSlider.scss ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }), + +/***/ "./src/index.scss": +/*!************************!*\ + !*** ./src/index.scss ***! + \************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!**********************!*\ + !*** ./src/index.ts ***! + \**********************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ FaustUI: () => (/* reexport safe */ _FaustUI__WEBPACK_IMPORTED_MODULE_0__["default"]), +/* harmony export */ instantiate: () => (/* reexport safe */ _instantiate__WEBPACK_IMPORTED_MODULE_1__["default"]) +/* harmony export */ }); +/* harmony import */ var _FaustUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FaustUI */ "./src/FaustUI.ts"); +/* harmony import */ var _instantiate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./instantiate */ "./src/instantiate.ts"); + + + +})(); + +var __webpack_exports__FaustUI = __webpack_exports__.FaustUI; +var __webpack_exports__instantiate = __webpack_exports__.instantiate; +export { __webpack_exports__FaustUI as FaustUI, __webpack_exports__instantiate as instantiate }; + +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/faust-ui/index.js.map b/docs/gamelan/sinusoide2/faust-ui/index.js.map new file mode 100644 index 0000000..09f3cc7 --- /dev/null +++ b/docs/gamelan/sinusoide2/faust-ui/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","mappings":";;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,yBAAyB,GAAG,qBAAqB;AACjD,qBAAqB;AACrB;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,UAAU;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,UAAU;AAC9B;AACA;AACA;AACA;AACA,wBAAwB,sBAAsB;AAC9C;AACA;AACA;AACA,wBAAwB,yBAAyB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,UAAU;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB,kBAAe;AACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzGqC;AAEE;AAGjB;AAeP,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAWzB,YAAY,SAAmB;AAV/B,wBAAwD,CAAC;AA4EzD;AAAA;AAAA;AAAA,2BAAkB,CAAC,MAAc,UAAkB;AAC/C,UAAI,CAAC,KAAK;AAAY;AACtB,WAAK,WAAW,YAAY,EAAE,MAAM,OAAO,MAAM,QAAQ,GAAG,GAAG;AAAA,IACnE;AApEI,UAAM,EAAE,MAAM,IAAI,MAAM,oBAAoB,oBAAoB,IAAI;AACpE,SAAK,UAAU;AACf,SAAK,KAAK,QAAQ,CAAC;AACnB,QAAI,OAAO,uBAAuB,eAAe,uBAAuB,MAAM;AAC1E,aAAO,iBAAiB,UAAU,MAAM;AACpC,aAAK,OAAO;AAAA,MAChB,CAAC;AAAA,IACL;AACA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A;;SAEA;SACA;;SAEA;SACA;SACA;;;;;UCtBA;UACA;UACA;UACA;UACA,yCAAyC,wCAAwC;UACjF;UACA;UACA;;;;;UCPA;;;;;UCAA;UACA;UACA;UACA,uDAAuD,iBAAiB;UACxE;UACA,gDAAgD,aAAa;UAC7D;;;;;;;;;;;;;;;;;ACN+C;AACQ","sources":["webpack://@shren/faust-ui/./node_modules/@shren/typed-event-emitter/dist/index.js","webpack://@shren/faust-ui/./src/FaustUI.ts","webpack://@shren/faust-ui/./src/components/AbstractComponent.ts","webpack://@shren/faust-ui/./src/components/AbstractItem.ts","webpack://@shren/faust-ui/./src/components/Button.ts","webpack://@shren/faust-ui/./src/components/Checkbox.ts","webpack://@shren/faust-ui/./src/components/Group.ts","webpack://@shren/faust-ui/./src/components/HBargraph.ts","webpack://@shren/faust-ui/./src/components/HSlider.ts","webpack://@shren/faust-ui/./src/components/Knob.ts","webpack://@shren/faust-ui/./src/components/Led.ts","webpack://@shren/faust-ui/./src/components/Menu.ts","webpack://@shren/faust-ui/./src/components/Nentry.ts","webpack://@shren/faust-ui/./src/components/Numerical.ts","webpack://@shren/faust-ui/./src/components/Radio.ts","webpack://@shren/faust-ui/./src/components/Soundfile.ts","webpack://@shren/faust-ui/./src/components/VBargraph.ts","webpack://@shren/faust-ui/./src/components/VSlider.ts","webpack://@shren/faust-ui/./src/components/utils.ts","webpack://@shren/faust-ui/./src/instantiate.ts","webpack://@shren/faust-ui/./src/layout/AbstractGroup.ts","webpack://@shren/faust-ui/./src/layout/AbstractInputItem.ts","webpack://@shren/faust-ui/./src/layout/AbstractItem.ts","webpack://@shren/faust-ui/./src/layout/AbstractOutputItem.ts","webpack://@shren/faust-ui/./src/layout/Button.ts","webpack://@shren/faust-ui/./src/layout/Checkbox.ts","webpack://@shren/faust-ui/./src/layout/HBargraph.ts","webpack://@shren/faust-ui/./src/layout/HGroup.ts","webpack://@shren/faust-ui/./src/layout/HSlider.ts","webpack://@shren/faust-ui/./src/layout/Knob.ts","webpack://@shren/faust-ui/./src/layout/Layout.ts","webpack://@shren/faust-ui/./src/layout/Led.ts","webpack://@shren/faust-ui/./src/layout/Menu.ts","webpack://@shren/faust-ui/./src/layout/Nentry.ts","webpack://@shren/faust-ui/./src/layout/Numerical.ts","webpack://@shren/faust-ui/./src/layout/Radio.ts","webpack://@shren/faust-ui/./src/layout/Soundfile.ts","webpack://@shren/faust-ui/./src/layout/TGroup.ts","webpack://@shren/faust-ui/./src/layout/VBargraph.ts","webpack://@shren/faust-ui/./src/layout/VGroup.ts","webpack://@shren/faust-ui/./src/layout/VSlider.ts","webpack://@shren/faust-ui/./src/components/Base.scss?7dde","webpack://@shren/faust-ui/./src/components/Button.scss?0477","webpack://@shren/faust-ui/./src/components/Checkbox.scss?c5fc","webpack://@shren/faust-ui/./src/components/Group.scss?02dc","webpack://@shren/faust-ui/./src/components/HBargraph.scss?1965","webpack://@shren/faust-ui/./src/components/HSlider.scss?9042","webpack://@shren/faust-ui/./src/components/Knob.scss?e43b","webpack://@shren/faust-ui/./src/components/Led.scss?9f37","webpack://@shren/faust-ui/./src/components/Menu.scss?9176","webpack://@shren/faust-ui/./src/components/Nentry.scss?1976","webpack://@shren/faust-ui/./src/components/Numerical.scss?f52f","webpack://@shren/faust-ui/./src/components/Radio.scss?89be","webpack://@shren/faust-ui/./src/components/Soundfile.scss?16d8","webpack://@shren/faust-ui/./src/components/VBargraph.scss?8274","webpack://@shren/faust-ui/./src/components/VSlider.scss?1848","webpack://@shren/faust-ui/./src/index.scss?a5de","webpack://@shren/faust-ui/webpack/bootstrap","webpack://@shren/faust-ui/webpack/runtime/define property getters","webpack://@shren/faust-ui/webpack/runtime/hasOwnProperty shorthand","webpack://@shren/faust-ui/webpack/runtime/make namespace object","webpack://@shren/faust-ui/./src/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.TypedEventEmitter = exports.$AnyEventType = void 0;\nexports.$AnyEventType = Symbol(\"__TypedEventListener_AnyEventType\");\nclass TypedEventEmitter {\n constructor() {\n this._listeners = { [exports.$AnyEventType]: [] };\n }\n get listeners() {\n return this._listeners;\n }\n getListeners(eventName) {\n if (!(eventName in this._listeners))\n this._listeners[eventName] = [];\n return this._listeners[eventName];\n }\n on(eventName, listener) {\n if (this.getListeners(eventName).indexOf(listener) === -1)\n this.getListeners(eventName).push(listener);\n }\n once(eventName, listener) {\n const listenerWithOff = (arg, emitter) => {\n const returnValue = listener(arg, emitter);\n this.off(eventName, listenerWithOff);\n return returnValue;\n };\n this.on(eventName, listenerWithOff);\n }\n onAny(listener) {\n this._listeners[exports.$AnyEventType].push(listener);\n }\n off(eventName, listener) {\n const i = this.getListeners(eventName).indexOf(listener);\n if (i !== -1)\n this.getListeners(eventName).splice(i, 1);\n }\n offAny(listener) {\n const i = this._listeners[exports.$AnyEventType].indexOf(listener);\n if (i !== -1)\n this._listeners[exports.$AnyEventType].splice(i, 1);\n }\n async emit(eventName, eventData, options) {\n var _a;\n let listeners = this.getListeners(eventName);\n let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType];\n if (!listeners.length && !anyListeners.length)\n return [];\n if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) {\n const { exclude } = options;\n listeners = listeners.filter(l => exclude.indexOf(l) === -1);\n anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1);\n }\n return Promise.all([...listeners.map(f => f(eventData, this)), ...anyListeners.map(f => f(eventName, eventData, this))]);\n }\n async emitSerial(eventName, eventData, options) {\n var _a;\n let listeners = this.getListeners(eventName);\n let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType];\n if (!listeners.length && !anyListeners.length)\n return [];\n if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) {\n const { exclude } = options;\n listeners = listeners.filter(l => exclude.indexOf(l) === -1);\n anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1);\n }\n const returnValues = [];\n for (let i = 0; i < listeners.length; i++) {\n const listener = listeners[i];\n returnValues[i] = await listener(eventData, this);\n }\n for (let i = 0; i < anyListeners.length; i++) {\n const listener = anyListeners[i];\n returnValues[listeners.length + i] = await listener(eventName, eventData, this);\n }\n return returnValues;\n }\n emitSync(eventName, eventData, options) {\n var _a;\n let listeners = this.getListeners(eventName);\n let anyListeners = (options === null || options === void 0 ? void 0 : options.excludeAny) ? [] : this._listeners[exports.$AnyEventType];\n if (!listeners.length && !anyListeners.length)\n return [];\n if ((_a = options === null || options === void 0 ? void 0 : options.exclude) === null || _a === void 0 ? void 0 : _a.length) {\n const { exclude } = options;\n listeners = listeners.filter(l => exclude.indexOf(l) === -1);\n anyListeners = anyListeners.filter(l => exclude.indexOf(l) === -1);\n }\n return [...listeners.map(f => f(eventData, this)), ...anyListeners.map(f => f(eventName, eventData, this))];\n }\n offAll(eventName) {\n if (eventName) {\n this._listeners[eventName] = [];\n }\n else {\n this._listeners = { [exports.$AnyEventType]: [] };\n }\n }\n listenerCount(eventName) {\n const anyListenerCount = this._listeners[exports.$AnyEventType].length;\n if (!(eventName in this._listeners))\n return anyListenerCount;\n return this._listeners[eventName].length + anyListenerCount;\n }\n}\nexports.TypedEventEmitter = TypedEventEmitter;\nexports.default = TypedEventEmitter;\n//# sourceMappingURL=index.js.map","import type { FaustUIDescriptor, FaustUIInputItem, FaustUIItem, FaustUIOutputItem } from \"@grame/faustwasm\";\nimport Layout from \"./layout/Layout\";\nimport AbstractItem from \"./components/AbstractItem\";\nimport Group from \"./components/Group\";\nimport type { FaustUIGroupProps } from \"./components/types\";\nimport type { LayoutProps } from \"./types\";\nimport \"./index.scss\";\n\ninterface IOptions {\n root: HTMLDivElement;\n ui?: FaustUIDescriptor;\n listenWindowResize?: boolean;\n listenWindowMessage?: boolean;\n}\n\n/**\n * The main class of UI constructor,\n * listening to `resize` window event to resize component,\n * listening to `message` window event to change UI or param value.\n * See readme.\n */\nexport default class FaustUI {\n componentMap: { [path: string]: AbstractItem[] } = {};\n DOMroot: HTMLDivElement;\n faustUIRoot: Group;\n hostWindow: Window;\n grid: number;\n private _ui: FaustUIItem[];\n private _layout: LayoutProps;\n /**\n * Calculate incoming UI's layout, bind window events\n */\n constructor(options: IOptions) {\n const { root, ui: uiIn, listenWindowResize, listenWindowMessage } = options;\n this.DOMroot = root;\n this.ui = uiIn || [];\n if (typeof listenWindowResize === \"undefined\" || listenWindowResize === true) {\n window.addEventListener(\"resize\", () => {\n this.resize();\n });\n }\n if (typeof listenWindowMessage === \"undefined\" || listenWindowMessage === true) {\n window.addEventListener(\"message\", (e) => {\n const { data, source } = e;\n this.hostWindow = source as Window;\n const { type } = data;\n if (!type) return;\n if (type === \"ui\") {\n this.ui = data.ui;\n } else if (type === \"param\") {\n const { path, value } = data;\n this.paramChangeByDSP(path, value);\n }\n });\n }\n }\n /**\n * Render the UI to DOM root\n */\n mount() {\n this.componentMap = {};\n this.DOMroot.innerHTML = \"\";\n const props: FaustUIGroupProps = {\n label: \"\",\n type: \"vgroup\",\n items: this.ui,\n style: {\n grid: this.grid,\n width: this.layout.width,\n height: this.layout.height,\n left: this.layout.offsetLeft,\n top: this.layout.offsetTop\n },\n isRoot: true,\n emitter: this\n };\n this.faustUIRoot = new Group(props);\n this.faustUIRoot.componentWillMount();\n this.faustUIRoot.mount();\n this.DOMroot.appendChild(this.faustUIRoot.container);\n this.faustUIRoot.componentDidMount();\n }\n /**\n * This method should be called by components to register itself to map.\n */\n register(path: string, item: AbstractItem) {\n if (this.componentMap[path]) this.componentMap[path].push(item);\n else this.componentMap[path] = [item];\n }\n /**\n * Notify the component to change its value.\n */\n paramChangeByDSP(path: string, value: number) {\n if (this.componentMap[path]) this.componentMap[path].forEach(item => item.setState({ value }));\n }\n /**\n * Can be overriden, called by components when its value is changed by user.\n */\n paramChangeByUI = (path: string, value: number) => {\n if (!this.hostWindow) return;\n this.hostWindow.postMessage({ path, value, type: \"param\" }, \"*\");\n };\n /**\n * Calculate UI layout in grid then calculate grid size.\n */\n calc() {\n const { items, layout } = Layout.calc(this.ui);\n this._ui = items;\n this._layout = layout;\n this.calcGrid();\n }\n /**\n * Calculate grid size by DOM root size and layout size in grids.\n */\n calcGrid() {\n const { width, height } = this.DOMroot.getBoundingClientRect();\n const grid = Math.max(40, Math.min(width / this._layout.width, height / this._layout.height));\n this.grid = grid;\n return grid;\n }\n /**\n * Force recalculate grid size and resize UI\n */\n resize() {\n if (!this.faustUIRoot) return;\n this.calcGrid();\n this.faustUIRoot.setState({ style: { grid: this.grid } });\n }\n /** Filter out items with `hidden` metadata and `soundfile` items */\n filter(ui: FaustUIItem[]) {\n const callback = (items: FaustUIItem[], item: FaustUIItem) => {\n if (item.type === \"soundfile\") return items;\n if (item.type === \"hgroup\" || item.type === \"vgroup\" || item.type === \"tgroup\") {\n items.push({ ...item, items: item.items.reduce(callback, [] as FaustUIItem[]) });\n return items;\n }\n if ((item as FaustUIInputItem | FaustUIOutputItem).meta?.find(m => m.hidden && m.hidden === \"1\")) return items;\n items.push(item);\n return items;\n }\n return ui.reduce(callback, []);\n }\n get ui() {\n return this._ui;\n }\n set ui(uiIn) {\n this._ui = this.filter(uiIn);\n this.calc();\n this.mount();\n }\n get layout() {\n return this._layout;\n }\n get minWidth() {\n return this._layout.width * 40 + 1;\n }\n get minHeight() {\n return this._layout.height * 40 + 1;\n }\n}\n","import TypedEventEmitter from \"@shren/typed-event-emitter\";\n\nexport default abstract class AbstractComponent extends TypedEventEmitter {\n /**\n * The default state of the component.\n */\n static defaultProps: Record = {};\n get defaultProps() {\n return (this.constructor as typeof AbstractComponent).defaultProps as T;\n }\n /**\n * Here stores corrent state of component\n * change the state with `setState` method to fire state events\n * then UI parts will get notified and rerender\n */\n state: T;\n /**\n * Frame count in order to reduce frame rate\n */\n private $frame = 0;\n /**\n * Frame reducing factor, 1 = render at every browser rendering tick, 2 will skip one every two ticks.\n */\n frameReduce = 1;\n /**\n * Here stores current `requestAnimationFrame` reference\n * if we have a new state to render, we cancel the old one\n */\n private $raf: number;\n /**\n * `requestAnimationFrame` callback\n */\n private raf = () => {\n this.$frame++;\n if (this.$frame % this.frameReduce !== 0) {\n this.$raf = window.requestAnimationFrame(this.raf);\n return;\n }\n this.$raf = undefined;\n this.tasks.forEach(f => f());\n this.tasks = [];\n };\n /**\n * tasks to execute in next redering tick\n */\n private tasks: (() => any)[] = [];\n /**\n * Initiate default state with incoming state.\n */\n constructor(props?: T) {\n super();\n this.state = { ...this.defaultProps, ...props };\n }\n /**\n * set internal state and fire events for UI parts subscribed\n */\n setState(newState: Partial) {\n let shouldUpdate = false;\n for (const stateKey in newState) {\n const stateValue = newState[stateKey];\n if (stateKey in this.state && this.state[stateKey] !== stateValue) {\n this.state[stateKey] = stateValue;\n shouldUpdate = true;\n } else return;\n if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);\n }\n }\n /**\n * Use this method to request a new rendering\n * schedule what you need to do in next render tick in `raf` callback\n */\n schedule(func: () => any) {\n if (this.tasks.indexOf(func) === -1) this.tasks.push(func);\n if (this.$raf) return;\n this.$raf = window.requestAnimationFrame(this.raf);\n }\n}\n","import AbstractComponent from \"./AbstractComponent\";\nimport { normalize, normExp, normLog } from \"./utils\";\nimport type { FaustUIItemStyle, FaustUIItemProps, PointerDownEvent as MouseOrTouchDownEvent, PointerDragEvent as MouseOrTouchMoveEvent, PointerUpEvent as MouseOrTouchUpEvent } from \"./types\";\nimport \"./Base.scss\";\n\n/**\n * Abstract class that describes a FaustUI Component\n * this is an event emitter that emits every state change to inform UI renderer parts\n * Each UI parts could subscribe to a specific state such as `value`, `min`, `max` or `style`\n * when the event subscribed is fired, this part of ui updated using its own handler without updating the rest of UI parts\n * the types of events is restricted to the same as keys of `state` object:\n * `state` object is a `FaustUIItemProps` with a `style` object that contains `T` defined by child class.\n * Child class can override life cycle methods\n * `componentWillMount` prepare data before DOM get loads to page\n * `mount` get DOMs append to page\n * `componentDidMount` Now draw canvas etc.\n */\nexport default abstract class AbstractItem extends AbstractComponent> {\n /**\n * The default state of the component.\n */\n static defaultProps: FaustUIItemProps = {\n value: 0,\n active: true,\n focus: false,\n label: \"\",\n address: \"\",\n min: 0,\n max: 1,\n enums: {},\n type: \"float\",\n unit: \"\",\n scale: \"linear\",\n step: 0.01,\n style: { width: 45, height: 15, left: 0, top: 0, labelcolor: \"rgba(226, 222, 255, 0.5)\" }\n };\n /**\n * DOM Div container of the component\n */\n container: HTMLDivElement;\n /**\n * DOM Div container of label canvas\n */\n label: HTMLDivElement;\n /**\n * Use canvas as label to fit full text in.\n */\n labelCanvas: HTMLCanvasElement;\n labelCtx: CanvasRenderingContext2D;\n /**\n * Override this to get css work\n */\n className: string;\n frameReduce = 3;\n /**\n * Default DOM event listeners, unify mousedown and touchstart events\n * For mouse or touch events, please use `handlePointerDown` `handlePointerUp` `handlePointerDrag` callbacks\n */\n handleKeyDown = (e: KeyboardEvent) => {};\n handleKeyUp = (e: KeyboardEvent) => {};\n handleTouchStart = (e: TouchEvent) => {\n e.preventDefault();\n const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let prevX = e.touches[0].clientX;\n let prevY = e.touches[0].clientY;\n const fromX = prevX - rect.left;\n const fromY = prevY - rect.top;\n const prevValue = this.state.value;\n this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e });\n const handleTouchMove = (e: TouchEvent) => {\n e.preventDefault();\n const clientX = e.changedTouches[0].clientX;\n const clientY = e.changedTouches[0].clientY;\n const movementX = clientX - prevX;\n const movementY = clientY - prevY;\n prevX = clientX;\n prevY = clientY;\n const x = clientX - rect.left;\n const y = clientY - rect.top;\n this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX, movementY, originalEvent: e });\n };\n const handleTouchEnd = (e: TouchEvent) => {\n e.preventDefault();\n const x = e.changedTouches[0].clientX - rect.left;\n const y = e.changedTouches[0].clientY - rect.top;\n this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e });\n document.removeEventListener(\"touchmove\", handleTouchMove);\n document.removeEventListener(\"touchend\", handleTouchEnd);\n };\n document.addEventListener(\"touchmove\", handleTouchMove, { passive: false });\n document.addEventListener(\"touchend\", handleTouchEnd, { passive: false });\n };\n handleWheel = (e: WheelEvent) => {};\n handleClick = (e: MouseEvent) => {};\n handleMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n (e.currentTarget as HTMLElement).focus();\n const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n const fromX = e.clientX - rect.left;\n const fromY = e.clientY - rect.top;\n const prevValue = this.state.value;\n this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e });\n const handleMouseMove = (e: MouseEvent) => {\n e.preventDefault();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX: e.movementX, movementY: e.movementY, originalEvent: e });\n };\n const handleMouseUp = (e: MouseEvent) => {\n e.preventDefault();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e });\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n };\n handleMouseOver = (e: MouseEvent) => {};\n handleMouseOut = (e: MouseEvent) => {};\n handleContextMenu = (e: MouseEvent) => {};\n handlePointerDown = (e: PointerEvent) => {\n e.preventDefault();\n (e.currentTarget as HTMLElement).focus();\n const { pointerId } = e;\n const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n const fromX = e.clientX - rect.left;\n const fromY = e.clientY - rect.top;\n const prevValue = this.state.value;\n this.handleMouseOrTouchDown({ pointerId, x: fromX, y: fromY, originalEvent: e });\n const handlePointerMove = (e: PointerEvent) => {\n if (e.pointerId !== pointerId) return;\n e.preventDefault();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n this.handleMouseOrTouchMove({ pointerId, prevValue, x, y, fromX, fromY, movementX: e.movementX, movementY: e.movementY, originalEvent: e });\n };\n const handlePointerUp = (e: PointerEvent) => {\n if (e.pointerId !== pointerId) return;\n e.preventDefault();\n const x = e.clientX - rect.left;\n const y = e.clientY - rect.top;\n this.handleMouseOrTouchUp({ pointerId, x, y, originalEvent: e });\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n };\n document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n \n };\n handleMouseOrTouchDown = (e: MouseOrTouchDownEvent) => {};\n handleMouseOrTouchMove = (e: MouseOrTouchMoveEvent) => {};\n handleMouseOrTouchUp = (e: MouseOrTouchUpEvent) => {};\n handleFocusIn = (e: FocusEvent) => this.setState({ focus: true });\n handleFocusOut = (e: FocusEvent) => this.setState({ focus: false });\n\n /**\n * Initiate default state with incoming state.\n */\n constructor(props?: FaustUIItemProps) {\n super(props);\n this.state.style = { ...this.defaultProps.style, ...props.style };\n if (this.state.emitter) this.state.emitter.register(this.state.address, this);\n }\n /**\n * Get a nearest valid number\n */\n toValidNumber(value: number) {\n const { min, max, step } = this.state;\n if (typeof min !== \"number\" || typeof max !== \"number\") return value;\n const v = Math.min(max, Math.max(min, value));\n if (!step) return v;\n return min + Math.floor((v - min) / step) * step;\n }\n /**\n * Use this method if you want the emitter to send value to DSP\n */\n setValue(valueIn: number) {\n const value = this.toValidNumber(valueIn);\n const changed = this.setState({ value });\n if (changed) this.change(value);\n return changed;\n }\n /**\n * Send value to DSP\n */\n change(valueIn?: number) {\n if (this.state.emitter) this.state.emitter.paramChangeByUI(this.state.address, typeof valueIn === \"number\" ? valueIn : this.state.value);\n }\n /**\n * set internal state and fire events for UI parts subscribed\n * This will not send anything to DSP\n * @returns is state updated\n */\n setState(newState: { [key in keyof FaustUIItemProps]?: FaustUIItemProps[key] }) {\n let shouldUpdate = false;\n for (const key in newState) {\n const stateKey = key as keyof FaustUIItemProps;\n const stateValue = newState[stateKey];\n if (stateKey === \"style\") {\n for (const styleKey in newState.style) {\n if (styleKey in this.state.style /* Fix hidden -> canvas not rendered bug && this.state.style[styleKey] !== newState.style[styleKey] */) {\n this.state.style[styleKey] = newState.style[styleKey];\n shouldUpdate = true;\n }\n }\n } else if (stateKey in this.state && this.state[stateKey] !== stateValue) {\n (this.state as any)[stateKey] = stateValue;\n shouldUpdate = true;\n } else return false;\n if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);\n }\n return shouldUpdate;\n }\n /**\n * Create container with class name\n * override it with `super.componentWillMount();`\n */\n componentWillMount() {\n this.container = document.createElement(\"div\");\n this.container.className = [\"faust-ui-component\", \"faust-ui-component-\" + this.className].join(\" \");\n this.container.tabIndex = 1;\n this.container.id = this.state.address;\n if (this.state.tooltip) this.container.title = this.state.tooltip;\n this.label = document.createElement(\"div\");\n this.label.className = \"faust-ui-component-label\";\n this.labelCanvas = document.createElement(\"canvas\");\n this.labelCtx = this.labelCanvas.getContext(\"2d\");\n return this;\n }\n /**\n * Here append all child DOM to container\n */\n mount() {\n this.label.appendChild(this.labelCanvas);\n return this;\n }\n paintLabel(align?: CanvasTextAlign) {\n const label = this.state.label;\n const color = this.state.style.labelcolor;\n const ctx = this.labelCtx;\n const canvas = this.labelCanvas;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.label.getBoundingClientRect();\n if (!width || !height) return this;\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n ctx.clearRect(0, 0, width, height);\n ctx.fillStyle = color;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = align || \"center\";\n ctx.font = `bold ${height * 0.9}px -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"`;\n ctx.fillText(label, align === \"left\" ? 0 : align === \"right\" ? width : width / 2, height / 2, width);\n return this;\n }\n /**\n * will call this method when mounted\n */\n componentDidMount() {\n const handleResize = () => {\n const { grid, left, top, width, height } = this.state.style;\n this.container.style.width = `${width * grid}px`;\n this.container.style.height = `${height * grid}px`;\n this.container.style.left = `${left * grid}px`;\n this.container.style.top = `${top * grid}px`;\n this.label.style.height = `${grid * 0.25}px`;\n this.paintLabel();\n };\n this.on(\"style\", () => this.schedule(handleResize));\n handleResize();\n return this;\n }\n /**\n * Count steps in range min-max with step\n */\n get stepsCount() {\n const { type, max, min, step, enums } = this.state;\n const maxSteps = type === \"enum\" ? enums.length : type === \"int\" ? max - min : (max - min) / step;\n if (step) {\n if (type === \"enum\") return enums.length;\n if (type === \"int\") return Math.min(Math.floor((max - min) / (Math.round(step) || 1)), maxSteps);\n return Math.floor((max - min) / step);\n }\n return maxSteps;\n }\n /**\n * Normalized value between 0 - 1.\n */\n get distance() {\n const { type, max, min, value, enums, scale } = this.state;\n return AbstractItem.getDistance({ type, max, min, value, enums, scale });\n }\n static getDistance(state: { value: number; min: number; max: number; enums?: { [key: string]: number }; type: \"enum\" | \"int\" | \"float\"; scale: \"linear\" | \"exp\" | \"log\" }) {\n const { type, max, min, value, enums, scale } = state;\n if (type === \"enum\") return value / (enums.length - 1);\n const v = scale === \"exp\" ? normLog(value, min, max) : scale === \"log\" ? normExp(value, min, max) : value;\n return normalize(v, min, max);\n }\n /**\n * Mousemove pixels for each step\n */\n get stepRange() {\n const full = 100;\n const stepsCount = this.stepsCount;\n return full / stepsCount;\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemStyle, FaustUIItemProps } from \"./types\";\nimport \"./Button.scss\";\n\nexport interface FaustUIButtonStyle extends FaustUIItemStyle {\n fontname?: string;\n fontsize?: number;\n fontface?: \"normal\" | \"bold\" | \"italic\" | \"bold italic\";\n bgcolor?: string;\n bgoncolor?: string;\n bordercolor?: string;\n borderoncolor?: string;\n textcolor?: string;\n textoncolor?: string;\n}\nexport default class Button extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"normal\",\n bgcolor: \"rgba(40, 40, 40, 1)\",\n bgoncolor: \"rgba(18, 18, 18, 1)\",\n bordercolor: \"rgba(80, 80, 80, 1)\",\n borderoncolor: \"rgba(255, 165, 0, 1)\",\n textcolor: \"rgba(226, 222, 255, 0.5)\",\n textoncolor: \"rgba(255, 165, 0, 1)\"\n }\n };\n }\n className = \"button\";\n\n btn: HTMLDivElement;\n span: HTMLSpanElement;\n componentWillMount() {\n super.componentWillMount();\n this.btn = document.createElement(\"div\");\n this.span = document.createElement(\"span\");\n this.span.innerText = this.state.label;\n this.setStyle();\n return this;\n }\n setStyle = () => {\n const { value, style } = this.state;\n const { height, grid, fontsize, fontname, fontface, textcolor, textoncolor, bgoncolor, bgcolor, bordercolor, borderoncolor } = style;\n this.btn.style.backgroundColor = value ? bgoncolor : bgcolor;\n this.btn.style.borderColor = value ? borderoncolor : bordercolor;\n this.btn.style.color = value ? textoncolor : textcolor;\n this.btn.style.fontSize = `${fontsize || height * grid / 4}px`;\n this.btn.style.fontFamily = `${fontname}, sans-serif`;\n this.btn.style.fontStyle = fontface;\n };\n mount() {\n this.btn.appendChild(this.span);\n this.container.appendChild(this.btn);\n return super.mount();\n }\n componentDidMount() {\n super.componentDidMount();\n this.btn.addEventListener(\"pointerdown\", this.handlePointerDown);\n this.btn.addEventListener(\"contextmenu\", this.handleContextMenu);\n // this.btn.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.btn.addEventListener(\"touchstart\", this.handleTouchStart);\n this.on(\"style\", () => this.schedule(this.setStyle));\n const labelChange = () => this.span.innerText = this.state.label;\n this.on(\"label\", () => this.schedule(labelChange));\n this.on(\"value\", () => this.schedule(this.setStyle));\n return this;\n }\n handleContextMenu = (e: MouseEvent) => {\n e.preventDefault();\n };\n handleMouseOrTouchDown = () => {\n this.setValue(1);\n };\n handleMouseOrTouchUp = () => {\n this.setValue(0);\n };\n}\n","import Button from \"./Button\";\nimport \"./Checkbox.scss\";\n\nexport default class Checkbox extends Button {\n className = \"checkbox\";\n\n handleMouseOrTouchDown = () => {\n this.setValue(1 - this.state.value);\n };\n handleMouseOrTouchUp = () => {\n };\n}\n","import type { FaustUIMeta } from \"@grame/faustwasm\";\nimport AbstractComponent from \"./AbstractComponent\";\nimport AbstractItem from \"./AbstractItem\";\nimport HSlider from \"./HSlider\";\nimport VSlider from \"./VSlider\";\nimport Nentry from \"./Nentry\";\nimport Soundfile from \"./Soundfile\";\nimport Button from \"./Button\";\nimport Checkbox from \"./Checkbox\";\nimport Knob from \"./Knob\";\nimport Menu from \"./Menu\";\nimport Radio from \"./Radio\";\nimport Led from \"./Led\";\nimport Numerical from \"./Numerical\";\nimport HBargraph from \"./HBargraph\";\nimport VBargraph from \"./VBargraph\";\nimport Layout from \"../layout/Layout\";\nimport type FaustUI from \"../FaustUI\";\nimport type LayoutAbstractGroup from \"../layout/AbstractGroup\";\nimport type LayoutAbstractInputItem from \"../layout/AbstractInputItem\";\nimport type LayoutAbstractOutputItem from \"../layout/AbstractOutputItem\";\nimport type { FaustUIItemProps, FaustUIItemStyle, FaustUIGroupProps } from \"./types\";\nimport type { LayoutProps } from \"../types\";\nimport \"./Group.scss\";\n\nexport interface GroupProps extends FaustUIGroupProps {\n items?: (LayoutAbstractGroup | LayoutAbstractInputItem | LayoutAbstractOutputItem)[];\n}\nexport default class Group extends AbstractComponent {\n static parseMeta(metaIn: FaustUIMeta[]): { metaObject: FaustUIMeta; enums?: { [key: string]: number } } {\n const metaObject: FaustUIMeta = {};\n if (!metaIn) return { metaObject };\n metaIn.forEach(m => Object.assign(metaObject, m));\n if (metaObject.style) {\n const enumsRegex = /\\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\\.?[0-9]+?);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\\.?[0-9]+?))\\}/;\n const matched = metaObject.style.match(enumsRegex);\n if (matched) {\n const itemsRegex = /(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\\.?[0-9]+?))/g;\n const enums: { [key: string]: number } = {};\n let item;\n // eslint-disable-next-line no-cond-assign\n while (item = itemsRegex.exec(matched[0])) {\n enums[item[1]] = +item[2];\n }\n return { metaObject, enums };\n }\n }\n return { metaObject };\n }\n static getComponent(item: LayoutAbstractGroup | LayoutAbstractInputItem | LayoutAbstractOutputItem, emitter: FaustUI, grid: number) {\n const type = Layout.predictType(item);\n if (type.endsWith(\"group\")) {\n const { label, items, type, layout } = item as LayoutAbstractGroup;\n const props: GroupProps = {\n label,\n type,\n items,\n style: {\n grid,\n width: layout.width,\n height: layout.height,\n left: layout.offsetLeft,\n top: layout.offsetTop,\n labelcolor: \"rgba(255, 255, 255, 0.7)\"\n },\n emitter\n };\n return new Group(props);\n }\n const ioItem = item as LayoutAbstractInputItem | LayoutAbstractOutputItem;\n const { metaObject, enums } = this.parseMeta(ioItem.meta);\n const { tooltip, unit, scale } = metaObject;\n const { label, min, max, address, layout } = ioItem;\n const props: FaustUIItemProps = {\n label,\n address,\n tooltip,\n unit,\n scale: scale || \"linear\",\n emitter,\n enums,\n style: {\n grid,\n width: layout.width,\n height: layout.height,\n left: layout.offsetLeft,\n top: layout.offsetTop\n },\n type: \"float\",\n min: isFinite(min) ? min : 0,\n max: isFinite(max) ? max : 1,\n step: \"step\" in item ? +item.step : 1,\n value: \"init\" in item ? +item.init || 0 : 0\n };\n if (type === \"button\") return new Button(props);\n if (type === \"checkbox\") return new Checkbox(props);\n if (type === \"nentry\") return new Nentry(props);\n if (type === \"soundfile\") return new Soundfile(props);\n if (type === \"knob\") return new Knob(props);\n if (type === \"menu\") return new Menu(props);\n if (type === \"radio\") return new Radio(props);\n if (type === \"hslider\") return new HSlider(props);\n if (type === \"vslider\") return new VSlider(props);\n if (type === \"hbargraph\") return new HBargraph(props);\n if (type === \"vbargraph\") return new VBargraph(props);\n if (type === \"numerical\") return new Numerical(props);\n if (type === \"led\") return new Led(props);\n return null;\n }\n /**\n * DOM Div container of the group\n */\n container: HTMLDivElement;\n /**\n * DOM Div container of label canvas\n */\n label: HTMLDivElement;\n /**\n * Use canvas as label to fit full text in.\n */\n labelCanvas: HTMLCanvasElement;\n labelCtx: CanvasRenderingContext2D;\n tabs: HTMLDivElement;\n children: (AbstractItem | Group)[];\n layout: LayoutProps;\n setState(newState: { [key in keyof FaustUIGroupProps]?: FaustUIGroupProps[key] }) {\n let shouldUpdate = false;\n for (const key in newState) {\n const stateKey = key as keyof FaustUIGroupProps;\n const stateValue = newState[stateKey];\n if (stateKey === \"style\") {\n for (const key in newState.style) {\n const styleKey = key as keyof FaustUIItemStyle;\n if (styleKey in this.state.style /* Fix hidden -> canvas not rendered bug && this.state.style[styleKey] !== newState.style[styleKey] */) {\n (this.state.style as any)[styleKey] = newState.style[styleKey];\n shouldUpdate = true;\n }\n }\n } else if (stateKey in this.state && this.state[stateKey] !== stateValue) {\n (this.state as any)[stateKey] = stateValue;\n shouldUpdate = true;\n } else return;\n if (shouldUpdate) this.emit(stateKey, this.state[stateKey]);\n }\n }\n componentWillMount() {\n this.container = document.createElement(\"div\");\n this.tabs = document.createElement(\"div\");\n this.tabs.className = \"faust-ui-tgroup-tabs\";\n if (!this.state.isRoot) {\n this.label = document.createElement(\"div\");\n this.label.className = \"faust-ui-group-label\";\n this.labelCanvas = document.createElement(\"canvas\");\n this.labelCtx = this.labelCanvas.getContext(\"2d\");\n }\n this.updateUI();\n this.children.forEach(item => item.componentWillMount());\n return this;\n }\n paintLabel() {\n if (this.state.isRoot) return this;\n const label = this.state.label;\n const color = this.state.style.labelcolor;\n const ctx = this.labelCtx;\n const canvas = this.labelCanvas;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.label.getBoundingClientRect();\n if (!width || !height) return this;\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n ctx.clearRect(0, 0, width, height);\n ctx.fillStyle = color;\n ctx.textBaseline = \"middle\";\n ctx.textAlign = \"left\";\n ctx.font = `bold ${height * 0.9}px -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"`;\n ctx.fillText(label, 0, height / 2, width);\n return this;\n }\n updateUI = () => {\n this.children = [];\n const { style, type, items, emitter, isRoot } = this.state as GroupProps;\n const { grid, left, top, width, height } = style;\n if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;\n this.container.style.left = `${left * grid}px`;\n this.container.style.top = `${top * grid}px`;\n this.container.style.width = `${width * grid}px`;\n this.container.style.height = `${height * grid}px`;\n this.container.className = [\"faust-ui-group\", `faust-ui-${type}`, `${isRoot ? \"faust-ui-root\" : \"\"}`].join(\" \");\n items.forEach((item) => {\n if (item.type.endsWith(\"group\")) {\n const component = Group.getComponent(item, emitter, grid);\n if (component) this.children.push(component);\n } else {\n const ioItem = item as LayoutAbstractInputItem | LayoutAbstractOutputItem;\n const itemComponent = Group.getComponent(ioItem, this.state.emitter, grid);\n if (itemComponent) this.children.push(itemComponent);\n }\n });\n if (type === \"tgroup\") {\n this.tabs.innerHTML = \"\";\n this.tabs.style.height = `${grid}px`;\n this.tabs.style.top = `${0.25 * grid}px`;\n this.state.items.forEach((item, i) => {\n const label = item.label;\n const tab = document.createElement(\"span\");\n tab.innerText = label;\n tab.className = \"faust-ui-tgroup-tab\";\n tab.style.fontSize = `${0.25 * grid}px`;\n tab.style.width = `${2 * grid - 20}px`;\n tab.style.height = `${grid - 20}px`;\n tab.style.lineHeight = `${grid - 20}px`;\n tab.addEventListener(\"click\", () => {\n const groups: HTMLDivElement[] = [];\n for (let j = 0; j < this.container.children.length; j++) {\n const element = this.container.children[j] as HTMLDivElement;\n if (j > 1) groups.push(element);\n }\n for (let j = 0; j < groups.length; j++) {\n const element = groups[j] as HTMLDivElement;\n element.style.visibility = i === j ? \"visible\" : \"hidden\";\n }\n for (let j = 0; j < this.tabs.children.length; j++) {\n const e = this.tabs.children[j];\n if (i !== j) {\n if (e.classList.contains(\"active\")) e.classList.remove(\"active\");\n } else e.classList.add(\"active\");\n }\n });\n this.tabs.appendChild(tab);\n });\n }\n };\n mount() {\n if (!this.state.isRoot) {\n this.label.appendChild(this.labelCanvas);\n this.container.appendChild(this.label);\n }\n if (this.tabs.children.length) this.container.appendChild(this.tabs);\n this.children.forEach((item) => {\n item.mount();\n this.container.appendChild(item.container);\n });\n return this;\n }\n componentDidMount() {\n const handleResize = () => {\n const { grid, left, top, width, height } = this.state.style;\n if (!this.state.isRoot) this.label.style.height = `${grid * 0.3}px`;\n this.container.style.width = `${width * grid}px`;\n this.container.style.height = `${height * grid}px`;\n this.container.style.left = `${left * grid}px`;\n this.container.style.top = `${top * grid}px`;\n if (this.state.type === \"tgroup\") {\n this.tabs.style.height = `${grid}px`;\n this.tabs.style.top = `${0.25 * grid}px`;\n for (let i = 0; i < this.tabs.children.length; i++) {\n const tab = this.tabs.children[i] as HTMLSpanElement;\n tab.style.fontSize = `${0.25 * grid}px`;\n tab.style.width = `${2 * grid - 20}px`;\n tab.style.height = `${grid - 20}px`;\n tab.style.lineHeight = `${grid - 20}px`;\n }\n }\n this.paintLabel();\n this.children.forEach(item => item.setState({ style: { grid } }));\n };\n this.on(\"style\", () => this.schedule(handleResize));\n const itemsChange = () => {\n this.updateUI();\n this.children.forEach(item => item.componentWillMount());\n };\n this.on(\"items\", () => this.schedule(itemsChange));\n const labelChange = () => {\n this.paintLabel();\n this.label.title = this.state.label;\n };\n this.on(\"label\", () => this.schedule(labelChange));\n this.paintLabel();\n if (this.tabs?.children.length) (this.tabs.children[0] as HTMLSpanElement).click();\n this.children.forEach(item => item.componentDidMount());\n return this;\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport VBargraph from \"./VBargraph\";\nimport \"./HBargraph.scss\";\n\nexport default class HBargraph extends VBargraph {\n className = \"hbargraph\";\n\n paintLabel() {\n return super.paintLabel(\"left\");\n }\n setStyle = () => {\n const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n this.input.style.fontSize = `${fontsize || height * grid * 0.2}px`;\n this.input.style.color = textcolor;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n paint = () => {\n const { barwidth, barbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style;\n const { type, max, min, enums, scale, value } = this.state;\n const ctx = this.ctx;\n const canvas = this.canvas;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.canvasDiv.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const drawWidth = width * 0.9;\n const drawHeight = barwidth || Math.min(height / 3, drawWidth * 0.05);\n const left = width * 0.05;\n const top = (height - drawHeight) * 0.5;\n this.paintValue = value;\n const paintValue = this.paintValue;\n if (paintValue > this.maxValue) {\n this.maxValue = paintValue;\n if (this.maxTimer) window.clearTimeout(this.maxTimer);\n this.maxTimer = window.setTimeout(() => {\n this.maxValue = this.paintValue;\n this.maxTimer = undefined;\n this.schedule(this.paint);\n }, 1000);\n }\n if (paintValue < this.maxValue && typeof this.maxTimer === \"undefined\") {\n this.maxTimer = window.setTimeout(() => {\n this.maxValue = this.paintValue;\n this.maxTimer = undefined;\n this.schedule(this.paint);\n }, 1000);\n }\n const maxValue = this.maxValue;\n const coldStop = (-18 - min) / (max - min);\n const warmStop = (-6 - min) / (max - min);\n const hotStop = (-3 - min) / (max - min);\n const overloadStop = Math.max(0, -min / (max - min));\n const gradient = ctx.createLinearGradient(left, 0, drawWidth, 0);\n if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);\n else if (coldStop > 1) gradient.addColorStop(1, coldcolor);\n if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);\n if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);\n if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);\n else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);\n\n ctx.fillStyle = barbgcolor;\n if (paintValue < 0) ctx.fillRect(left, top, drawWidth * overloadStop, drawHeight);\n if (paintValue < max) ctx.fillRect(left + drawWidth * overloadStop + 1, top, drawWidth * (1 - overloadStop) - 1, drawHeight);\n ctx.fillStyle = gradient;\n if (paintValue > min) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));\n ctx.fillRect(left, top, distance * drawWidth, drawHeight);\n }\n if (paintValue > 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(max, paintValue) }) - overloadStop);\n ctx.fillRect(left + overloadStop * drawWidth + 1, top, distance * drawWidth - 1, drawHeight);\n }\n if (maxValue > paintValue) {\n if (maxValue <= 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(0, maxValue) }));\n ctx.fillRect(left + distance * drawWidth - 1, top, 1, drawHeight);\n }\n if (maxValue > 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(max, maxValue) }) - overloadStop);\n ctx.fillRect(left + Math.min(drawWidth - 1, (overloadStop + distance) * drawWidth), top, 1, drawHeight);\n }\n }\n };\n}\n","import { fillRoundedRect } from \"./utils\";\nimport VSlider from \"./VSlider\";\nimport \"./HSlider.scss\";\n\nexport default class HSlider extends VSlider {\n className = \"hslider\";\n\n paintLabel() {\n return super.paintLabel(\"left\");\n }\n setStyle = () => {\n const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n this.input.style.fontSize = `${fontsize || height * grid * 0.2}px`;\n this.input.style.color = textcolor;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n paint = () => {\n const { sliderwidth, sliderbgcolor, sliderbgoncolor, slidercolor } = this.state.style;\n const ctx = this.ctx;\n const canvas = this.canvas;\n const distance = this.distance;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.canvasDiv.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const drawWidth = width * 0.9;\n const drawHeight = sliderwidth || Math.min(height / 3, drawWidth * 0.05);\n const left = width * 0.05;\n const top = (height - drawHeight) * 0.5;\n const borderRadius = drawHeight * 0.25;\n this.interactionRect = [left, 0, drawWidth, height];\n const grd = ctx.createLinearGradient(left, 0, left + drawWidth, 0);\n grd.addColorStop(Math.max(0, Math.min(1, distance)), sliderbgoncolor);\n grd.addColorStop(Math.max(0, Math.min(1, distance)), sliderbgcolor);\n ctx.fillStyle = grd;\n fillRoundedRect(ctx, left, top, drawWidth, drawHeight, borderRadius);\n // draw slider\n ctx.fillStyle = slidercolor;\n fillRoundedRect(ctx, left + drawWidth * distance - drawHeight, top - drawHeight, drawHeight * 2, drawHeight * 3, borderRadius);\n };\n}\n","import AbstractItem from \"./AbstractItem\";\nimport { toRad, normLog, normExp, denormalize, normalize } from \"./utils\";\nimport type { FaustUIItemProps, PointerDragEvent } from \"./types\";\nimport type { FaustUINentryStyle } from \"./Nentry\";\nimport \"./Knob.scss\";\n\ninterface FaustUIKnobStyle extends FaustUINentryStyle {\n knobwidth?: number;\n knobcolor?: string;\n knoboncolor?: string;\n needlecolor?: string;\n}\nexport default class Knob extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(18, 18, 18, 0)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\",\n knobwidth: undefined,\n knobcolor: \"rgba(18, 18, 18, 1)\",\n knoboncolor: \"rgba(255, 165, 0, 1)\",\n needlecolor: \"rgba(200, 200, 200, 0.75)\"\n }\n };\n }\n className = \"knob\";\n\n canvas: HTMLCanvasElement;\n inputNumber: HTMLInputElement;\n input: HTMLInputElement;\n ctx: CanvasRenderingContext2D;\n componentWillMount() {\n super.componentWillMount();\n this.canvas = document.createElement(\"canvas\");\n this.canvas.width = 10;\n this.canvas.height = 10;\n this.ctx = this.canvas.getContext(\"2d\");\n this.inputNumber = document.createElement(\"input\");\n this.inputNumber.type = \"number\";\n this.inputNumber.value = (+this.state.value.toFixed(3)).toString();\n this.inputNumber.max = this.state.max.toString();\n this.inputNumber.min = this.state.min.toString();\n this.inputNumber.step = this.state.step.toString();\n this.input = document.createElement(\"input\");\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n this.input.spellcheck = false;\n this.setStyle();\n return this;\n }\n handleChange = (e: Event) => {\n const value = parseFloat((e.currentTarget as HTMLInputElement).value);\n if (isFinite(value)) {\n const changed = this.setValue(+value);\n if (changed) return;\n }\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n };\n setStyle = () => {\n const { fontsize, height, grid, textcolor, bgcolor, bordercolor } = this.state.style;\n this.input.style.fontSize = `${fontsize || height * grid * 0.1}px`;\n this.input.style.color = textcolor;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n componentDidMount() {\n super.componentDidMount();\n this.input.addEventListener(\"change\", this.handleChange);\n this.canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n // this.canvas.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.canvas.addEventListener(\"touchstart\", this.handleTouchStart, { passive: false });\n this.on(\"style\", () => {\n this.schedule(this.setStyle);\n this.schedule(this.paint);\n });\n this.on(\"label\", () => this.schedule(this.paintLabel));\n const valueChange = () => {\n this.inputNumber.value = (+this.state.value.toFixed(3)).toString();\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n };\n this.on(\"value\", () => {\n this.schedule(valueChange);\n this.schedule(this.paint);\n });\n const maxChange = () => this.inputNumber.max = this.state.max.toString();\n this.on(\"max\", () => {\n this.schedule(maxChange);\n this.schedule(this.paint);\n });\n const minChange = () => this.inputNumber.min = this.state.min.toString();\n this.on(\"min\", () => {\n this.schedule(minChange);\n this.schedule(this.paint);\n });\n const stepChange = () => this.inputNumber.step = this.state.step.toString();\n this.on(\"step\", () => {\n this.schedule(stepChange);\n this.schedule(this.paint);\n });\n this.schedule(this.paint);\n return this;\n }\n mount() {\n this.container.appendChild(this.label);\n this.container.appendChild(this.canvas);\n this.container.appendChild(this.input);\n return super.mount();\n }\n paint = () => {\n const { knobwidth, knobcolor, knoboncolor, needlecolor } = this.state.style;\n const ctx = this.ctx;\n const canvas = this.canvas;\n const distance = this.distance;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.canvas.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const start = 5 / 8 * Math.PI;\n const end = 19 / 8 * Math.PI;\n const valPos = start + toRad(distance * 315);\n const dialHeight = Math.min(width, height) * 0.75;\n const dialRadius = dialHeight * 0.5;\n const dialCenterX = width * 0.5;\n const dialCenterY = height * 0.5;\n // const arcStartX = dialCenterX + (dialHeight * 0.5 * Math.cos(start));\n // const arcStartY = dialCenterY + (dialHeight * 0.5 * Math.sin(start));\n // const arcEndX = dialCenterX + (dialHeight * 0.5 * Math.cos(end));\n // const arcEndY = dialCenterY + (dialHeight * 0.5 * Math.sin(end));\n const valuePosX = dialCenterX + (dialHeight * 0.5 * Math.cos(valPos));\n const valuePosY = dialCenterY + (dialHeight * 0.5 * Math.sin(valPos));\n const lineWidth = knobwidth || dialRadius * 0.2;\n\n ctx.strokeStyle = knobcolor;\n ctx.lineWidth = lineWidth;\n ctx.lineCap = \"round\";\n // draw background arc\n ctx.beginPath();\n ctx.arc(dialCenterX, dialCenterY, dialRadius, valPos, end);\n ctx.stroke();\n // draw value arc\n if (distance) {\n ctx.strokeStyle = knoboncolor;\n ctx.beginPath();\n ctx.arc(dialCenterX, dialCenterY, dialRadius, start, valPos);\n ctx.stroke();\n }\n // draw dial needle\n ctx.strokeStyle = needlecolor;\n ctx.beginPath();\n ctx.moveTo(dialCenterX, dialCenterY);\n ctx.lineTo(valuePosX, valuePosY);\n ctx.stroke();\n };\n getValueFromDelta(e: PointerDragEvent) {\n const { type, min, max, enums, scale } = this.state;\n const step = type === \"enum\" ? 1 : (this.state.step || 1);\n const stepRange = this.stepRange;\n const stepsCount = this.stepsCount;\n const range = 100;\n const prevDistance = AbstractItem.getDistance({ value: e.prevValue, type, min, max, enums, scale }) * range;\n const distance = prevDistance + e.fromY - e.y;\n const denormalized = denormalize(distance / range, min, max);\n const v = scale === \"exp\" ? normExp(denormalized, min, max) : scale === \"log\" ? normLog(denormalized, min, max) : denormalized;\n let steps = Math.round(normalize(v, min, max) * range / stepRange);\n steps = Math.min(stepsCount, Math.max(0, steps));\n if (type === \"enum\") return steps;\n if (type === \"int\") return Math.round(steps * step + min);\n return steps * step + min;\n }\n handleMouseOrTouchMove = (e: PointerDragEvent) => {\n const newValue = this.getValueFromDelta(e);\n if (newValue !== this.state.value) this.setValue(newValue);\n };\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemProps } from \"./types\";\nimport type { FaustUINentryStyle } from \"./Nentry\";\nimport \"./Led.scss\";\n\ninterface FaustUILedStyle extends FaustUINentryStyle {\n shape?: \"circle\" | \"square\";\n ledbgcolor?: string;\n coldcolor?: string;\n warmcolor?: string;\n hotcolor?: string;\n overloadcolor?: string;\n}\nexport default class Led extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(18, 18, 18, 0)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\",\n shape: \"circle\",\n ledbgcolor: \"rgba(18, 18, 18, 1)\",\n coldcolor: \"rgba(12, 248, 100, 1)\",\n warmcolor: \"rgba(195, 248, 100, 1)\",\n hotcolor: \"rgba(255, 193, 10, 1)\",\n overloadcolor: \"rgba(255, 10, 10, 1)\"\n }\n };\n }\n className = \"led\";\n\n canvasDiv: HTMLDivElement;\n canvas: HTMLCanvasElement;\n tempCanvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n tempCtx: CanvasRenderingContext2D;\n componentWillMount() {\n super.componentWillMount();\n this.canvasDiv = document.createElement(\"div\");\n this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`;\n this.canvas = document.createElement(\"canvas\");\n this.canvas.width = 10;\n this.canvas.height = 10;\n this.ctx = this.canvas.getContext(\"2d\");\n this.tempCanvas = document.createElement(\"canvas\");\n this.tempCtx = this.tempCanvas.getContext(\"2d\");\n this.tempCanvas.width = 128;\n this.tempCanvas.height = 1;\n this.setStyle();\n return this;\n }\n setStyle = () => {\n const { bgcolor, bordercolor } = this.state.style;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n componentDidMount() {\n super.componentDidMount();\n this.canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n // this.canvas.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.canvas.addEventListener(\"touchstart\", this.handleTouchStart, { passive: false });\n this.on(\"style\", () => this.schedule(this.setStyle));\n this.on(\"label\", () => this.schedule(this.paintLabel));\n this.on(\"value\", () => this.schedule(this.paint));\n this.on(\"max\", () => this.schedule(this.paint));\n this.on(\"min\", () => this.schedule(this.paint));\n this.on(\"step\", () => this.schedule(this.paint));\n this.schedule(this.paint);\n return this;\n }\n mount() {\n this.canvasDiv.appendChild(this.canvas);\n this.container.appendChild(this.label);\n this.container.appendChild(this.canvasDiv);\n return super.mount();\n }\n paint = () => {\n const { shape, ledbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style;\n const { min, max } = this.state;\n const { canvas, ctx, tempCanvas, tempCtx, distance } = this;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = canvas.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const drawHeight = Math.min(height, width) * 0.75;\n const drawWidth = drawHeight;\n const left = (width - drawWidth) * 0.5;\n const top = (height - drawHeight) * 0.5;\n const coldStop = (-18 - min) / (max - min);\n const warmStop = (-6 - min) / (max - min);\n const hotStop = (-3 - min) / (max - min);\n const overloadStop = -min / (max - min);\n const gradient = tempCtx.createLinearGradient(0, 0, tempCanvas.width, 0);\n if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);\n else if (coldStop > 1) gradient.addColorStop(1, coldcolor);\n if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);\n if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);\n if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);\n else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);\n tempCtx.fillStyle = gradient;\n tempCtx.fillRect(0, 0, tempCanvas.width, 10);\n const d = tempCtx.getImageData(Math.min(tempCanvas.width - 1, distance * tempCanvas.width), 0, 1, 1).data;\n if (distance) ctx.fillStyle = `rgb(${d[0]}, ${d[1]}, ${d[2]})`;\n else ctx.fillStyle = ledbgcolor;\n if (shape === \"circle\") ctx.arc(width / 2, height / 2, width / 2 - left, 0, 2 * Math.PI);\n else ctx.rect(left, top, drawWidth, drawHeight);\n ctx.fill();\n };\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemStyle, FaustUIItemProps } from \"./types\";\nimport \"./Menu.scss\";\n\nexport interface FaustUIMenuStyle extends FaustUIItemStyle {\n fontname?: string;\n fontsize?: number;\n fontface?: \"regular\" | \"bold\" | \"italic\" | \"bold italic\";\n bgcolor?: string;\n bordercolor?: string;\n labelcolor?: string;\n textcolor?: string;\n}\nexport default class Menu extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(255, 255, 255, 0.25)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\"\n }\n };\n }\n className = \"menu\";\n\n select: HTMLSelectElement;\n componentWillMount() {\n super.componentWillMount();\n this.select = document.createElement(\"select\");\n this.getOptions();\n this.setStyle();\n return this;\n }\n getOptions() {\n const { enums } = this.state;\n this.select.innerHTML = \"\";\n if (enums) {\n let i = 0;\n for (const key in enums) {\n const option = document.createElement(\"option\");\n option.value = enums[key].toString();\n option.text = key;\n if (i === 0) option.selected = true;\n this.select.appendChild(option);\n i++;\n }\n }\n }\n handleChange = (e: Event) => {\n this.setValue(+(e.currentTarget as HTMLInputElement).value);\n };\n setStyle = () => {\n const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n this.select.style.backgroundColor = bgcolor;\n this.select.style.borderColor = bordercolor;\n this.select.style.color = textcolor;\n this.select.style.fontSize = `${fontsize || height * grid / 4}px`;\n };\n componentDidMount() {\n super.componentDidMount();\n this.select.addEventListener(\"change\", this.handleChange);\n this.on(\"style\", () => this.schedule(this.setStyle));\n this.on(\"label\", () => this.schedule(this.paintLabel));\n this.on(\"enums\", () => this.schedule(this.getOptions));\n const valueChange = () => {\n for (let i = this.select.children.length - 1; i >= 0; i--) {\n const option = this.select.children[i] as HTMLOptionElement;\n if (+option.value === this.state.value) this.select.selectedIndex = i;\n }\n };\n this.on(\"value\", () => this.schedule(valueChange));\n valueChange();\n return this;\n }\n mount() {\n this.container.appendChild(this.label);\n this.container.appendChild(this.select);\n return super.mount();\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemStyle, FaustUIItemProps } from \"./types\";\nimport \"./Nentry.scss\";\n\nexport interface FaustUINentryStyle extends FaustUIItemStyle {\n fontname?: string;\n fontsize?: number;\n fontface?: \"regular\" | \"bold\" | \"italic\" | \"bold italic\";\n bgcolor?: string;\n bordercolor?: string;\n labelcolor?: string;\n textcolor?: string;\n}\nexport default class Nentry extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(255, 255, 255, 0.25)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\"\n }\n };\n }\n className = \"nentry\";\n\n input: HTMLInputElement;\n componentWillMount() {\n super.componentWillMount();\n this.input = document.createElement(\"input\");\n this.input.type = \"number\";\n this.input.value = (+this.state.value.toFixed(3)).toString();\n this.input.max = this.state.max.toString();\n this.input.min = this.state.min.toString();\n this.input.step = this.state.step.toString();\n this.setStyle();\n return this;\n }\n handleChange = (e: Event) => {\n this.setValue(+(e.currentTarget as HTMLInputElement).value);\n };\n setStyle = () => {\n const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n this.input.style.backgroundColor = bgcolor;\n this.input.style.borderColor = bordercolor;\n this.input.style.color = textcolor;\n this.input.style.fontSize = `${fontsize || height * grid / 4}px`;\n };\n componentDidMount() {\n super.componentDidMount();\n this.input.addEventListener(\"change\", this.handleChange);\n this.on(\"style\", () => this.schedule(this.setStyle));\n this.on(\"label\", () => this.schedule(this.paintLabel));\n const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString();\n this.on(\"value\", () => this.schedule(valueChange));\n const maxChange = () => this.input.max = this.state.max.toString();\n this.on(\"max\", () => this.schedule(maxChange));\n const minChange = () => this.input.min = this.state.min.toString();\n this.on(\"min\", () => this.schedule(minChange));\n const stepChange = () => this.input.step = this.state.step.toString();\n this.on(\"step\", () => this.schedule(stepChange));\n return this;\n }\n mount() {\n this.container.appendChild(this.label);\n this.container.appendChild(this.input);\n return super.mount();\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemProps } from \"./types\";\nimport type { FaustUINentryStyle } from \"./Nentry\";\nimport \"./Numerical.scss\";\n\nexport default class Numerical extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(255, 255, 255, 0.25)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\"\n }\n };\n }\n className = \"numerical\";\n\n input: HTMLInputElement;\n componentWillMount() {\n super.componentWillMount();\n this.input = document.createElement(\"input\");\n this.input.disabled = true;\n this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || \"\");\n this.setStyle();\n return this;\n }\n setStyle = () => {\n const { height, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n this.input.style.backgroundColor = bgcolor;\n this.input.style.borderColor = bordercolor;\n this.input.style.color = textcolor;\n this.input.style.fontSize = `${fontsize || height * grid / 4}px`;\n };\n componentDidMount() {\n super.componentDidMount();\n this.on(\"style\", () => this.schedule(this.setStyle));\n this.on(\"label\", () => this.schedule(this.paintLabel));\n const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || \"\");\n this.on(\"value\", () => this.schedule(valueChange));\n return this;\n }\n mount() {\n this.container.appendChild(this.label);\n this.container.appendChild(this.input);\n return super.mount();\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemStyle, FaustUIItemProps } from \"./types\";\nimport \"./Radio.scss\";\n\nexport interface FaustUIRadioStyle extends FaustUIItemStyle {\n fontname?: string;\n fontsize?: number;\n fontface?: \"regular\" | \"bold\" | \"italic\" | \"bold italic\";\n bgcolor?: string;\n bordercolor?: string;\n labelcolor?: string;\n textcolor?: string;\n}\nexport default class Radio extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(255, 255, 255, 0.25)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\"\n }\n };\n }\n className = \"radio\";\n\n group: HTMLDivElement;\n componentWillMount() {\n super.componentWillMount();\n this.group = document.createElement(\"div\");\n this.group.className = \"faust-ui-component-radio-group\";\n this.getOptions();\n this.setStyle();\n return this;\n }\n getOptions = () => {\n const { enums, address } = this.state;\n this.group.innerHTML = \"\";\n if (enums) {\n let i = 0;\n for (const key in enums) {\n const input = document.createElement(\"input\");\n const div = document.createElement(\"div\");\n input.value = enums[key].toString();\n input.name = address;\n input.type = \"radio\";\n if (i === 0) input.checked = true;\n input.addEventListener(\"change\", () => {\n if (input.checked) this.setValue(enums[key]);\n });\n div.appendChild(input);\n div.append(key);\n this.group.appendChild(div);\n i++;\n }\n }\n };\n setStyle = () => {\n const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n const fontSize = Math.min(height * grid * 0.1, width * grid * 0.1);\n this.group.style.backgroundColor = bgcolor;\n this.group.style.borderColor = bordercolor;\n this.group.style.color = textcolor;\n this.group.style.fontSize = `${fontsize || fontSize}px`;\n };\n componentDidMount() {\n super.componentDidMount();\n this.on(\"style\", () => this.schedule(this.setStyle));\n this.on(\"label\", () => this.schedule(this.paintLabel));\n this.on(\"enums\", () => this.schedule(this.getOptions));\n const valueChange = () => {\n for (let i = this.group.children.length - 1; i >= 0; i--) {\n const input = this.group.children[i].querySelector(\"input\");\n if (+input.value === this.state.value) input.checked = true;\n }\n };\n this.on(\"value\", () => this.schedule(valueChange));\n valueChange();\n return this;\n }\n mount() {\n this.container.appendChild(this.label);\n this.container.appendChild(this.group);\n return super.mount();\n }\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemStyle, FaustUIItemProps } from \"./types\";\nimport \"./Soundfile.scss\";\n\nexport interface FaustUISoundfileStyle extends FaustUIItemStyle {\n fontname?: string;\n fontsize?: number;\n fontface?: \"normal\" | \"bold\" | \"italic\" | \"bold italic\";\n bgcolor?: string;\n bgoncolor?: string;\n bordercolor?: string;\n borderoncolor?: string;\n textcolor?: string;\n textoncolor?: string;\n}\nexport default class Soundfile extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"normal\",\n bgcolor: \"rgba(40, 40, 40, 1)\",\n bgoncolor: \"rgba(18, 18, 18, 1)\",\n bordercolor: \"rgba(80, 80, 80, 1)\",\n borderoncolor: \"rgba(255, 165, 0, 1)\",\n textcolor: \"rgba(226, 222, 255, 0.5)\",\n textoncolor: \"rgba(255, 165, 0, 1)\"\n }\n };\n }\n className = \"soundfile\";\n\n btn: HTMLDivElement;\n span: HTMLSpanElement;\n componentWillMount() {\n super.componentWillMount();\n this.btn = document.createElement(\"div\");\n this.span = document.createElement(\"span\");\n this.span.innerText = this.state.label;\n this.setStyle();\n return this;\n }\n setStyle = () => {\n const { value, style } = this.state;\n const { height, grid, fontsize, fontname, fontface, textcolor, textoncolor, bgoncolor, bgcolor, bordercolor, borderoncolor } = style;\n this.btn.style.backgroundColor = value ? bgoncolor : bgcolor;\n this.btn.style.borderColor = value ? borderoncolor : bordercolor;\n this.btn.style.color = value ? textoncolor : textcolor;\n this.btn.style.fontSize = `${fontsize || height * grid / 4}px`;\n this.btn.style.fontFamily = `${fontname}, sans-serif`;\n this.btn.style.fontStyle = fontface;\n };\n mount() {\n this.btn.appendChild(this.span);\n this.container.appendChild(this.btn);\n return super.mount();\n }\n componentDidMount() {\n super.componentDidMount();\n this.btn.addEventListener(\"pointerdown\", this.handlePointerDown);\n // this.btn.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.btn.addEventListener(\"touchstart\", this.handleTouchStart);\n this.on(\"style\", () => this.schedule(this.setStyle));\n const labelChange = () => this.span.innerText = this.state.label;\n this.on(\"label\", () => this.schedule(labelChange));\n this.on(\"value\", () => this.schedule(this.setStyle));\n return this;\n }\n handleMouseOrTouchDown = () => {\n //this.setValue(1);\n };\n handleMouseOrTouchUp = () => {\n //this.setValue(0);\n };\n}\n","import AbstractItem from \"./AbstractItem\";\nimport type { FaustUIItemProps } from \"./types\";\nimport type { FaustUINentryStyle } from \"./Nentry\";\nimport \"./VBargraph.scss\";\n\ninterface FaustUIBargraphStyle extends FaustUINentryStyle {\n barwidth?: number;\n barbgcolor?: string;\n coldcolor?: string;\n warmcolor?: string;\n hotcolor?: string;\n overloadcolor?: string;\n}\nexport default class VBargraph extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(18, 18, 18, 0)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\",\n barwidth: undefined,\n barbgcolor: \"rgba(18, 18, 18, 1)\",\n coldcolor: \"rgba(12, 248, 100, 1)\",\n warmcolor: \"rgba(195, 248, 100, 1)\",\n hotcolor: \"rgba(255, 193, 10, 1)\",\n overloadcolor: \"rgba(255, 10, 10, 1)\"\n }\n };\n }\n className = \"vbargraph\";\n\n canvas: HTMLCanvasElement;\n input: HTMLInputElement;\n flexDiv: HTMLDivElement;\n canvasDiv: HTMLDivElement;\n ctx: CanvasRenderingContext2D;\n componentWillMount() {\n super.componentWillMount();\n this.flexDiv = document.createElement(\"div\");\n this.flexDiv.className = `faust-ui-component-${this.className}-flexdiv`;\n this.canvasDiv = document.createElement(\"div\");\n this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`;\n this.canvas = document.createElement(\"canvas\");\n this.canvas.width = 10;\n this.canvas.height = 10;\n this.ctx = this.canvas.getContext(\"2d\");\n this.input = document.createElement(\"input\");\n this.input.disabled = true;\n this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || \"\");\n this.setStyle();\n return this;\n }\n setStyle = () => {\n const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n const fontSize = Math.min(height * grid * 0.05, width * grid * 0.2);\n this.input.style.fontSize = `${fontsize || fontSize}px`;\n this.input.style.color = textcolor;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n componentDidMount() {\n super.componentDidMount();\n this.canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n // this.canvas.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.canvas.addEventListener(\"touchstart\", this.handleTouchStart, { passive: false });\n this.on(\"style\", () => {\n this.schedule(this.setStyle);\n this.schedule(this.paint);\n });\n this.on(\"label\", () => this.schedule(this.paintLabel));\n const valueChange = () => this.input.value = (+this.state.value.toFixed(3)).toString() + (this.state.unit || \"\");\n this.on(\"value\", () => {\n this.schedule(valueChange);\n this.schedule(this.paint);\n });\n this.on(\"max\", () => this.schedule(this.paint));\n this.on(\"min\", () => this.schedule(this.paint));\n this.on(\"step\", () => this.schedule(this.paint));\n this.schedule(this.paint);\n return this;\n }\n mount() {\n this.canvasDiv.appendChild(this.canvas);\n this.flexDiv.appendChild(this.canvasDiv);\n this.flexDiv.appendChild(this.input);\n this.container.appendChild(this.label);\n this.container.appendChild(this.flexDiv);\n return super.mount();\n }\n paintValue = 0;\n maxValue = -Infinity;\n maxTimer: number;\n paint = () => {\n const { barwidth, barbgcolor, coldcolor, warmcolor, hotcolor, overloadcolor } = this.state.style;\n const { type, max, min, enums, scale, value } = this.state;\n const ctx = this.ctx;\n const canvas = this.canvas;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.canvasDiv.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const drawHeight = height * 0.9;\n const drawWidth = barwidth || Math.min(width / 3, drawHeight * 0.05);\n const left = (width - drawWidth) * 0.5;\n const top = height * 0.05;\n this.paintValue = value;\n const paintValue = this.paintValue;\n if (paintValue > this.maxValue) {\n this.maxValue = paintValue;\n if (this.maxTimer) window.clearTimeout(this.maxTimer);\n this.maxTimer = window.setTimeout(() => {\n this.maxValue = this.paintValue;\n this.maxTimer = undefined;\n this.schedule(this.paint);\n }, 1000);\n }\n if (paintValue < this.maxValue && typeof this.maxTimer === \"undefined\") {\n this.maxTimer = window.setTimeout(() => {\n this.maxValue = this.paintValue;\n this.maxTimer = undefined;\n this.schedule(this.paint);\n }, 1000);\n }\n const maxValue = this.maxValue;\n const coldStop = (-18 - min) / (max - min);\n const warmStop = (-6 - min) / (max - min);\n const hotStop = (-3 - min) / (max - min);\n const overloadStop = Math.max(0, -min / (max - min));\n const gradient = ctx.createLinearGradient(0, drawHeight, 0, top);\n if (coldStop <= 1 && coldStop >= 0) gradient.addColorStop(coldStop, coldcolor);\n else if (coldStop > 1) gradient.addColorStop(1, coldcolor);\n if (warmStop <= 1 && warmStop >= 0) gradient.addColorStop(warmStop, warmcolor);\n if (hotStop <= 1 && hotStop >= 0) gradient.addColorStop(hotStop, hotcolor);\n if (overloadStop <= 1 && overloadStop >= 0) gradient.addColorStop(overloadStop, overloadcolor);\n else if (overloadStop < 0) gradient.addColorStop(0, coldcolor);\n\n ctx.fillStyle = barbgcolor;\n if (paintValue < 0) ctx.fillRect(left, top + (1 - overloadStop) * drawHeight, drawWidth, drawHeight * overloadStop);\n if (paintValue < max) ctx.fillRect(left, top, drawWidth, (1 - overloadStop) * drawHeight - 1);\n ctx.fillStyle = gradient;\n if (paintValue > min) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(0, paintValue) }));\n ctx.fillRect(left, top + (1 - distance) * drawHeight, drawWidth, drawHeight * distance);\n }\n if (paintValue > 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(max, paintValue) }) - overloadStop);\n ctx.fillRect(left, top + (1 - overloadStop - distance) * drawHeight, drawWidth, drawHeight * distance - 1);\n }\n if (maxValue > paintValue) {\n if (maxValue <= 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(0, maxValue) }));\n ctx.fillRect(left, top + (1 - distance) * drawHeight, drawWidth, 1);\n }\n if (maxValue > 0) {\n const distance = Math.max(0, AbstractItem.getDistance({ type, max, min, enums, scale, value: Math.min(max, maxValue) }) - overloadStop);\n ctx.fillRect(left, Math.max(top, top + (1 - overloadStop - distance) * drawHeight - 1), drawWidth, 1);\n }\n }\n };\n}\n","import AbstractItem from \"./AbstractItem\";\nimport { fillRoundedRect, normLog, normExp, denormalize, normalize } from \"./utils\";\nimport type { FaustUIItemProps, PointerDownEvent, PointerDragEvent } from \"./types\";\nimport type { FaustUINentryStyle } from \"./Nentry\";\nimport \"./VSlider.scss\";\n\ninterface FaustUISliderStyle extends FaustUINentryStyle {\n sliderwidth?: number;\n sliderbgcolor?: string;\n sliderbgoncolor?: string;\n slidercolor?: string;\n}\nexport default class VSlider extends AbstractItem {\n static get defaultProps(): FaustUIItemProps {\n const inherited = super.defaultProps;\n return {\n ...inherited,\n style: {\n ...inherited.style,\n fontname: \"Arial\",\n fontsize: undefined,\n fontface: \"regular\",\n bgcolor: \"rgba(18, 18, 18, 0)\",\n bordercolor: \"rgba(80, 80, 80, 0)\",\n labelcolor: \"rgba(226, 222, 255, 0.5)\",\n textcolor: \"rgba(18, 18, 18, 1)\",\n sliderwidth: undefined,\n sliderbgcolor: \"rgba(18, 18, 18, 1)\",\n sliderbgoncolor: \"rgba(255, 165, 0, 1)\",\n slidercolor: \"rgba(200, 200, 200, 0.75)\"\n }\n };\n }\n className = \"vslider\";\n\n canvas: HTMLCanvasElement;\n inputNumber: HTMLInputElement;\n input: HTMLInputElement;\n flexDiv: HTMLDivElement;\n canvasDiv: HTMLDivElement;\n ctx: CanvasRenderingContext2D;\n interactionRect: number[] = [0, 0, 0, 0];\n componentWillMount() {\n super.componentWillMount();\n this.flexDiv = document.createElement(\"div\");\n this.flexDiv.className = `faust-ui-component-${this.className}-flexdiv`;\n this.canvasDiv = document.createElement(\"div\");\n this.canvasDiv.className = `faust-ui-component-${this.className}-canvasdiv`;\n this.canvas = document.createElement(\"canvas\");\n this.canvas.width = 10;\n this.canvas.height = 10;\n this.ctx = this.canvas.getContext(\"2d\");\n this.inputNumber = document.createElement(\"input\");\n this.inputNumber.type = \"number\";\n this.inputNumber.value = (+this.state.value.toFixed(3)).toString();\n this.inputNumber.max = this.state.max.toString();\n this.inputNumber.min = this.state.min.toString();\n this.inputNumber.step = this.state.step.toString();\n this.input = document.createElement(\"input\");\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n this.input.spellcheck = false;\n this.setStyle();\n return this;\n }\n handleChange = (e: Event) => {\n const value = parseFloat((e.currentTarget as HTMLInputElement).value);\n if (isFinite(value)) {\n const changed = this.setValue(+value);\n if (changed) return;\n }\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n };\n setStyle = () => {\n const { height, width, grid, fontsize, textcolor, bgcolor, bordercolor } = this.state.style;\n const fontSize = Math.min(height * grid * 0.05, width * grid * 0.2);\n this.input.style.fontSize = `${fontsize || fontSize}px`;\n this.input.style.color = textcolor;\n this.container.style.backgroundColor = bgcolor;\n this.container.style.borderColor = bordercolor;\n };\n componentDidMount() {\n super.componentDidMount();\n this.input.addEventListener(\"change\", this.handleChange);\n this.canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n // this.canvas.addEventListener(\"mousedown\", this.handleMouseDown);\n // this.canvas.addEventListener(\"touchstart\", this.handleTouchStart, { passive: false });\n this.on(\"style\", () => {\n this.schedule(this.setStyle);\n this.schedule(this.paint);\n });\n this.on(\"label\", () => this.schedule(this.paintLabel));\n const valueChange = () => {\n this.inputNumber.value = (+this.state.value.toFixed(3)).toString();\n this.input.value = this.inputNumber.value + (this.state.unit || \"\");\n };\n this.on(\"value\", () => {\n this.schedule(valueChange);\n this.schedule(this.paint);\n });\n const maxChange = () => this.inputNumber.max = this.state.max.toString();\n this.on(\"max\", () => {\n this.schedule(maxChange);\n this.schedule(this.paint);\n });\n const minChange = () => this.inputNumber.min = this.state.min.toString();\n this.on(\"min\", () => {\n this.schedule(minChange);\n this.schedule(this.paint);\n });\n const stepChange = () => this.inputNumber.step = this.state.step.toString();\n this.on(\"step\", () => {\n this.schedule(stepChange);\n this.schedule(this.paint);\n });\n this.schedule(this.paint);\n return this;\n }\n mount() {\n this.canvasDiv.appendChild(this.canvas);\n this.flexDiv.appendChild(this.canvasDiv);\n this.flexDiv.appendChild(this.input);\n this.container.appendChild(this.label);\n this.container.appendChild(this.flexDiv);\n return super.mount();\n }\n paint = () => {\n const { sliderwidth, sliderbgcolor, sliderbgoncolor, slidercolor } = this.state.style;\n const ctx = this.ctx;\n const canvas = this.canvas;\n const distance = this.distance;\n const ratio = window.devicePixelRatio || 1;\n let { width, height } = this.canvasDiv.getBoundingClientRect();\n width = Math.floor(width);\n height = Math.floor(height);\n const scaledWidth = Math.floor(width * ratio);\n const scaledHeight = Math.floor(height * ratio);\n canvas.width = scaledWidth;\n canvas.height = scaledHeight;\n // canvas.style.width = width + \"px\";\n // canvas.style.height = height + \"px\";\n ctx.scale(ratio, ratio);\n\n const drawHeight = height * 0.9;\n const drawWidth = sliderwidth || Math.min(width / 3, drawHeight * 0.05);\n const left = (width - drawWidth) * 0.5;\n const top = height * 0.05;\n const borderRadius = drawWidth * 0.25;\n this.interactionRect = [0, top, width, drawHeight];\n const grd = ctx.createLinearGradient(0, top, 0, top + drawHeight);\n grd.addColorStop(Math.max(0, Math.min(1, 1 - distance)), sliderbgcolor);\n grd.addColorStop(Math.max(0, Math.min(1, 1 - distance)), sliderbgoncolor);\n ctx.fillStyle = grd;\n fillRoundedRect(ctx, left, top, drawWidth, drawHeight, borderRadius);\n // draw slider\n ctx.fillStyle = slidercolor;\n fillRoundedRect(ctx, left - drawWidth, top + drawHeight * (1 - distance) - drawWidth, drawWidth * 3, drawWidth * 2, borderRadius);\n };\n get stepsCount() {\n const { type, max, min, step, enums } = this.state;\n const maxSteps = type === \"enum\" ? enums.length : type === \"int\" ? max - min : (max - min) / step;\n if (step) {\n if (type === \"enum\") return enums.length;\n if (type === \"int\") return Math.min(Math.floor((max - min) / (Math.round(step) || 0)), maxSteps);\n return Math.floor((max - min) / step);\n }\n return maxSteps;\n }\n get stepRange() {\n const full = this.interactionRect[this.className === \"vslider\" ? 3 : 2];\n const stepsCount = this.stepsCount;\n return full / stepsCount;\n }\n getValueFromPos(e: { x: number; y: number }) {\n const { type, min, max, scale } = this.state;\n const step = type === \"enum\" ? 1 : (this.state.step || 1);\n const stepRange = this.stepRange;\n const stepsCount = this.stepsCount;\n const distance = (this.className === \"vslider\" ? this.interactionRect[3] - (e.y - this.interactionRect[1]) : e.x - this.interactionRect[0]);\n const range = this.className === \"vslider\" ? this.interactionRect[3] : this.interactionRect[2];\n const denormalized = denormalize(distance / range, min, max);\n const v = scale === \"exp\" ? normExp(denormalized, min, max) : scale === \"log\" ? normLog(denormalized, min, max) : denormalized;\n let steps = Math.round(normalize(v, min, max) * range / stepRange);\n steps = Math.min(stepsCount, Math.max(0, steps));\n if (type === \"enum\") return steps;\n if (type === \"int\") return Math.round(steps * step + min);\n return steps * step + min;\n }\n handleMouseOrTouchDown = (e: PointerDownEvent) => {\n const { value } = this.state;\n if (\n e.x < this.interactionRect[0]\n || e.x > this.interactionRect[0] + this.interactionRect[2]\n || e.y < this.interactionRect[1]\n || e.y > this.interactionRect[1] + this.interactionRect[3]\n ) return;\n const newValue = this.getValueFromPos(e);\n if (newValue !== value) this.setValue(this.getValueFromPos(e));\n };\n handleMouseOrTouchMove = (e: PointerDragEvent) => {\n const newValue = this.getValueFromPos(e);\n if (newValue !== this.state.value) this.setValue(newValue);\n };\n}\n","export const toMIDI = (f: number) => [\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"A#\", \"B\"][(f % 12 + 12) % 12] + Math.round(f / 12 - 2);\nexport const toRad = (degrees: number) => degrees * Math.PI / 180;\nexport const atodb = (a: number) => 20 * Math.log10(a);\nexport const dbtoa = (db: number) => 10 ** (db / 20);\nexport const denormalize = (x: number, min: number, max: number) => min + (max - min) * x;\nexport const normalize = (x: number, min: number, max: number) => (x - min) / (max - min) || 0;\nexport const normLog = (x: number, min: number, max: number) => {\n const normalized = normalize(x, min, max);\n const logMin = Math.log(Math.max(Number.EPSILON, min));\n const logMax = Math.log(Math.max(Number.EPSILON, max));\n const vLog = denormalize(normalized, logMin, logMax);\n const v = Math.exp(vLog);\n return Math.max(min, Math.min(max, v));\n};\nexport const iNormLog = (vIn: number, min: number, max: number) => {\n const v = Math.max(min, Math.min(max, vIn));\n const vLog = Math.log(Math.max(Number.EPSILON, v));\n const logMin = Math.log(Math.max(Number.EPSILON, min));\n const logMax = Math.log(Math.max(Number.EPSILON, max));\n const normalized = normalize(vLog, logMin, logMax);\n return denormalize(normalized, min, max);\n};\nexport const normExp = iNormLog;\nexport const iNormExp = normLog;\nexport const roundedRect = (ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number | number[]) => {\n const radii = [0, 0, 0, 0];\n if (typeof radius === \"number\") radii.fill(radius);\n else radius.forEach((v, i) => radii[i] = v);\n ctx.beginPath();\n ctx.moveTo(x + radii[0], y);\n ctx.lineTo(x + width - radii[1], y);\n ctx.quadraticCurveTo(x + width, y, x + width, y + radii[1]);\n ctx.lineTo(x + width, y + height - radii[2]);\n ctx.quadraticCurveTo(x + width, y + height, x + width - radii[2], y + height);\n ctx.lineTo(x + radii[3], y + height);\n ctx.quadraticCurveTo(x, y + height, x, y + height - radii[3]);\n ctx.lineTo(x, y + radii[0]);\n ctx.quadraticCurveTo(x, y, x + radii[0], y);\n ctx.closePath();\n ctx.stroke();\n};\nexport const fillRoundedRect = (ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number | number[]) => {\n const radii = [0, 0, 0, 0];\n if (typeof radius === \"number\") radii.fill(radius);\n else radius.forEach((v, i) => radii[i] = v);\n ctx.beginPath();\n ctx.moveTo(x + radii[0], y);\n ctx.lineTo(x + width - radii[1], y);\n ctx.quadraticCurveTo(x + width, y, x + width, y + radii[1]);\n ctx.lineTo(x + width, y + height - radii[2]);\n ctx.quadraticCurveTo(x + width, y + height, x + width - radii[2], y + height);\n ctx.lineTo(x + radii[3], y + height);\n ctx.quadraticCurveTo(x, y + height, x, y + height - radii[3]);\n ctx.lineTo(x, y + radii[0]);\n ctx.quadraticCurveTo(x, y, x + radii[0], y);\n ctx.closePath();\n ctx.fill();\n};\n","import FaustUI from \"./FaustUI\";\n\nconst instantiate = () => {\n const faustUI = new FaustUI({\n root: document.getElementById(\"root\") as HTMLDivElement,\n listenWindowResize: true,\n listenWindowMessage: true\n });\n let host: Window;\n window.addEventListener(\"message\", (e) => {\n const { source } = e;\n host = source as Window;\n });\n\n window.addEventListener(\"keydown\", (e) => {\n if (host) host.postMessage({ type: \"keydown\", key: e.key }, \"*\");\n });\n window.addEventListener(\"keyup\", (e) => {\n if (host) host.postMessage({ type: \"keyup\", key: e.key }, \"*\");\n });\n (window as any).faustUI = faustUI;\n};\n\nexport default instantiate;\n","import type { FaustUIGroupType } from \"@grame/faustwasm\";\nimport IItem from \"./IItem\";\nimport AbstractItem from \"./AbstractItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default abstract class AbstractGroup implements IItem {\n static padding = 0.2;\n static labelHeight = 0.25;\n static spaceBetween = 0.1;\n isRoot: boolean;\n type: FaustUIGroupType;\n label: string;\n items: (AbstractGroup | AbstractItem)[];\n layout: LayoutProps;\n\n constructor(group: { type: FaustUIGroupType; label: string; items: (AbstractGroup | AbstractItem)[] }, isRoot?: boolean) {\n this.isRoot = !!isRoot;\n Object.assign(this, group);\n const { hasHSizingDesc, hasVSizingDesc } = this;\n const sizing = hasHSizingDesc && hasVSizingDesc ? \"both\" : hasHSizingDesc ? \"horizontal\" : hasVSizingDesc ? \"vertical\" : \"none\";\n this.layout = {\n type: group.type,\n width: AbstractGroup.padding * 2,\n height: AbstractGroup.padding * 2 + (this.isRoot ? 0 : AbstractGroup.labelHeight),\n sizing\n };\n }\n\n /**\n * find recursively if the group has horizontal-sizable item\n */\n get hasHSizingDesc(): boolean {\n return !!this.items.find((item) => {\n if (item instanceof AbstractGroup) return item.hasHSizingDesc;\n return item.layout.sizing === \"horizontal\" || item.layout.sizing === \"both\";\n });\n }\n /**\n * find recursively if the group has vertical-sizable item\n */\n get hasVSizingDesc(): boolean {\n return !!this.items.find((item) => {\n if (item instanceof AbstractGroup) return item.hasVSizingDesc;\n return item.layout.sizing === \"vertical\" || item.layout.sizing === \"both\";\n });\n }\n adjust() {\n return this;\n }\n expand(dX: number, dY: number) {\n return this;\n }\n offset() {\n return this;\n }\n}\n","import type { FaustUIInputItem } from \"@grame/faustwasm\";\nimport AbstractItem from \"./AbstractItem\";\n\nexport default abstract class AbstractInputItem extends AbstractItem {\n init: number;\n step: number;\n constructor(item: FaustUIInputItem) {\n super(item);\n this.init = +item.init || 0;\n this.step = +item.step || 1;\n }\n}\n","import type { FaustUIInputType, FaustUIItem, FaustUIMeta, FaustUIOutputType } from \"@grame/faustwasm\";\nimport type { LayoutProps } from \"../types\";\nimport type IItem from \"./IItem\";\n\nexport default abstract class AbstractItem implements IItem {\n type: FaustUIInputType | FaustUIOutputType;\n label: string;\n address: string;\n url: string;\n index: number;\n init: number;\n min: number;\n max: number;\n meta?: FaustUIMeta[];\n layout: LayoutProps;\n constructor(item: FaustUIItem) {\n Object.assign(this, item);\n this.min = isFinite(+this.min) ? +this.min : 0;\n this.max = isFinite(+this.max) ? +this.max : 1;\n }\n\n adjust(): this {\n return this;\n }\n expand(dX: number, dY: number): this {\n return this;\n }\n offset(): this {\n return this;\n }\n}\n","import AbstractItem from \"./AbstractItem\";\n\nexport default abstract class AbstractOutputItem extends AbstractItem {\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport { LayoutProps } from \"../types\";\n\nexport default class Button extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"button\",\n width: 2,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport { LayoutProps } from \"../types\";\n\nexport default class Checkbox extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"checkbox\",\n width: 2,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractOutputItem from \"./AbstractOutputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class HBargraph extends AbstractOutputItem {\n layout: LayoutProps = {\n type: \"hbargraph\",\n width: 5,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractGroup from \"./AbstractGroup\";\n\nexport default class HGroup extends AbstractGroup {\n adjust() {\n this.items.forEach((item) => {\n item.adjust();\n this.layout.width += item.layout.width;\n this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * AbstractGroup.padding + (this.isRoot ? 0 : AbstractGroup.labelHeight));\n });\n this.layout.width += AbstractGroup.spaceBetween * (this.items.length - 1);\n if (this.layout.width < 1) this.layout.width += 1;\n return this;\n }\n expand(dX: number) {\n let hExpandItems = 0;\n this.items.forEach((item) => { // Count items that need to expand horizontally\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"horizontal\") hExpandItems++;\n });\n this.items.forEach((item) => {\n let dX$ = 0;\n let dY$ = 0; // Space available to expand for current item\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"horizontal\") {\n dX$ = hExpandItems ? dX / hExpandItems : 0;\n item.layout.width += dX$;\n }\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"vertical\") {\n dY$ = this.layout.height - 2 * AbstractGroup.padding - (this.isRoot ? 0 : AbstractGroup.labelHeight) - item.layout.height;\n item.layout.height += dY$;\n }\n item.expand(dX$, dY$);\n });\n // this.layout.width += dX;\n return this;\n }\n offset() {\n const { labelHeight, padding, spaceBetween } = AbstractGroup;\n let $left = padding;\n const $top = padding + (this.isRoot ? 0 : labelHeight);\n const { height } = this.layout;\n this.items.forEach((item) => {\n item.layout.offsetLeft = $left;\n item.layout.offsetTop = $top;\n // center the item\n item.layout.offsetTop += (height - (this.isRoot ? 0 : labelHeight) - item.layout.height) / 2 - padding;\n item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft;\n item.layout.top = (this.layout.top || 0) + item.layout.offsetTop;\n item.offset();\n $left += item.layout.width + spaceBetween;\n });\n return this;\n }\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class HSlider extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"hslider\",\n width: 5,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Knob extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"knob\",\n width: 1,\n height: 1.75,\n sizing: \"none\"\n };\n}\n","import type { FaustUIItem } from \"@grame/faustwasm\";\nimport HSlider from \"./HSlider\";\nimport VSlider from \"./VSlider\";\nimport Nentry from \"./Nentry\";\nimport Soundfile from \"./Soundfile\";\nimport Button from \"./Button\";\nimport Checkbox from \"./Checkbox\";\nimport Knob from \"./Knob\";\nimport Menu from \"./Menu\";\nimport Radio from \"./Radio\";\nimport Led from \"./Led\";\nimport Numerical from \"./Numerical\";\nimport HBargraph from \"./HBargraph\";\nimport VBargraph from \"./VBargraph\";\nimport HGroup from \"./HGroup\";\nimport VGroup from \"./VGroup\";\nimport TGroup from \"./TGroup\";\nimport type AbstractItem from \"./AbstractItem\";\nimport type AbstractGroup from \"./AbstractGroup\";\nimport type { TLayoutType } from \"../types\";\n\nexport default class Layout {\n /**\n * Get the rendering type of an item by parsing its metadata\n */\n static predictType(item: FaustUIItem): TLayoutType {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n if (item.meta?.find(meta => meta.style?.startsWith(\"led\"))) return \"led\";\n if (item.meta?.find(meta => meta.style?.startsWith(\"numerical\"))) return \"numerical\";\n return item.type;\n }\n if (item.type === \"hslider\" || item.type === \"nentry\" || item.type === \"vslider\") {\n if (item.meta?.find(meta => meta.style?.startsWith(\"knob\"))) return \"knob\";\n if (item.meta?.find(meta => meta.style?.startsWith(\"menu\"))) return \"menu\";\n if (item.meta?.find(meta => meta.style?.startsWith(\"radio\"))) return \"radio\";\n }\n return item.type;\n }\n /**\n * Get the Layout class constructor of an item\n */\n static getItem(item: FaustUIItem): AbstractItem | AbstractGroup {\n const Ctor = {\n hslider: HSlider,\n vslider: VSlider,\n nentry: Nentry,\n soundfile: Soundfile,\n button: Button,\n checkbox: Checkbox,\n knob: Knob,\n menu: Menu,\n radio: Radio,\n led: Led,\n numerical: Numerical,\n hbargraph: HBargraph,\n vbargraph: VBargraph,\n hgroup: HGroup,\n vgroup: VGroup,\n tgroup: TGroup\n };\n const layoutType = this.predictType(item);\n return new Ctor[layoutType](item as any);\n }\n static getItems(items: FaustUIItem[]) {\n return items.map((item) => {\n if (\"items\" in item) item.items = this.getItems(item.items);\n return this.getItem(item);\n });\n }\n static calc(ui: FaustUIItem[]) {\n const rootGroup = new VGroup({ items: this.getItems(ui), type: \"vgroup\", label: \"\" }, true);\n rootGroup.adjust();\n rootGroup.expand(0, 0);\n rootGroup.offset();\n return rootGroup;\n }\n}\n","import AbstractOutputItem from \"./AbstractOutputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Led extends AbstractOutputItem {\n layout: LayoutProps = {\n type: \"led\",\n width: 1,\n height: 1,\n sizing: \"none\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Menu extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"menu\",\n width: 2,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Nentry extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"nentry\",\n width: 1,\n height: 1,\n sizing: \"none\"\n };\n}\n","import AbstractOutputItem from \"./AbstractOutputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Numerical extends AbstractOutputItem {\n layout: LayoutProps = {\n type: \"numerical\",\n width: 1,\n height: 1,\n sizing: \"none\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class Radio extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"radio\",\n width: 2,\n height: 2, // TODO: vradio and hradio\n sizing: \"both\"\n };\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport { LayoutProps } from \"../types\";\n\nexport default class Soundfile extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"soundfile\",\n width: 2,\n height: 1,\n sizing: \"horizontal\"\n };\n}\n","import AbstractGroup from \"./AbstractGroup\";\n\nexport default class TGroup extends AbstractGroup {\n static tabLayout = {\n width: 2,\n height: 1\n };\n adjust() {\n this.items.forEach((item) => {\n item.adjust();\n this.layout.width = Math.max(this.layout.width, item.layout.width + 2 * AbstractGroup.padding);\n this.layout.height = Math.max(this.layout.height, item.layout.height + 2 * AbstractGroup.padding + TGroup.labelHeight);\n });\n const tabsCount = this.items.length;\n this.layout.width = Math.max(this.layout.width, tabsCount * TGroup.tabLayout.width);\n this.layout.height += TGroup.tabLayout.height;\n if (this.layout.width < 1) this.layout.width += 1;\n return this;\n }\n expand() {\n const tabsCount = this.items.length;\n this.items.forEach((item) => {\n let dY$ = 0; // Space available to expand for current item\n let dX$ = 0;\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"horizontal\") dX$ = this.layout.width - 2 * AbstractGroup.padding - item.layout.width;\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"vertical\") dY$ = this.layout.height - 2 * AbstractGroup.padding - (this.isRoot ? 0 : AbstractGroup.labelHeight) - (tabsCount ? TGroup.tabLayout.height : 0) - item.layout.height;\n item.expand(dX$, dY$);\n });\n return this;\n }\n offset() {\n const { labelHeight, padding } = AbstractGroup;\n const $left = padding;\n const $top = padding + (this.isRoot ? 0 : labelHeight) + TGroup.tabLayout.height;\n this.items.forEach((item) => {\n item.layout.offsetLeft = $left;\n item.layout.offsetTop = $top;\n item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft;\n item.layout.top = (this.layout.top || 0) + item.layout.offsetTop;\n item.offset();\n });\n return this;\n }\n}\n","import AbstractOutputItem from \"./AbstractOutputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class VBargraph extends AbstractOutputItem {\n layout: LayoutProps = {\n type: \"vbargraph\",\n width: 1,\n height: 5,\n sizing: \"vertical\"\n };\n}\n","import AbstractGroup from \"./AbstractGroup\";\n\nexport default class VGroup extends AbstractGroup {\n adjust() {\n this.items.forEach((item) => {\n item.adjust();\n this.layout.width = Math.max(this.layout.width, item.layout.width + 2 * AbstractGroup.padding);\n this.layout.height += item.layout.height;\n });\n this.layout.height += AbstractGroup.spaceBetween * (this.items.length - 1);\n if (this.layout.width < 1) this.layout.width += 1;\n return this;\n }\n expand(dX: number, dY: number) {\n let vExpandItems = 0;\n this.items.forEach((item) => {\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"vertical\") vExpandItems++;\n });\n this.items.forEach((item) => {\n let dX$ = 0;\n let dY$ = 0; // Space available to expand for current item\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"horizontal\") {\n dX$ = this.layout.width - 2 * AbstractGroup.padding - item.layout.width;\n item.layout.width += dX$;\n }\n if (item.layout.sizing === \"both\" || item.layout.sizing === \"vertical\") {\n dY$ = vExpandItems ? dY / vExpandItems : 0;\n item.layout.height += dY$;\n }\n item.expand(dX$, dY$);\n });\n // this.layout.height += dY;\n return this;\n }\n offset() {\n const { labelHeight, padding, spaceBetween } = AbstractGroup;\n const $left = padding;\n let $top = padding + (this.isRoot ? 0 : labelHeight);\n const { width } = this.layout;\n this.items.forEach((item) => {\n item.layout.offsetLeft = $left;\n item.layout.offsetTop = $top;\n // center the item\n item.layout.offsetLeft += (width - item.layout.width) / 2 - padding;\n item.layout.left = (this.layout.left || 0) + item.layout.offsetLeft;\n item.layout.top = (this.layout.top || 0) + item.layout.offsetTop;\n item.offset();\n $top += item.layout.height + spaceBetween;\n });\n return this;\n }\n}\n","import AbstractInputItem from \"./AbstractInputItem\";\nimport type { LayoutProps } from \"../types\";\n\nexport default class VSlider extends AbstractInputItem {\n layout: LayoutProps = {\n type: \"vslider\",\n width: 1,\n height: 5,\n sizing: \"vertical\"\n };\n}\n","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// extracted by mini-css-extract-plugin\nexport {};","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export { default as FaustUI } from \"./FaustUI\";\nexport { default as instantiate } from \"./instantiate\";\n"],"names":["e","label","type","layout","props","key","_a"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/faustwasm/index.d.ts b/docs/gamelan/sinusoide2/faustwasm/index.d.ts new file mode 100644 index 0000000..1443906 --- /dev/null +++ b/docs/gamelan/sinusoide2/faustwasm/index.d.ts @@ -0,0 +1,1585 @@ +// Generated by dts-bundle-generator v9.5.1 + +/// + +export type FaustModuleFactory = EmscriptenModuleFactory; +export interface FaustModule extends EmscriptenModule { + ccall: typeof ccall; + cwrap: typeof cwrap; + UTF8ArrayToString(u8Array: number[], ptr: number, maxBytesToRead?: number): string; + stringToUTF8Array(str: string, outU8Array: number[], outIdx: number, maxBytesToWrite: number): number; + UTF8ToString: typeof UTF8ToString; + UTF16ToString: typeof UTF16ToString; + UTF32ToString: typeof UTF32ToString; + stringToUTF8: typeof stringToUTF8; + stringToUTF16: typeof stringToUTF16; + stringToUTF32: typeof stringToUTF32; + allocateUTF8: typeof allocateUTF8; + lengthBytesUTF8: typeof lengthBytesUTF8; + lengthBytesUTF16: typeof lengthBytesUTF16; + lengthBytesUTF32: typeof lengthBytesUTF32; + FS: typeof FS; + libFaustWasm: new () => LibFaustWasm; +} +export type FaustInfoType = "help" | "version" | "libdir" | "includedir" | "archdir" | "dspdir" | "pathslist"; +export interface IntVector { + size(): number; + get(i: number): number; + delete(): void; +} +export interface FaustDspWasm { + cfactory: number; + data: IntVector; + json: string; +} +export interface LibFaustWasm { + /** + * Return the Faust compiler version. + * + * @returns the version + */ + version(): string; + /** + * Create a dsp factory from Faust code. + * + * @param name - an arbitrary name for the Faust module + * @param code - Faust dsp code + * @param args - the compiler options + * @param useInternalMemory - tell the compiler to generate static embedded memory or not + * @returns an opaque reference to the factory + */ + createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm; + /** + * Delete a dsp factory. + * + * @param cFactory - the factory C++ internal pointer as a number + */ + deleteDSPFactory(cFactory: number): void; + /** + * Expand Faust code i.e. linearize included libraries. + * + * @param name - an arbitrary name for the Faust module + * @param code - Faust dsp code + * @param args - the compiler options + * @returns return the expanded dsp code + */ + expandDSP(name: string, code: string, args: string): string; + /** + * Generates auxiliary files from Faust code. The output depends on the compiler options. + * + * @param name - an arbitrary name for the faust module + * @param code - Faust dsp code + * @param args - the compiler options + */ + generateAuxFiles(name: string, code: string, args: string): boolean; + /** + * Delete all existing dsp factories. + */ + deleteAllDSPFactories(): void; + /** + * Exception management: gives an error string + */ + getErrorAfterException(): string; + /** + * Exception management: cleanup + * Should be called after each exception generated by the LibFaust methods. + */ + cleanupAfterException(): void; + /** + * Get info about the embedded Faust engine + * @param what - the requested info + */ + getInfos(what: FaustInfoType): string; +} +export interface FaustDspFactory extends Required { +} +/** + * The Factory structure. + */ +export interface LooseFaustDspFactory { + /** a "pointer" (as an integer) on the internal C++ factory */ + cfactory?: number; + /** the WASM code as a binary array */ + code?: Uint8Array; + /** the compule WASM module */ + module: WebAssembly.Module; + /** the compiled DSP JSON description */ + json: string; + /** whether the factory is a polyphonic one or not */ + poly?: boolean; + /** a unique identifier */ + shaKey?: string; + /** a map of transferable audio buffers for the `soundfile` function */ + soundfiles: Record; +} +export interface FaustDspMeta { + name: string; + filename: string; + compile_options: string; + include_pathnames: string[]; + inputs: number; + outputs: number; + size: number; + version: string; + library_list: string[]; + meta: { + [key: string]: string; + }[]; + ui: FaustUIDescriptor; +} +export type FaustUIDescriptor = FaustUIGroup[]; +export type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup; +export interface FaustUIInputItem { + type: FaustUIInputType; + label: string; + address: string; + url: string; + index: number; + init?: number; + min?: number; + max?: number; + step?: number; + meta?: FaustUIMeta[]; +} +export interface FaustUIOutputItem { + type: FaustUIOutputType; + label: string; + address: string; + index: number; + min?: number; + max?: number; + meta?: FaustUIMeta[]; +} +export interface FaustUIMeta { + [order: number]: string; + style?: string; + unit?: string; + scale?: "linear" | "exp" | "log"; + tooltip?: string; + hidden?: string; + [key: string]: string | undefined; +} +export type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup"; +export type FaustUIOutputType = "hbargraph" | "vbargraph"; +export type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry" | "soundfile"; +export interface FaustUIGroup { + type: FaustUIGroupType; + label: string; + items: FaustUIItem[]; +} +export type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType; +export interface AudioParamDescriptor { + automationRate?: AutomationRate; + defaultValue?: number; + maxValue?: number; + minValue?: number; + name: string; +} +export interface AudioWorkletProcessor { + port: MessagePort; + process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record): boolean; +} +export declare const AudioWorkletProcessor: { + prototype: AudioWorkletProcessor; + parameterDescriptors: AudioParamDescriptor[]; + new (options: AudioWorkletNodeOptions): AudioWorkletProcessor; +}; +export interface AudioWorkletGlobalScope { + AudioWorkletGlobalScope: any; + globalThis: AudioWorkletGlobalScope; + registerProcessor: (name: string, constructor: new (options: any) => AudioWorkletProcessor) => void; + currentFrame: number; + currentTime: number; + sampleRate: number; + AudioWorkletProcessor: typeof AudioWorkletProcessor; +} +export interface InterfaceFFT { + forward(arr: ArrayLike | ((arr: Float32Array) => any)): Float32Array; + inverse(arr: ArrayLike | ((arr: Float32Array) => any)): Float32Array; + dispose(): void; +} +export declare const InterfaceFFT: { + new (size: number): InterfaceFFT; +}; +export type TWindowFunction = (index: number, length: number, ...args: any[]) => number; +export type Writeable = { + -readonly [P in keyof T]: T[P]; +}; +export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array; +export type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array; +export declare const FFTUtils: { + /** Inject window functions as array, no need to add rectangular (no windowing) */ + windowFunctions?: TWindowFunction[]; + /** Get a FFT interface constructor */ + getFFT: () => Promise; + /** Convert from FFTed (spectral) signal to three arrays for Faust processor's input, fft is readonly, real/imag/index length = *fftSize* / 2 + 1; fft length depends on the FFT implementation */ + fftToSignal: (fft: Float32Array | Float64Array, real: Float32Array | Float64Array, imag?: Float32Array | Float64Array, index?: Float32Array | Float64Array) => any; + /** Convert from Faust processor's output to spectral data for Inversed FFT, real/imag are readonly, real/imag length = *fftSize* / 2 + 1; fft length depends on the FFT implementation */ + signalToFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any; + /** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */ + signalToNoFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any; +}; +export interface AudioData { + sampleRate: number; + audioBuffer: Float32Array[]; +} +/** + * Load libfaust-wasm files, than instantiate libFaust + * @param jsFile path to `libfaust-wasm.js` + * @param dataFile path to `libfaust-wasm.data` + * @param wasmFile path to `libfaust-wasm.wasm` + */ +export declare const instantiateFaustModuleFromFile: (jsFile: string, dataFile?: string, wasmFile?: string) => Promise; +/** + * The Faust wasm instance interface. + */ +export interface IFaustDspInstance { + /** + * The dsp computation, to be called with successive input/output audio buffers. + * + * @param $dsp - the DSP pointer + * @param count - the audio buffer size in frames + * @param $inputs - the input audio buffer as in index in wasm memory + * @param $output - the output audio buffer as in index in wasm memory + */ + compute($dsp: number, count: number, $inputs: number, $output: number): void; + /** + * Give the number of inputs of a Faust wasm instance. + * + * @param $dsp - the DSP pointer + */ + getNumInputs($dsp: number): number; + /** + * Give the number of outputs of a Faust wasm instance. + * + * @param $dsp - the DSP pointer + */ + getNumOutputs($dsp: number): number; + /** + * Give a parameter current value. + * + * @param $dsp - the DSP pointer + * @param index - the parameter index + * @return the parameter value + */ + getParamValue($dsp: number, index: number): number; + /** + * Give the Faust wasm instance sample rate. + * + * @param $dsp - the DSP pointer + * @return the sample rate + */ + getSampleRate($dsp: number): number; + /** + * Global init, calls the following methods: + * - static class 'classInit': static tables initialization + * - 'instanceInit': constants and instance state initialization + * + * @param $dsp - the DSP pointer + * @param sampleRate - the sampling rate in Hertz + */ + init($dsp: number, sampleRate: number): void; + /** Init instance state (delay lines...). + * + * @param $dsp - the DSP pointer + */ + instanceClear($dsp: number): void; + /** Init instance constant state. + * + * @param $dsp - the DSP pointer + * @param sampleRate - the sampling rate in Hertz + */ + instanceConstants($dsp: number, sampleRate: number): void; + /** Init instance state. + * + * @param $dsp - the DSP pointer + * @param sampleRate - the sampling rate in Hertz + */ + instanceInit($dsp: number, sampleRate: number): void; + /** Init default control parameters values. + * + * @param $dsp - the DSP pointer + */ + instanceResetUserInterface($dsp: number): void; + /** + * Set a parameter current value. + * + * @param $dsp - the DSP pointer + * @param index - the parameter index + * @param value - the parameter value + */ + setParamValue($dsp: number, index: number, value: number): void; +} +/** + * Mixer used in polyphonic mode. + */ +export interface IFaustMixerInstance { + clearOutput(bufferSize: number, chans: number, $outputs: number): void; + mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number; + fadeOut(bufferSize: number, chans: number, $outputs: number): void; +} +/** + * Monophonic instance. + */ +export interface FaustMonoDspInstance { + memory: WebAssembly.Memory; + api: IFaustDspInstance; + json: string; +} +/** + * Polyphonic instance. + */ +export interface FaustPolyDspInstance { + memory: WebAssembly.Memory; + voices: number; + voiceAPI: IFaustDspInstance; + effectAPI?: IFaustDspInstance; + mixerAPI: IFaustMixerInstance; + voiceJSON: string; + effectJSON?: string; +} +export declare class FaustDspInstance implements IFaustDspInstance { + private readonly fExports; + constructor(exports: IFaustDspInstance); + compute($dsp: number, count: number, $input: number, $output: number): void; + getNumInputs($dsp: number): number; + getNumOutputs($dsp: number): number; + getParamValue($dsp: number, index: number): number; + getSampleRate($dsp: number): number; + init($dsp: number, sampleRate: number): void; + instanceClear($dsp: number): void; + instanceConstants($dsp: number, sampleRate: number): void; + instanceInit($dsp: number, sampleRate: number): void; + instanceResetUserInterface($dsp: number): void; + setParamValue($dsp: number, index: number, value: number): void; +} +export declare class FaustWasmInstantiator { + private static createWasmImport; + private static createWasmMemoryPoly; + private static createWasmMemoryMono; + private static createMonoDSPInstanceAux; + private static createMemoryMono; + private static createMemoryPoly; + private static createMixerAux; + static loadDSPFactory(wasmPath: string, jsonPath: string): Promise; + static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise; + static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise; + static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance; + static createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise; + static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance; +} +export type OutputParamHandler = (path: string, value: number) => void; +export type ComputeHandler = (buffer_size: number) => void; +export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { + type: string; + data: any; +}[]) => void; +export type MetadataHandler = (key: string, value: string) => void; +export type UIHandler = (item: FaustUIItem) => void; +export type SensorEventHandler = (val: number) => void; +export type SensorEventHandlers = { + x: SensorEventHandler[]; + y: SensorEventHandler[]; + z: SensorEventHandler[]; +}; +/** Definition of the AudioBufferItem type */ +export interface AudioBufferItem { + pathName: string; + audioBuffer: AudioBuffer; +} +/** Definition of the SoundfileItem type */ +export interface SoundfileItem { + /** Name of the soundfile */ + name: string; + /** URL of the soundfile */ + url: string; + /** Index in the DSP struct */ + index: number; + /** Base pointer in wasm memory */ + basePtr: number; +} +/** + * WasmAllocator is a basic memory management class designed to allocate + * blocks of memory within a WebAssembly.Memory object. It provides a simple + * alloc method to allocate a contiguous block of memory of a specified size. + * + * The allocator operates by keeping a linear progression through the memory, + * always allocating the next block at the end of the last. This approach does not + * handle freeing of memory or reuse of memory spaces. + */ +export declare class WasmAllocator { + private readonly memory; + private allocatedBytes; + constructor(memory: WebAssembly.Memory, offset: number); + /** + * Allocates a block of memory of the specified size, returning the pointer to the + * beginning of the block. The block is allocated at the current offset and the + * offset is incremented by the size of the block. + * + * @param sizeInBytes The size of the block to allocate in bytes. + * @returns The offset (pointer) to the beginning of the allocated block. + */ + alloc(sizeInBytes: number): number; + /** + * Returns the underlying buffer object. + * + * @returns The buffer object. + */ + getBuffer(): ArrayBuffer; + /** + * Returns the Int32 view of the underlying buffer object. + * + * @returns The view of the memory buffer as Int32Array. + */ + getInt32Array(): Int32Array; + /** + * Returns the Int64 view of the underlying buffer object. + * + * @returns The view of the memory buffer as BigInt64Array. + */ + getInt64Array(): BigInt64Array; + /** + * Returns the Float32 view of the underlying buffer object. + * + * @returns The view of the memory buffer as Float32Array. + */ + getFloat32Array(): Float32Array; + /** + * Returns the Float64 view of the underlying buffer object.. + * + * @returns The view of the memory buffer as Float64Array. + */ + getFloat64Array(): Float64Array; +} +/** + * Soundfile class to handle soundfile data in wasm memory. + */ +export declare class Soundfile { + /** Maximum number of soundfile parts. */ + static get MAX_SOUNDFILE_PARTS(): number; + /** Maximum number of channels. */ + static get MAX_CHAN(): number; + /** Maximum buffer size in frames. */ + static get BUFFER_SIZE(): number; + /** Default sample rate. */ + static get SAMPLE_RATE(): number; + /** Pointer to the soundfile structure in wasm memory */ + private readonly fPtr; + private readonly fBuffers; + private readonly fLength; + private readonly fSR; + private readonly fOffset; + private readonly fSampleSize; + private readonly fPtrSize; + private readonly fIntSize; + private readonly fAllocator; + constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number); + private allocBuffers; + shareBuffers(curChan: number, maxChan: number): void; + copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData): void; + copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData): void; + copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData): void; + emptyFile(part: number, offset: number): number; + displayMemory(where?: string, mem?: boolean): void; + getPtr(): number; + getHEAP32(): Int32Array; + getHEAPFloat32(): Float32Array; + getHEAPFloat64(): Float64Array; +} +/** + * DSP implementation that mimic the C++ 'dsp' class: + * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers + * - an output handler can be set to treat produced output controllers (like 'bargraph') + * - regular controllers are handled using setParamValue/getParamValue and getParams methods + */ +export interface IFaustBaseWebAudioDsp { + /** + * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph). + * + * @param handler - the output handler + */ + setOutputParamHandler(handler: OutputParamHandler | null): void; + /** + * Get the parameter output handler. + * + * @return the current output handler + */ + getOutputParamHandler(): OutputParamHandler | null; + /** + * Set the compute handler, to be called in the 'compute' method with buffer size. + * + * @param handler - the compute handler + */ + setComputeHandler(handler: ComputeHandler | null): void; + /** + * Get the compute handler. + * + * @return the current output handler + */ + getComputeHandler(): ComputeHandler | null; + /** + * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type). + * + * @param handler - the plot handler + */ + setPlotHandler(handler: PlotHandler | null): void; + /** + * Get the plot handler. + * + * @return the current plot handler + */ + getPlotHandler(): PlotHandler | null; + /** + * Return instance number of audio inputs. + * + * @return the instance number of audio inputs + */ + getNumInputs(): number; + /** + * Return instance number of audio outputs. + * + * @return the instance number of audio outputs + */ + getNumOutputs(): number; + /** + * DSP instance computation, to be called with successive input/output audio buffers, using their size. + * + * @param inputs - the input audio buffers + * @param outputs - the output audio buffers + */ + compute(inputs: Float32Array[], outputs: Float32Array[]): boolean; + /** + * Give a handler to be called on 'declare key value' kind of metadata. + * + * @param handler - the handler to be used + */ + metadata(handler: MetadataHandler): void; + /** + * Handle untyped MIDI messages. + * + * @param data - and arry of MIDI bytes + */ + midiMessage(data: number[] | Uint8Array): void; + /** + * Handle MIDI ctrlChange messages. + * + * @param channel - the MIDI channel (0..15, not used for now) + * @param ctrl - the MIDI controller number (0..127) + * @param value - the MIDI controller value (0..127) + */ + ctrlChange(chan: number, ctrl: number, value: number): void; + /** + * Handle MIDI pitchWheel messages. + * + * @param channel - the MIDI channel (0..15, not used for now) + * @param value - the MIDI controller value (0..16383) + */ + pitchWheel(chan: number, value: number): void; + /** + * Set parameter value. + * + * @param path - the path to the wanted parameter (retrieved using 'getParams' method) + * @param val - the float value for the wanted control + */ + setParamValue(path: string, value: number): void; + /** + * Get parameter value. + * + * @param path - the path to the wanted parameter (retrieved using 'getParams' method) + * + * @return the float value + */ + getParamValue(path: string): number; + /** + * Get the table of all input parameters paths. + * + * @return the table of all input parameters paths + */ + getParams(): string[]; + /** + * Get DSP JSON description with its UI and metadata as object. + * + * @return the DSP JSON description as object + */ + getMeta(): FaustDspMeta; + /** + * Get DSP UI description. + * + * @return the DSP UI description + */ + getUI(): FaustUIDescriptor; + /** + * Get DSP UI items description. + * + * @return the DSP UI items description + */ + getDescriptors(): FaustUIInputItem[]; + /** + * Get DSP JSON description with its UI and metadata. + * + * @return the DSP JSON description + */ + getJSON(): string; + /** + * Start the DSP. + */ + start(): void; + /** + * Stop the DSP. + */ + stop(): void; + /** + * Destroy the DSP. + */ + destroy(): void; + /** Indicating if the DSP handles the accelerometer */ + readonly hasAccInput: boolean; + /** Accelerometer handling */ + propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void; + /** Indicating if the DSP handles the gyroscope */ + readonly hasGyrInput: boolean; + /** Gyroscope handling */ + propagateGyr(event: Pick): void; +} +export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { +} +export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { +} +export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp { + /** + * Handle MIDI keyOn messages. + * + * @param channel - the MIDI channel (0..15, not used for now) + * @param pitch - the MIDI pitch value (0..127) + * @param velocity - the MIDI velocity value (0..127) + */ + keyOn(channel: number, pitch: number, velocity: number): void; + /** + * Handle MIDI keyOff messages. + * + * @param channel - the MIDI channel (0..15, not used for now) + * @param pitch - the MIDI pitch value (0..127) + * @param velocity - the MIDI velocity value (0..127) + */ + keyOff(channel: number, pitch: number, velocity: number): void; + /** + * Stop all playing notes. + * + * @param hard - whether to immediately stop notes or put them in release mode + */ + allNotesOff(hard: boolean): void; +} +export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { +} +export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp { + protected fOutputHandler: OutputParamHandler | null; + protected fComputeHandler: ComputeHandler | null; + protected fPlotHandler: PlotHandler | null; + protected fCachedEvents: { + type: string; + data: any; + }[]; + protected fBufferNum: number; + protected fInChannels: Float32Array[] | Float64Array[]; + protected fOutChannels: Float32Array[] | Float64Array[]; + protected fOutputsTimer: number; + protected fInputsItems: string[]; + protected fOutputsItems: string[]; + protected fDescriptor: FaustUIInputItem[]; + protected fSoundfiles: SoundfileItem[]; + protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"]; + /** Keep the end of memory offset before soundfiles */ + protected fEndMemory: number; + protected fAcc: SensorEventHandlers; + protected fGyr: SensorEventHandlers; + protected fAudioInputs: number; + protected fAudioOutputs: number; + protected fBufferSize: number; + protected fPtrSize: number; + protected fSampleSize: number; + protected fPitchwheelLabel: { + path: string; + chan: number; + min: number; + max: number; + }[]; + protected fCtrlLabel: { + path: string; + chan: number; + min: number; + max: number; + }[][]; + protected fPathTable: { + [address: string]: number; + }; + protected fUICallback: UIHandler; + protected fProcessing: boolean; + protected fDestroyed: boolean; + protected fFirstCall: boolean; + protected fJSONDsp: FaustDspMeta; + constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]); + static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number; + static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void; + static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void; + static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void; + static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void; + /** Split the soundfile names and return an array of names */ + static splitSoundfileNames(input: string): string[]; + get hasAccInput(): boolean; + propagateAcc(accelerationIncludingGravity: NonNullable, invert?: boolean): void; + get hasGyrInput(): boolean; + propagateGyr(event: Pick): void; + /** Build the accelerometer handler */ + private setupAccHandler; + /** Build the gyroscope handler */ + private setupGyrHandler; + static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[]; + /** + * Load a soundfile possibly containing several parts in the DSP struct. + * Soundfile pointers are located at 'index' offset, to be read in the JSON file. + * The DSP struct is located at baseDSP in the wasm memory, + * either a monophonic DSP, or a voice in a polyphonic context. + * + * @param allocator : the wasm memory allocator + * @param baseDSP : the base DSP in the wasm memory + * @param name : the name of the soundfile + * @param url : the url of the soundfile + */ + private loadSoundfile; + createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory["soundfiles"], maxChan?: number): Soundfile; + /** + * Init soundfiles memory. + * + * @param allocator : the wasm memory allocator + * @param sfReader : the soundfile reader + * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory + */ + protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void; + protected updateOutputs(): void; + metadata(handler: MetadataHandler): void; + compute(input: Float32Array[], output: Float32Array[]): boolean; + setOutputParamHandler(handler: OutputParamHandler | null): void; + getOutputParamHandler(): OutputParamHandler | null; + setComputeHandler(handler: ComputeHandler | null): void; + getComputeHandler(): ComputeHandler | null; + setPlotHandler(handler: PlotHandler | null): void; + getPlotHandler(): PlotHandler | null; + getNumInputs(): number; + getNumOutputs(): number; + midiMessage(data: number[] | Uint8Array): void; + ctrlChange(channel: number, ctrl: number, value: number): void; + pitchWheel(channel: number, wheel: number): void; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getParams(): string[]; + getMeta(): FaustDspMeta; + getJSON(): string; + getUI(): FaustUIDescriptor; + getDescriptors(): FaustUIInputItem[]; + hasSoundfiles(): boolean; + start(): void; + stop(): void; + destroy(): void; +} +export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp { + private fInstance; + private fDSP; + constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]); + private initMemory; + toString(): string; + compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean; + metadata(handler: MetadataHandler): void; + getNumInputs(): number; + getNumOutputs(): number; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getMeta(): FaustDspMeta; + getJSON(): string; + getDescriptors(): FaustUIInputItem[]; + getUI(): FaustUIDescriptor; +} +export declare class FaustWebAudioDspVoice { + static get kActiveVoice(): number; + static get kFreeVoice(): number; + static get kReleaseVoice(): number; + static get kLegatoVoice(): number; + static get kNoVoice(): number; + static get VOICE_STOP_LEVEL(): number; + private fFreqLabel; + private fGateLabel; + private fGainLabel; + private fKeyLabel; + private fVelLabel; + private fDSP; + private fAPI; + fCurNote: number; + fNextNote: number; + fNextVel: number; + fDate: number; + fLevel: number; + fRelease: number; + constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { + [address: string]: number; + }, sampleRate: number); + static midiToFreq(note: number): number; + static normalizeVelocity(velocity: number): number; + private extractPaths; + keyOn(pitch: number, velocity: number, legato?: boolean): void; + keyOff(hard?: boolean): void; + computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void; + compute(bufferSize: number, $inputs: number, $outputs: number): void; + setParamValue(index: number, value: number): void; + getParamValue(index: number): number; +} +export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp { + private fInstance; + private fEffect; + private fJSONEffect; + private fAudioMixing; + private fAudioMixingHalf; + private fVoiceTable; + constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]); + private initMemory; + toString(): string; + private allocVoice; + private getPlayingVoice; + private getFreeVoice; + compute(input: Float32Array[], output: Float32Array[]): boolean; + getNumInputs(): number; + getNumOutputs(): number; + private static findPath; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getMeta(): FaustDspMeta; + getJSON(): string; + getUI(): FaustUIDescriptor; + getDescriptors(): FaustUIInputItem[]; + midiMessage(data: number[] | Uint8Array): void; + ctrlChange(channel: number, ctrl: number, value: number): void; + keyOn(channel: number, pitch: number, velocity: number): void; + keyOff(channel: number, pitch: number, velocity: number): void; + allNotesOff(hard?: boolean): void; +} +/** + * Injected in the string to be compiled on AudioWorkletProcessor side + */ +export interface FaustData { + processorName: string; + dspName: string; + dspMeta: FaustDspMeta; + poly: boolean; + effectMeta?: FaustDspMeta; +} +export interface FaustAudioWorkletProcessorDependencies { + FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp; + FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp; + FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined; + FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined; + FaustWasmInstantiator: typeof FaustWasmInstantiator; +} +export interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions { + processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions; +} +export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions { + processorOptions: FaustMonoAudioWorkletProcessorOptions; +} +export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions { + processorOptions: FaustPolyAudioWorkletProcessorOptions; +} +export interface FaustAudioWorkletProcessorOptions { + name: string; + sampleSize: number; + moduleId?: string; + instanceId?: string; +} +export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions { + factory: LooseFaustDspFactory; +} +export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions { + voiceFactory: LooseFaustDspFactory; + mixerModule: WebAssembly.Module; + voices: number; + effectFactory?: LooseFaustDspFactory; +} +export declare const getFaustAudioWorkletProcessor: (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register?: boolean) => { + new (options: AudioWorkletNodeOptions): AudioWorkletProcessor; + prototype: AudioWorkletProcessor; + parameterDescriptors: AudioParamDescriptor[]; +}; +export interface FaustFFTOptionsData { + fftSize: number; + fftOverlap: number; + noIFFT: boolean; + /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */ + defaultWindowFunction: number; +} +/** + * Injected in the string to be compiled on AudioWorkletProcessor side + */ +export interface FaustFFTData { + processorName: string; + dspName: string; + dspMeta: FaustDspMeta; + fftOptions?: Partial; +} +export interface FaustFFTAudioWorkletProcessorDependencies { + FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp; + FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp; + FaustWasmInstantiator: typeof FaustWasmInstantiator; + FFTUtils: typeof FFTUtils; +} +export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions { + processorOptions: FaustFFTAudioWorkletProcessorOptions; +} +export interface FaustFFTAudioWorkletProcessorOptions { + name: string; + sampleSize: number; + factory: LooseFaustDspFactory; + moduleId?: string; + instanceId?: string; +} +export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => { + new (options: AudioWorkletNodeOptions): AudioWorkletProcessor; + prototype: AudioWorkletProcessor; + parameterDescriptors: AudioParamDescriptor[]; +}; +export interface ILibFaust extends LibFaustWasm { + module(): FaustModule; + fs(): typeof FS; +} +export declare class LibFaust implements ILibFaust { + private fModule; + private fCompiler; + private fFileSystem; + constructor(module: FaustModule); + module(): FaustModule; + fs(): typeof FS; + version(): string; + createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm; + deleteDSPFactory(cFactory: number): void; + expandDSP(name: string, code: string, args: string): string; + generateAuxFiles(name: string, code: string, args: string): boolean; + deleteAllDSPFactories(): void; + getErrorAfterException(): string; + cleanupAfterException(): void; + getInfos(what: FaustInfoType): string; + toString(): string; +} +export declare const ab2str: (buf: Uint8Array) => any; +export declare const str2ab: (str: string) => Uint8Array; +export interface IFaustCompiler { + /** + * Gives the Faust compiler version. + * @return a version string + */ + version(): string; + /** + * Gives the last compilation error. + * @return an error string + */ + getErrorMessage(): string; + /** + * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. + * This function is running asynchronously. + * + * @param name - an arbitrary name for the Faust factory + * @param code - Faust dsp code + * @param args - the compiler options + * @returns returns the wasm factory + */ + createMonoDSPFactory(name: string, code: string, args: string): Promise; + /** + * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. + * This function is running asynchronously. + * + * @param name - an arbitrary name for the Faust factory + * @param code - Faust dsp code + * @param args - the compiler options + * @returns returns the wasm factory + */ + createPolyDSPFactory(name: string, code: string, args: string): Promise; + /** + * Delete a dsp factory. + * + * @param factory - the factory to be deleted + */ + deleteDSPFactory(factory: FaustDspFactory): void; + /** + * Expand Faust code i.e. linearize included libraries. + * + * @param code - Faust dsp code + * @param args - the compiler options + * @returns returns the expanded dsp code + */ + expandDSP(code: string, args: string): string | null; + /** + * Generates auxiliary files from Faust code. The output depends on the compiler options. + * + * @param name - an arbitrary name for the Faust module + * @param code - Faust dsp code + * @param args - the compiler options + * @returns whether the generation actually succeded + */ + generateAuxFiles(name: string, code: string, args: string): boolean; + /** + * Delete all factories. + */ + deleteAllDSPFactories(): void; + fs(): typeof FS; + getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ + mixerBuffer: Uint8Array; + mixerModule: WebAssembly.Module; + }>; + getSyncInternalMixerModule(isDouble?: boolean): { + mixerBuffer: Uint8Array; + mixerModule: WebAssembly.Module; + }; +} +export declare class FaustCompiler implements IFaustCompiler { + private fLibFaust; + private fErrorMessage; + private static gFactories; + private mixer32Buffer; + private mixer64Buffer; + private mixer32Module; + private mixer64Module; + /** + * Get a stringified DSP factories table + */ + static serializeDSPFactories(): Record; + /** + * Get a stringified DSP factories table as string + */ + static stringifyDSPFactories(): string; + /** + * Import a DSP factories table + */ + static deserializeDSPFactories(table: Record): Promise[]>; + /** + * Import a stringified DSP factories table + */ + static importDSPFactories(tableStr: string): Promise[]>; + constructor(libFaust: ILibFaust); + private intVec2intArray; + private createDSPFactory; + version(): string; + getErrorMessage(): string; + createMonoDSPFactory(name: string, code: string, args: string): Promise; + createPolyDSPFactory(name: string, code: string, args: string): Promise; + deleteDSPFactory(factory: FaustDspFactory): void; + expandDSP(code: string, args: string): string; + generateAuxFiles(name: string, code: string, args: string): boolean; + deleteAllDSPFactories(): void; + fs(): typeof FS; + getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ + mixerBuffer: Uint8Array; + mixerModule: WebAssembly.Module; + }>; + getSyncInternalMixerModule(isDouble?: boolean): { + mixerBuffer: Uint8Array; + mixerModule: WebAssembly.Module; + }; +} +/** + * For offline rendering. + */ +export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp { + render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[]; +} +export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { +} +export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { +} +export declare class FaustOfflineProcessor { + protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp; + protected fBufferSize: number; + protected fInputs: Float32Array[]; + protected fOutputs: Float32Array[]; + constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number); + getParameterDescriptors(): AudioParamDescriptor[]; + compute(input: Float32Array[], output: Float32Array[]): boolean; + setOutputParamHandler(handler: OutputParamHandler): void; + getOutputParamHandler(): OutputParamHandler | null; + setComputeHandler(handler: ComputeHandler): void; + getComputeHandler(): ComputeHandler | null; + setPlotHandler(handler: PlotHandler): void; + getPlotHandler(): PlotHandler | null; + getNumInputs(): number; + getNumOutputs(): number; + metadata(handler: MetadataHandler): void; + midiMessage(data: number[] | Uint8Array): void; + ctrlChange(chan: number, ctrl: number, value: number): void; + pitchWheel(chan: number, value: number): void; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getParams(): string[]; + getMeta(): FaustDspMeta; + getJSON(): string; + getDescriptors(): FaustUIInputItem[]; + getUI(): FaustUIDescriptor; + start(): void; + stop(): void; + destroy(): void; + get hasAccInput(): boolean; + propagateAcc(accelerationIncludingGravity: NonNullable, invert?: boolean): void; + get hasGyrInput(): boolean; + propagateGyr(event: Pick): void; + /** + * Render frames in an array. + * + * @param inputs - input signal + * @param length - the number of frames to render (default: bufferSize) + * @param onUpdate - a callback after each buffer calculated, with an argument "current sample" + * @return an array of Float32Array with the rendered frames + */ + render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[]; +} +export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp { +} +export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp { + keyOn(channel: number, pitch: number, velocity: number): void; + keyOff(channel: number, pitch: number, velocity: number): void; + allNotesOff(hard: boolean): void; +} +export interface IFaustSvgDiagrams { + /** + * Generates auxiliary files from Faust code. The output depends on the compiler options. + * + * @param name - the DSP's name + * @param code - Faust code + * @param args - compilation args + * @returns the svg diagrams as a filename - svg string map + */ + from(name: string, code: string, args: string): Record; +} +export declare class FaustSvgDiagrams implements IFaustSvgDiagrams { + private compiler; + constructor(compiler: FaustCompiler); + from(name: string, code: string, args: string): Record; +} +export interface IFaustCmajor { + /** + * Generates auxiliary files from Faust code. The output depends on the compiler options. + * + * @param name - the DSP's name + * @param code - Faust code + * @param args - compilation args + * @returns the Cmajor compiled string + */ + compile(name: string, code: string, args: string): string; +} +export declare class FaustCmajor implements IFaustCmajor { + private fCompiler; + constructor(compiler: FaustCompiler); + compile(name: string, code: string, args: string): string; +} +export interface WavEncoderOptions { + bitDepth: number; + float?: boolean; + symmetric?: boolean; + shared?: boolean; + sampleRate: number; +} +/** + * Code from https://github.com/mohayonao/wav-encoder + */ +export declare class WavEncoder { + static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer; + private static writeHeader; + private static writeData; +} +export interface WavDecoderOptions { + symmetric?: boolean; + shared?: boolean; +} +/** + * Code from https://github.com/mohayonao/wav-decoder + */ +export declare class WavDecoder { + static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): { + numberOfChannels: number; + length: number; + sampleRate: number; + channelData: Float32Array[]; + }; + private static decodeFormat; + private static decodeData; + private static readPCM; +} +/** Read metadata and fetch soundfiles */ +export declare class SoundfileReader { + static get fallbackPaths(): string[]; + /** + * Extract the parent URL from an URL. + * @param url : the URL + * @returns : the parent URL + */ + private static getParentUrl; + /** + * Convert an audio buffer to audio data. + * + * @param audioBuffer : the audio buffer to convert + * @returns : the audio data + */ + private static toAudioData; + /** + * Extract the URLs from the metadata. + * + * @param dspMeta : the metadata + * @returns : the URLs + */ + static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"]; + /** + * Check if the file exists. + * + * @param url : the url of the file to check + * @returns : true if the file exists, otherwise false + */ + private static checkFileExists; + /** + * Fetch the soundfile. + * + * @param url : the url of the soundfile + * @param audioCtx : the audio context + * @returns : the audio data + */ + private static fetchSoundfile; + /** + * Load the soundfile. + * + * @param filename : the filename + * @param metaUrls : the metadata URLs + * @param soundfiles : the soundfiles + * @param audioCtx : the audio context + */ + private static loadSoundfile; + /** + * Load the soundfiles, public API. + * + * @param dspMeta : the metadata + * @param soundfilesIn : the soundfiles + * @param audioCtx : the audio context + * @returns : the soundfiles + */ + static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise; +} +declare const FaustAudioWorkletNode_base: { + new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode; + prototype: AudioWorkletNode; +}; +/** + * Base class for Monophonic and Polyphonic AudioWorkletNode + */ +export declare class FaustAudioWorkletNode extends FaustAudioWorkletNode_base { + #private; + protected fJSONDsp: FaustDspMeta; + protected fJSON: string; + protected fInputsItems: string[]; + protected fOutputHandler: OutputParamHandler | null; + protected fComputeHandler: ComputeHandler | null; + protected fPlotHandler: PlotHandler | null; + protected fUICallback: UIHandler; + protected fDescriptor: FaustUIInputItem[]; + constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial>); + private handleDeviceMotion; + private handleDeviceOrientation; + /** Setup accelerometer and gyroscope handlers */ + startSensors(): Promise; + stopSensors(): void; + setOutputParamHandler(handler: OutputParamHandler | null): void; + getOutputParamHandler(): OutputParamHandler | null; + setComputeHandler(handler: ComputeHandler | null): void; + getComputeHandler(): ComputeHandler | null; + setPlotHandler(handler: PlotHandler | null): void; + getPlotHandler(): PlotHandler | null; + setupWamEventHandler(): void; + getNumInputs(): number; + getNumOutputs(): number; + compute(inputs: Float32Array[], outputs: Float32Array[]): boolean; + metadata(handler: MetadataHandler): void; + midiMessage(data: number[] | Uint8Array): void; + ctrlChange(channel: number, ctrl: number, value: number): void; + pitchWheel(channel: number, wheel: number): void; + get hasAccInput(): boolean; + propagateAcc(accelerationIncludingGravity: NonNullable, invert?: boolean): void; + get hasGyrInput(): boolean; + propagateGyr(event: Pick): void; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getParams(): string[]; + getMeta(): FaustDspMeta; + getJSON(): string; + getUI(): FaustUIDescriptor; + getDescriptors(): FaustUIInputItem[]; + start(): void; + stop(): void; + destroy(): void; +} +/** + * Monophonic AudioWorkletNode + */ +export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp { + onprocessorerror: (e: Event) => never; + constructor(context: BaseAudioContext, options: Partial> & Pick, "processorOptions">); +} +/** + * Polyphonic AudioWorkletNode + */ +export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp { + private fJSONEffect; + onprocessorerror: (e: Event) => never; + constructor(context: BaseAudioContext, options: Partial> & Pick, "processorOptions">); + keyOn(channel: number, pitch: number, velocity: number): void; + keyOff(channel: number, pitch: number, velocity: number): void; + allNotesOff(hard: boolean): void; + getMeta(): FaustDspMeta; + getJSON(): string; + getUI(): FaustUIDescriptor; +} +declare const FaustScriptProcessorNode_base: { + new (): ScriptProcessorNode; + prototype: ScriptProcessorNode; +}; +/** + * Base class for Monophonic and Polyphonic ScriptProcessorNode + */ +export declare class FaustScriptProcessorNode extends FaustScriptProcessorNode_base { + protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp; + protected fInputs: Float32Array[]; + protected fOutputs: Float32Array[]; + init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void; + private handleDeviceMotion; + private handleDeviceOrientation; + /** Setup accelerometer and gyroscope handlers */ + startSensors(): Promise; + stopSensors(): void; + compute(input: Float32Array[], output: Float32Array[]): boolean; + setOutputParamHandler(handler: OutputParamHandler): void; + getOutputParamHandler(): OutputParamHandler | null; + setComputeHandler(handler: ComputeHandler): void; + getComputeHandler(): ComputeHandler | null; + setPlotHandler(handler: PlotHandler): void; + getPlotHandler(): PlotHandler | null; + getNumInputs(): number; + getNumOutputs(): number; + metadata(handler: MetadataHandler): void; + midiMessage(data: number[] | Uint8Array): void; + ctrlChange(chan: number, ctrl: number, value: number): void; + pitchWheel(chan: number, value: number): void; + setParamValue(path: string, value: number): void; + getParamValue(path: string): number; + getParams(): string[]; + getMeta(): FaustDspMeta; + getJSON(): string; + getDescriptors(): FaustUIInputItem[]; + getUI(): FaustUIDescriptor; + start(): void; + stop(): void; + destroy(): void; + get hasAccInput(): boolean; + propagateAcc(accelerationIncludingGravity: NonNullable, invert?: boolean): void; + get hasGyrInput(): boolean; + propagateGyr(event: Pick): void; +} +export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp { +} +export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp { + keyOn(channel: number, pitch: number, velocity: number): void; + keyOff(channel: number, pitch: number, velocity: number): void; + allNotesOff(hard: boolean): void; +} +export interface GeneratorSupportingSoundfiles { + /** + * Attach a map of id - audio data, call after `compile()` before `createNode()` + * + * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number` + */ + addSoundfiles(soundfileMap: Record): void; + /** + * Get a list of soundfiles needed, call after `compile()` + */ + getSoundfileList(): string[]; +} +export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles { + /** + * Compile a monophonic DSP factory from given code. + * + * @param compiler - the Faust compiler + * @param name - the DSP name + * @param code - the DSP code + * @param args - the compilation parameters + * @returns the compiled factory or 'null' if failure + */ + compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{ + factory: FaustDspFactory | null; + name?: string; + meta?: FaustDspMeta; + } | null>; + /** + * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode). + * + * @param context - the WebAudio context + * @param name - DSP name, can be used for processorName + * @param factory - default is the compiled factory + * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode + * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames + * @param processorName - AudioWorklet Processor name + * @param processorOptions - Additional AudioWorklet Processor options + * @returns the compiled WebAudio node or 'null' if failure + */ + createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record): Promise; + /** + * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode). + * + * @param context - the WebAudio context + * @param fftUtils - should be an anonymous class with static methods, without any import from outside + * @param name - DSP name, can be used for processorName + * @param factory - default is the compiled factory + * @param fftOptions - initial FFT options + * @param processorName - AudioWorklet Processor name + * @param processorOptions - Additional AudioWorklet Processor options + * @returns the compiled WebAudio node or 'null' if failure + */ + createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial, processorName?: string, processorOptions?: Record): Promise; + /** + * Create a monophonic Offline processor. + * + * @param sampleRate - the sample rate in Hz + * @param bufferSize - the buffer size in frames + * @param factory - default is the compiled factory + * @param context - if this exists, will be used to fetch soundfiles online + * @returns the compiled processor or 'null' if failure + */ + createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise; + /** + * Get DSP JSON description with its UI and metadata as object. + * + * @return the DSP JSON description as object + */ + getMeta(): FaustDspMeta; + /** + * Get DSP JSON description with its UI and metadata. + * + * @return the DSP JSON description + */ + getJSON(): string; + /** + * Get DSP UI description. + * + * @return the DSP UI description + */ + getUI(): FaustUIDescriptor; +} +export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles { + /** + * Compile a monophonic DSP factory from given code. + * + * @param compiler - the Faust compiler + * @param name - the DSP name + * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect) + * @param args - the compilation parameters + * @param effectCode - optional effect DSP code + * @returns the compiled factory or 'null' if failure + */ + compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{ + voiceFactory: FaustDspFactory | null; + effectFactory?: FaustDspFactory | null; + } | null>; + /** + * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode). + * + * @param context the WebAudio context + * @param voices - the number of voices + * @param name - AudioWorklet Processor name + * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory) + * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package) + * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory) + * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode + * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames + * @param processorOptions - Additional AudioWorklet Processor options + * @returns the compiled WebAudio node or 'null' if failure + */ + createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record): Promise; + /** + * Create a monophonic Offline processor. + * + * @param sampleRate - the sample rate in Hz + * @param bufferSize - the buffer size in frames + * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory) + * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files) + * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory) + * @param context - if this exists, will be used to fetch soundfiles online + * @returns the compiled processor or 'null' if failure + */ + createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise; + /** + * Get DSP JSON description with its UI and metadata as object. + * + * @return the DSP JSON description as object + */ + getMeta(): FaustDspMeta; + /** + * Get DSP JSON description with its UI and metadata. + * + * @return the DSP JSON description + */ + getJSON(): string; + /** + * Get DSP UI description. + * + * @return the DSP UI description + */ + getUI(): FaustUIDescriptor; +} +export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator { + private static gWorkletProcessors; + name: string; + factory: FaustDspFactory | null; + constructor(); + compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise; + addSoundfiles(soundfileMap: Record): void; + getSoundfileList(): string[]; + createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record): Promise; + createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial, processorName?: string, processorOptions?: Record): Promise; + createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{ + new (options: AudioWorkletNodeOptions): AudioWorkletProcessor; + prototype: AudioWorkletProcessor; + parameterDescriptors: AudioParamDescriptor[]; + }>; + createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise; + getMeta(): any; + getJSON(): string; + getUI(): any; +} +export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator { + private static gWorkletProcessors; + name: string; + voiceFactory: FaustDspFactory | null; + effectFactory: FaustDspFactory | null; + mixerBuffer: Uint8Array; + mixerModule: WebAssembly.Module; + constructor(); + compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise; + addSoundfiles(soundfileMap: Record): void; + getSoundfileList(): string[]; + createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise; + createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{ + new (options: AudioWorkletNodeOptions): AudioWorkletProcessor; + prototype: AudioWorkletProcessor; + parameterDescriptors: AudioParamDescriptor[]; + }>; + createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise; + getMeta(): FaustDspMeta; + getJSON(): string; + getUI(): FaustUIDescriptor; +} + +export {}; diff --git a/docs/gamelan/sinusoide2/faustwasm/index.js b/docs/gamelan/sinusoide2/faustwasm/index.js new file mode 100644 index 0000000..125645c --- /dev/null +++ b/docs/gamelan/sinusoide2/faustwasm/index.js @@ -0,0 +1,4639 @@ +var __accessCheck = (obj, member, msg) => { + if (!member.has(obj)) + throw TypeError("Cannot " + msg); +}; +var __privateGet = (obj, member, getter) => { + __accessCheck(obj, member, "read from private field"); + return getter ? getter.call(obj) : member.get(obj); +}; +var __privateAdd = (obj, member, value) => { + if (member.has(obj)) + throw TypeError("Cannot add the same private member more than once"); + member instanceof WeakSet ? member.add(obj) : member.set(obj, value); +}; +var __privateSet = (obj, member, value, setter) => { + __accessCheck(obj, member, "write to private field"); + setter ? setter.call(obj, value) : member.set(obj, value); + return value; +}; + +// src/instantiateFaustModuleFromFile.ts +var instantiateFaustModuleFromFile = async (jsFile, dataFile = jsFile.replace(/c?js$/, "data"), wasmFile = jsFile.replace(/c?js$/, "wasm")) => { + var _a, _b; + let FaustModule; + let dataBinary; + let wasmBinary; + const jsCodeHead = /var (.+) = \(/; + if (typeof window === "object") { + let jsCode = await (await fetch(jsFile)).text(); + jsCode = `${jsCode} +export default ${(_a = jsCode.match(jsCodeHead)) == null ? void 0 : _a[1]}; +`; + const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: "text/javascript" })); + FaustModule = (await import( + /* webpackIgnore: true */ + jsFileMod + )).default; + dataBinary = await (await fetch(dataFile)).arrayBuffer(); + wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer()); + } else { + const { promises: fs } = await import("fs"); + const { pathToFileURL } = await import("url"); + let jsCode = await fs.readFile(jsFile, { encoding: "utf-8" }); + jsCode = ` +import process from "process"; +import * as path from "path"; +import { createRequire } from "module"; +import { fileURLToPath } from "url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const __filename = fileURLToPath(import.meta.url); +const require = createRequire(import.meta.url); + +${jsCode} + +export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]}; +`; + const jsFileMod = jsFile.replace(/c?js$/, "mjs"); + await fs.writeFile(jsFileMod, jsCode); + FaustModule = (await import( + /* webpackIgnore: true */ + pathToFileURL(jsFileMod).href + )).default; + await fs.unlink(jsFileMod); + dataBinary = (await fs.readFile(dataFile)).buffer; + wasmBinary = (await fs.readFile(wasmFile)).buffer; + } + const faustModule = await FaustModule({ + wasmBinary, + getPreloadedPackage: (remotePackageName, remotePackageSize) => { + if (remotePackageName === "libfaust-wasm.data") + return dataBinary; + return new ArrayBuffer(0); + } + }); + return faustModule; +}; +var instantiateFaustModuleFromFile_default = instantiateFaustModuleFromFile; + +// src/FaustAudioWorkletProcessor.ts +var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) => { + const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis; + const { + FaustBaseWebAudioDsp: FaustBaseWebAudioDsp2, + FaustWasmInstantiator: FaustWasmInstantiator2 + } = dependencies; + const { + processorName, + dspName, + dspMeta, + effectMeta, + poly + } = faustData; + const analysePolyParameters = (item) => { + const polyKeywords = ["/gate", "/freq", "/gain", "/key", "/vel", "/velocity"]; + const isPolyReserved = "address" in item && !!polyKeywords.find((k) => item.address.endsWith(k)); + if (poly && isPolyReserved) + return null; + if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") { + return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 }; + } else if (item.type === "button" || item.type === "checkbox") { + return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 }; + } + return null; + }; + class FaustAudioWorkletProcessor extends AudioWorkletProcessor { + constructor(options) { + super(options); + this.paramValuesCache = {}; + this.port.onmessage = (e) => this.handleMessageAux(e); + const { parameterDescriptors } = this.constructor; + parameterDescriptors.forEach((pd) => { + this.paramValuesCache[pd.name] = pd.defaultValue || 0; + }); + const { moduleId, instanceId } = options.processorOptions; + if (!moduleId || !instanceId) + return; + this.wamInfo = { moduleId, instanceId }; + } + static get parameterDescriptors() { + const params = []; + const callback = (item) => { + const param = analysePolyParameters(item); + if (param) + params.push(param); + }; + FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback); + if (effectMeta) + FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback); + return params; + } + setupWamEventHandler() { + var _a; + if (!this.wamInfo) + return; + const { moduleId, instanceId } = this.wamInfo; + const { webAudioModules } = globalThis; + const ModuleScope = webAudioModules.getModuleScope(moduleId); + const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId]; + if (!paramMgrProcessor) + return; + if (paramMgrProcessor.handleEvent) + return; + paramMgrProcessor.handleEvent = (event) => { + if (event.type === "wam-midi") + this.midiMessage(event.data.bytes); + }; + } + process(inputs, outputs, parameters) { + for (const path in parameters) { + const [paramValue] = parameters[path]; + if (paramValue !== this.paramValuesCache[path]) { + this.fDSPCode.setParamValue(path, paramValue); + this.paramValuesCache[path] = paramValue; + } + } + return this.fDSPCode.compute(inputs[0], outputs[0]); + } + handleMessageAux(e) { + const msg = e.data; + switch (msg.type) { + case "acc": { + this.propagateAcc(msg.data, msg.invert); + break; + } + case "gyr": { + this.propagateGyr(msg.data); + break; + } + case "midi": { + this.midiMessage(msg.data); + break; + } + case "ctrlChange": { + this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); + break; + } + case "pitchWheel": { + this.pitchWheel(msg.data[0], msg.data[1]); + break; + } + case "param": { + this.setParamValue(msg.data.path, msg.data.value); + break; + } + case "setPlotHandler": { + if (msg.data) { + this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: "plot", value: output, index, events })); + } else { + this.fDSPCode.setPlotHandler(null); + } + break; + } + case "setupWamEventHandler": { + this.setupWamEventHandler(); + break; + } + case "start": { + this.fDSPCode.start(); + break; + } + case "stop": { + this.fDSPCode.stop(); + break; + } + case "destroy": { + this.port.close(); + this.fDSPCode.destroy(); + break; + } + default: + break; + } + } + setParamValue(path, value) { + this.fDSPCode.setParamValue(path, value); + this.paramValuesCache[path] = value; + } + midiMessage(data) { + this.fDSPCode.midiMessage(data); + } + ctrlChange(channel, ctrl, value) { + this.fDSPCode.ctrlChange(channel, ctrl, value); + } + pitchWheel(channel, wheel) { + this.fDSPCode.pitchWheel(channel, wheel); + } + propagateAcc(accelerationIncludingGravity, invert = false) { + this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert); + } + propagateGyr(event) { + this.fDSPCode.propagateGyr(event); + } + } + class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor { + constructor(options) { + super(options); + const { FaustMonoWebAudioDsp: FaustMonoWebAudioDsp2 } = dependencies; + const { factory, sampleSize } = options.processorOptions; + const instance = FaustWasmInstantiator2.createSyncMonoDSPInstance(factory); + this.fDSPCode = new FaustMonoWebAudioDsp2(instance, sampleRate, sampleSize, 128, factory.soundfiles); + this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" })); + this.fDSPCode.start(); + } + } + class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor { + constructor(options) { + super(options); + this.handleMessageAux = (e) => { + const msg = e.data; + switch (msg.type) { + case "keyOn": + this.keyOn(msg.data[0], msg.data[1], msg.data[2]); + break; + case "keyOff": + this.keyOff(msg.data[0], msg.data[1], msg.data[2]); + break; + default: + super.handleMessageAux(e); + break; + } + }; + const { FaustPolyWebAudioDsp: FaustPolyWebAudioDsp3 } = dependencies; + const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions; + const instance = FaustWasmInstantiator2.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory); + const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles }; + this.fDSPCode = new FaustPolyWebAudioDsp3(instance, sampleRate, sampleSize, 128, soundfiles); + this.port.onmessage = (e) => this.handleMessageAux(e); + this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" })); + this.fDSPCode.start(); + } + midiMessage(data) { + const cmd = data[0] >> 4; + const channel = data[0] & 15; + const data1 = data[1]; + const data2 = data[2]; + if (cmd === 8 || cmd === 9 && data2 === 0) + this.keyOff(channel, data1, data2); + else if (cmd === 9) + this.keyOn(channel, data1, data2); + else + super.midiMessage(data); + } + // Public API + keyOn(channel, pitch, velocity) { + this.fDSPCode.keyOn(channel, pitch, velocity); + } + keyOff(channel, pitch, velocity) { + this.fDSPCode.keyOff(channel, pitch, velocity); + } + allNotesOff(hard) { + this.fDSPCode.allNotesOff(hard); + } + } + const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor; + if (register) { + try { + registerProcessor(processorName || dspName || (poly ? "mydsp_poly" : "mydsp"), Processor); + } catch (error) { + console.warn(error); + } + } + return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor; +}; +var FaustAudioWorkletProcessor_default = getFaustAudioWorkletProcessor; + +// src/FaustFFTAudioWorkletProcessor.ts +var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true) => { + const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis; + const { + FaustBaseWebAudioDsp: FaustBaseWebAudioDsp2, + FaustWasmInstantiator: FaustWasmInstantiator2, + FaustMonoWebAudioDsp: FaustMonoWebAudioDsp2, + FFTUtils + } = dependencies; + const { + processorName, + dspName, + dspMeta, + fftOptions + } = faustData; + const { + windowFunctions, + getFFT, + fftToSignal, + signalToFFT, + signalToNoFFT + } = FFTUtils; + const ceil = (x, to) => Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to; + const mod = (x, y) => (x % y + y) % y; + const apply = (array, windowFunction) => { + for (let i = 0; i < array.length; i++) { + array[i] *= windowFunction(i, array.length); + } + }; + const fftParamKeywords = ["/fftSize", "/fftHopSize", "/fftOverlap", "/windowFunction", "/noIFFT"]; + const setTypedArray = (to, from, offsetTo = 0, offsetFrom = 0) => { + const toLength = to.length; + const fromLength = from.length; + const spillLength = Math.min(toLength, fromLength); + let spilled = 0; + let $to = mod(offsetTo, toLength) || 0; + let $from = mod(offsetFrom, fromLength) || 0; + while (spilled < spillLength) { + const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from); + const $fromEnd = $from + $spillLength; + if ($from === 0 && $fromEnd === fromLength) + to.set(from, $to); + else + to.set(from.subarray($from, $fromEnd), $to); + $to = ($to + $spillLength) % toLength; + $from = $fromEnd % fromLength; + spilled += $spillLength; + } + return $to; + }; + const analyseParameters = (item) => { + const isFFTReserved = "address" in item && !!fftParamKeywords.find((k) => item.address.endsWith(k)); + if (isFFTReserved) + return null; + if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") { + return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 }; + } else if (item.type === "button" || item.type === "checkbox") { + return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 }; + } + return null; + }; + class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor { + constructor(options) { + super(options); + this.paramValuesCache = {}; + this.destroyed = false; + /** Pointer of next start sample to write of the FFT input window */ + this.$inputWrite = 0; + /** Pointer of next start sample to read of the FFT input window */ + this.$inputRead = 0; + /** Pointer of next start sample to write of the FFT output window */ + this.$outputWrite = 0; + /** Pointer of next start sample to read of the FFT output window */ + this.$outputRead = 0; + /** Not perform in IFFT when reconstruct the audio signal */ + this.noIFFT = false; + /** audio data from input, array of channels */ + this.fftInput = []; + /** audio data for output, array of channels */ + this.fftOutput = []; + /** FFT Overlaps, 1 means no overlap */ + this.fftOverlap = 0; + this.fftHopSize = 0; + this.fftSize = 0; + this.fftBufferSize = 0; + this.fPlotHandler = null; + this.fCachedEvents = []; + this.fBufferNum = 0; + this.soundfiles = {}; + this.windowFunction = null; + this.port.onmessage = (e) => this.handleMessageAux(e); + const { parameterDescriptors } = this.constructor; + parameterDescriptors.forEach((pd) => { + this.paramValuesCache[pd.name] = pd.defaultValue || 0; + }); + const { factory, sampleSize } = options.processorOptions; + this.dspInstance = FaustWasmInstantiator2.createSyncMonoDSPInstance(factory); + this.sampleSize = sampleSize; + this.soundfiles = factory.soundfiles; + this.initFFT(); + const { moduleId, instanceId } = options.processorOptions; + if (!moduleId || !instanceId) + return; + this.wamInfo = { moduleId, instanceId }; + } + get fftProcessorBufferSize() { + return this.fftSize / 2 + 1; + } + async initFFT() { + this.FFT = await getFFT(); + await this.createFFTProcessor(); + return true; + } + static get parameterDescriptors() { + const params = []; + const callback = (item) => { + const param = analyseParameters(item); + if (param) + params.push(param); + }; + FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback); + return [ + ...params, + { + defaultValue: (fftOptions == null ? void 0 : fftOptions.fftSize) || 1024, + maxValue: 2 ** 32, + minValue: 2, + name: "fftSize" + }, + { + defaultValue: (fftOptions == null ? void 0 : fftOptions.fftOverlap) || 2, + maxValue: 32, + minValue: 1, + name: "fftOverlap" + }, + { + defaultValue: typeof (fftOptions == null ? void 0 : fftOptions.defaultWindowFunction) === "number" ? fftOptions.defaultWindowFunction + 1 : 0, + maxValue: (windowFunctions == null ? void 0 : windowFunctions.length) || 0, + minValue: 0, + name: "windowFunction" + }, + { + defaultValue: +!!(fftOptions == null ? void 0 : fftOptions.noIFFT) || 0, + maxValue: 1, + minValue: 0, + name: "noIFFT" + } + ]; + } + setupWamEventHandler() { + var _a; + if (!this.wamInfo) + return; + const { moduleId, instanceId } = this.wamInfo; + const { webAudioModules } = globalThis; + const ModuleScope = webAudioModules.getModuleScope(moduleId); + const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId]; + if (!paramMgrProcessor) + return; + if (paramMgrProcessor.handleEvent) + return; + paramMgrProcessor.handleEvent = (event) => { + if (event.type === "wam-midi") + this.midiMessage(event.data.bytes); + }; + } + processFFT() { + let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize; + while (samplesForFFT >= this.fftSize) { + let fftProcessorOutputs = []; + this.fDSPCode.compute((inputs) => { + for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) { + const ffted = this.rfft.forward((fftBuffer) => { + setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead); + for (let j = 0; j < fftBuffer.length; j++) { + fftBuffer[j] *= this.window[j]; + } + }); + fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]); + } + for (let i = this.fftInput.length * 3; i < inputs.length; i++) { + if (i % 3 === 2) + inputs[i].forEach((v, j) => inputs[i][j] = j); + else + inputs[i].fill(0); + } + }, (outputs) => { + fftProcessorOutputs = outputs; + }); + this.$inputRead += this.fftHopSize; + this.$inputRead %= this.fftBufferSize; + samplesForFFT -= this.fftHopSize; + for (let i = 0; i < this.fftOutput.length; i++) { + let iffted; + if (this.noIFFT) { + iffted = this.noIFFTBuffer; + signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted); + } else { + iffted = this.rfft.inverse((ifftBuffer) => { + signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer); + }); + } + for (let j = 0; j < iffted.length; j++) { + iffted[j] *= this.window[j]; + } + let $; + for (let j = 0; j < iffted.length - this.fftHopSize; j++) { + $ = mod(this.$outputWrite + j, this.fftBufferSize); + this.fftOutput[i][$] += iffted[j]; + if (i === 0) + this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2; + } + for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) { + $ = mod(this.$outputWrite + j, this.fftBufferSize); + this.fftOutput[i][$] = iffted[j]; + if (i === 0) + this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2; + } + } + this.$outputWrite += this.fftHopSize; + this.$outputWrite %= this.fftBufferSize; + } + } + process(inputs, outputs, parameters) { + if (this.destroyed) + return false; + if (!this.FFT) + return true; + const input = inputs[0]; + const output = outputs[0]; + const inputChannels = (input == null ? void 0 : input.length) || 0; + const outputChannels = (output == null ? void 0 : output.length) || 0; + const bufferSize = (input == null ? void 0 : input.length) ? Math.max(...input.map((c) => c.length)) || 128 : 128; + this.noIFFT = !!parameters.noIFFT[0]; + this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize); + if (!this.fDSPCode) + return true; + for (const path in parameters) { + if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k))) + continue; + const [paramValue] = parameters[path]; + if (paramValue !== this.paramValuesCache[path]) { + this.fDSPCode.setParamValue(path, paramValue); + this.paramValuesCache[path] = paramValue; + } + } + if (input == null ? void 0 : input.length) { + let $inputWrite = 0; + for (let i = 0; i < input.length; i++) { + const inputWindow = this.fftInput[i]; + const channel = input[i].length ? input[i] : new Float32Array(bufferSize); + $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite); + } + this.$inputWrite = $inputWrite; + } else { + this.$inputWrite += bufferSize; + this.$inputWrite %= this.fftBufferSize; + } + this.processFFT(); + for (let i = 0; i < output.length; i++) { + setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead); + let div = 0; + for (let j = 0; j < bufferSize; j++) { + div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)]; + output[i][j] /= div < 1e-8 ? 1 : div; + } + } + this.$outputRead += bufferSize; + this.$outputRead %= this.fftBufferSize; + if (this.fPlotHandler) { + this.port.postMessage({ type: "plot", value: output, index: this.fBufferNum++, events: this.fCachedEvents }); + this.fCachedEvents = []; + } + return true; + } + handleMessageAux(e) { + var _a, _b, _c; + const msg = e.data; + switch (msg.type) { + case "midi": + this.midiMessage(msg.data); + break; + case "ctrlChange": + this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); + break; + case "pitchWheel": + this.pitchWheel(msg.data[0], msg.data[1]); + break; + case "param": + this.setParamValue(msg.data.path, msg.data.value); + break; + case "setPlotHandler": { + if (msg.data) { + this.fPlotHandler = (output, index, events) => { + if (events) + this.fCachedEvents.push(...events); + }; + } else { + this.fPlotHandler = null; + } + (_a = this.fDSPCode) == null ? void 0 : _a.setPlotHandler(this.fPlotHandler); + break; + } + case "setupWamEventHandler": { + this.setupWamEventHandler(); + break; + } + case "start": { + (_b = this.fDSPCode) == null ? void 0 : _b.start(); + break; + } + case "stop": { + (_c = this.fDSPCode) == null ? void 0 : _c.stop(); + break; + } + case "destroy": { + this.port.close(); + this.destroy(); + break; + } + default: + break; + } + } + setParamValue(path, value) { + var _a; + (_a = this.fDSPCode) == null ? void 0 : _a.setParamValue(path, value); + this.paramValuesCache[path] = value; + } + midiMessage(data) { + var _a; + (_a = this.fDSPCode) == null ? void 0 : _a.midiMessage(data); + } + ctrlChange(channel, ctrl, value) { + var _a; + (_a = this.fDSPCode) == null ? void 0 : _a.ctrlChange(channel, ctrl, value); + } + pitchWheel(channel, wheel) { + var _a; + (_a = this.fDSPCode) == null ? void 0 : _a.pitchWheel(channel, wheel); + } + resetFFT(sizeIn, overlapIn, windowFunctionIn, inputChannels, outputChannels, bufferSize) { + var _a, _b; + const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2); + const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn)); + const fftHopSize = ~~Math.max(1, fftSize / fftOverlap); + const latency = fftSize - Math.min(fftHopSize, bufferSize); + let windowFunction = null; + if (windowFunctionIn !== 0) { + windowFunction = typeof windowFunctions === "object" ? windowFunctions[~~windowFunctionIn - 1] || null : null; + } + const fftSizeChanged = fftSize !== this.fftSize; + const fftOverlapChanged = fftOverlap !== this.fftOverlap; + if (fftSizeChanged || fftOverlapChanged) { + this.fftSize = fftSize; + this.fftOverlap = fftOverlap; + this.fftHopSize = fftHopSize; + this.$inputWrite = 0; + this.$inputRead = 0; + this.$outputWrite = 0; + this.$outputRead = -latency; + this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2); + if (!fftSizeChanged && this.fftHopSizeParam) + (_a = this.fDSPCode) == null ? void 0 : _a.setParamValue(this.fftHopSizeParam, this.fftHopSize); + } + if (fftSizeChanged) { + (_b = this.rfft) == null ? void 0 : _b.dispose(); + this.rfft = new this.FFT(fftSize); + this.noIFFTBuffer = new Float32Array(this.fftSize); + this.createFFTProcessor(); + } + if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) { + this.windowFunction = windowFunction; + this.window = new Float32Array(fftSize); + this.window.fill(1); + if (windowFunction) + apply(this.window, windowFunction); + this.windowSumSquare = new Float32Array(this.fftBufferSize); + } + if (this.fftInput.length > inputChannels) { + this.fftInput.splice(inputChannels); + } + if (this.fftOutput.length > outputChannels) { + this.fftOutput.splice(outputChannels); + } + if (fftSizeChanged || fftOverlapChanged) { + for (let i = 0; i < inputChannels; i++) { + this.fftInput[i] = new Float32Array(this.fftBufferSize); + } + for (let i = 0; i < outputChannels; i++) { + this.fftOutput[i] = new Float32Array(this.fftBufferSize); + } + } else { + if (this.fftInput.length < inputChannels) { + for (let i = this.fftInput.length; i < inputChannels; i++) { + this.fftInput[i] = new Float32Array(this.fftBufferSize); + } + } + if (this.fftOutput.length < outputChannels) { + for (let i = this.fftOutput.length; i < outputChannels; i++) { + this.fftOutput[i] = new Float32Array(this.fftBufferSize); + } + } + } + } + async createFFTProcessor() { + var _a, _b; + (_a = this.fDSPCode) == null ? void 0 : _a.stop(); + (_b = this.fDSPCode) == null ? void 0 : _b.destroy(); + this.fDSPCode = new FaustMonoWebAudioDsp2(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles); + this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" })); + this.fDSPCode.setPlotHandler(this.fPlotHandler); + const params = this.fDSPCode.getParams(); + this.fDSPCode.start(); + for (const path in this.paramValuesCache) { + if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k))) + continue; + this.fDSPCode.setParamValue(path, this.paramValuesCache[path]); + } + const fftSizeParam = params.find((s) => s.endsWith("/fftSize")); + if (fftSizeParam) + this.fDSPCode.setParamValue(fftSizeParam, this.fftSize); + this.fftHopSizeParam = params.find((s) => s.endsWith("/fftHopSize")); + if (this.fftHopSizeParam) + this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize); + this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize); + } + destroy() { + var _a, _b, _c; + (_a = this.fDSPCode) == null ? void 0 : _a.stop(); + (_b = this.fDSPCode) == null ? void 0 : _b.destroy(); + (_c = this.rfft) == null ? void 0 : _c.dispose(); + this.destroyed = true; + } + } + const Processor = FaustFFTAudioWorkletProcessor; + if (register) { + try { + registerProcessor(processorName || dspName || "myfftdsp", Processor); + } catch (error) { + console.warn(error); + } + } + return FaustFFTAudioWorkletProcessor; +}; +var FaustFFTAudioWorkletProcessor_default = getFaustFFTAudioWorkletProcessor; + +// node_modules/tslib/tslib.es6.mjs +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { + if (t[0] & 1) + throw t[1]; + return t[1]; + }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); + return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { + return this; + }), g; + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) + throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) + try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) + return t; + if (y = 0, t) + op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { + _ = 0; + continue; + } + if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) + _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) + throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +// node_modules/@aws-crypto/sha256-js/build/module/constants.js +var BLOCK_SIZE = 64; +var DIGEST_LENGTH = 32; +var KEY = new Uint32Array([ + 1116352408, + 1899447441, + 3049323471, + 3921009573, + 961987163, + 1508970993, + 2453635748, + 2870763221, + 3624381080, + 310598401, + 607225278, + 1426881987, + 1925078388, + 2162078206, + 2614888103, + 3248222580, + 3835390401, + 4022224774, + 264347078, + 604807628, + 770255983, + 1249150122, + 1555081692, + 1996064986, + 2554220882, + 2821834349, + 2952996808, + 3210313671, + 3336571891, + 3584528711, + 113926993, + 338241895, + 666307205, + 773529912, + 1294757372, + 1396182291, + 1695183700, + 1986661051, + 2177026350, + 2456956037, + 2730485921, + 2820302411, + 3259730800, + 3345764771, + 3516065817, + 3600352804, + 4094571909, + 275423344, + 430227734, + 506948616, + 659060556, + 883997877, + 958139571, + 1322822218, + 1537002063, + 1747873779, + 1955562222, + 2024104815, + 2227730452, + 2361852424, + 2428436474, + 2756734187, + 3204031479, + 3329325298 +]); +var INIT = [ + 1779033703, + 3144134277, + 1013904242, + 2773480762, + 1359893119, + 2600822924, + 528734635, + 1541459225 +]; +var MAX_HASHABLE_LENGTH = Math.pow(2, 53) - 1; + +// node_modules/@aws-crypto/sha256-js/build/module/RawSha256.js +var RawSha256 = ( + /** @class */ + function() { + function RawSha2562() { + this.state = Int32Array.from(INIT); + this.temp = new Int32Array(64); + this.buffer = new Uint8Array(64); + this.bufferLength = 0; + this.bytesHashed = 0; + this.finished = false; + } + RawSha2562.prototype.update = function(data) { + if (this.finished) { + throw new Error("Attempted to update an already finished hash."); + } + var position = 0; + var byteLength = data.byteLength; + this.bytesHashed += byteLength; + if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) { + throw new Error("Cannot hash more than 2^53 - 1 bits"); + } + while (byteLength > 0) { + this.buffer[this.bufferLength++] = data[position++]; + byteLength--; + if (this.bufferLength === BLOCK_SIZE) { + this.hashBuffer(); + this.bufferLength = 0; + } + } + }; + RawSha2562.prototype.digest = function() { + if (!this.finished) { + var bitsHashed = this.bytesHashed * 8; + var bufferView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength); + var undecoratedLength = this.bufferLength; + bufferView.setUint8(this.bufferLength++, 128); + if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) { + for (var i = this.bufferLength; i < BLOCK_SIZE; i++) { + bufferView.setUint8(i, 0); + } + this.hashBuffer(); + this.bufferLength = 0; + } + for (var i = this.bufferLength; i < BLOCK_SIZE - 8; i++) { + bufferView.setUint8(i, 0); + } + bufferView.setUint32(BLOCK_SIZE - 8, Math.floor(bitsHashed / 4294967296), true); + bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed); + this.hashBuffer(); + this.finished = true; + } + var out = new Uint8Array(DIGEST_LENGTH); + for (var i = 0; i < 8; i++) { + out[i * 4] = this.state[i] >>> 24 & 255; + out[i * 4 + 1] = this.state[i] >>> 16 & 255; + out[i * 4 + 2] = this.state[i] >>> 8 & 255; + out[i * 4 + 3] = this.state[i] >>> 0 & 255; + } + return out; + }; + RawSha2562.prototype.hashBuffer = function() { + var _a = this, buffer = _a.buffer, state = _a.state; + var state0 = state[0], state1 = state[1], state2 = state[2], state3 = state[3], state4 = state[4], state5 = state[5], state6 = state[6], state7 = state[7]; + for (var i = 0; i < BLOCK_SIZE; i++) { + if (i < 16) { + this.temp[i] = (buffer[i * 4] & 255) << 24 | (buffer[i * 4 + 1] & 255) << 16 | (buffer[i * 4 + 2] & 255) << 8 | buffer[i * 4 + 3] & 255; + } else { + var u = this.temp[i - 2]; + var t1_1 = (u >>> 17 | u << 15) ^ (u >>> 19 | u << 13) ^ u >>> 10; + u = this.temp[i - 15]; + var t2_1 = (u >>> 7 | u << 25) ^ (u >>> 18 | u << 14) ^ u >>> 3; + this.temp[i] = (t1_1 + this.temp[i - 7] | 0) + (t2_1 + this.temp[i - 16] | 0); + } + var t1 = (((state4 >>> 6 | state4 << 26) ^ (state4 >>> 11 | state4 << 21) ^ (state4 >>> 25 | state4 << 7)) + (state4 & state5 ^ ~state4 & state6) | 0) + (state7 + (KEY[i] + this.temp[i] | 0) | 0) | 0; + var t2 = ((state0 >>> 2 | state0 << 30) ^ (state0 >>> 13 | state0 << 19) ^ (state0 >>> 22 | state0 << 10)) + (state0 & state1 ^ state0 & state2 ^ state1 & state2) | 0; + state7 = state6; + state6 = state5; + state5 = state4; + state4 = state3 + t1 | 0; + state3 = state2; + state2 = state1; + state1 = state0; + state0 = t1 + t2 | 0; + } + state[0] += state0; + state[1] += state1; + state[2] += state2; + state[3] += state3; + state[4] += state4; + state[5] += state5; + state[6] += state6; + state[7] += state7; + }; + return RawSha2562; + }() +); + +// node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js +var fromUtf8 = (input) => new TextEncoder().encode(input); + +// node_modules/@aws-crypto/util/build/module/convertToBuffer.js +var fromUtf82 = typeof Buffer !== "undefined" && Buffer.from ? function(input) { + return Buffer.from(input, "utf8"); +} : fromUtf8; +function convertToBuffer(data) { + if (data instanceof Uint8Array) + return data; + if (typeof data === "string") { + return fromUtf82(data); + } + if (ArrayBuffer.isView(data)) { + return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT); + } + return new Uint8Array(data); +} + +// node_modules/@aws-crypto/util/build/module/isEmptyData.js +function isEmptyData(data) { + if (typeof data === "string") { + return data.length === 0; + } + return data.byteLength === 0; +} + +// node_modules/@aws-crypto/sha256-js/build/module/jsSha256.js +var Sha256 = ( + /** @class */ + function() { + function Sha2562(secret) { + this.secret = secret; + this.hash = new RawSha256(); + this.reset(); + } + Sha2562.prototype.update = function(toHash) { + if (isEmptyData(toHash) || this.error) { + return; + } + try { + this.hash.update(convertToBuffer(toHash)); + } catch (e) { + this.error = e; + } + }; + Sha2562.prototype.digestSync = function() { + if (this.error) { + throw this.error; + } + if (this.outer) { + if (!this.outer.finished) { + this.outer.update(this.hash.digest()); + } + return this.outer.digest(); + } + return this.hash.digest(); + }; + Sha2562.prototype.digest = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a) { + return [2, this.digestSync()]; + }); + }); + }; + Sha2562.prototype.reset = function() { + this.hash = new RawSha256(); + if (this.secret) { + this.outer = new RawSha256(); + var inner = bufferFromSecret(this.secret); + var outer = new Uint8Array(BLOCK_SIZE); + outer.set(inner); + for (var i = 0; i < BLOCK_SIZE; i++) { + inner[i] ^= 54; + outer[i] ^= 92; + } + this.hash.update(inner); + this.outer.update(outer); + for (var i = 0; i < inner.byteLength; i++) { + inner[i] = 0; + } + } + }; + return Sha2562; + }() +); +function bufferFromSecret(secret) { + var input = convertToBuffer(secret); + if (input.byteLength > BLOCK_SIZE) { + var bufferHash = new RawSha256(); + bufferHash.update(input); + input = bufferHash.digest(); + } + var buffer = new Uint8Array(BLOCK_SIZE); + buffer.set(input); + return buffer; +} + +// src/FaustCompiler.ts +var ab2str = (buf) => String.fromCharCode.apply(null, buf); +var str2ab = (str) => { + const buf = new ArrayBuffer(str.length); + const bufView = new Uint8Array(buf); + for (let i = 0, strLen = str.length; i < strLen; i++) { + bufView[i] = str.charCodeAt(i); + } + return bufView; +}; +var sha256 = async (str) => { + const sha2562 = new Sha256(); + sha2562.update(str); + const hashArray = Array.from(await sha2562.digest()); + const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); + return hashHex; +}; +var _FaustCompiler = class _FaustCompiler { + /** + * Get a stringified DSP factories table + */ + static serializeDSPFactories() { + const table = {}; + this.gFactories.forEach((factory, shaKey) => { + const { code, json, poly } = factory; + table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly }; + }); + return table; + } + /** + * Get a stringified DSP factories table as string + */ + static stringifyDSPFactories() { + return JSON.stringify(this.serializeDSPFactories()); + } + /** + * Import a DSP factories table + */ + static deserializeDSPFactories(table) { + const awaited = []; + for (const shaKey in table) { + const factory = table[shaKey]; + const { code, json, poly } = factory; + const ab = str2ab(atob(code)); + awaited.push(WebAssembly.compile(ab).then((module) => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} }))); + } + return Promise.all(awaited); + } + /** + * Import a stringified DSP factories table + */ + static importDSPFactories(tableStr) { + const table = JSON.parse(tableStr); + return this.deserializeDSPFactories(table); + } + constructor(libFaust) { + this.fLibFaust = libFaust; + this.fErrorMessage = ""; + } + intVec2intArray(vec) { + const size = vec.size(); + const ui8Code = new Uint8Array(size); + for (let i = 0; i < size; i++) { + ui8Code[i] = vec.get(i); + } + return ui8Code; + } + async createDSPFactory(name, code, args, poly) { + if (_FaustCompiler.gFactories.size > 10) { + _FaustCompiler.gFactories.clear(); + } + let shaKey = await sha256(name + code + args + (poly ? "poly" : "mono")); + if (_FaustCompiler.gFactories.has(shaKey)) { + return _FaustCompiler.gFactories.get(shaKey) || null; + } else { + try { + const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly); + const ui8Code = this.intVec2intArray(faustDspWasm.data); + faustDspWasm.data.delete(); + const module = await WebAssembly.compile(ui8Code); + const factory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} }; + this.deleteDSPFactory(factory); + _FaustCompiler.gFactories.set(shaKey, factory); + return factory; + } catch (e) { + this.fErrorMessage = this.fLibFaust.getErrorAfterException(); + this.fLibFaust.cleanupAfterException(); + throw this.fErrorMessage ? new Error(this.fErrorMessage) : e; + } + } + } + version() { + return this.fLibFaust.version(); + } + getErrorMessage() { + return this.fErrorMessage; + } + async createMonoDSPFactory(name, code, args) { + return this.createDSPFactory(name, code, args, false); + } + async createPolyDSPFactory(name, code, args) { + return this.createDSPFactory(name, code, args, true); + } + deleteDSPFactory(factory) { + this.fLibFaust.deleteDSPFactory(factory.cfactory); + factory.cfactory = 0; + } + expandDSP(code, args) { + try { + return this.fLibFaust.expandDSP("FaustDSP", code, args); + } catch (e) { + this.fErrorMessage = this.fLibFaust.getErrorAfterException(); + this.fLibFaust.cleanupAfterException(); + throw this.fErrorMessage ? new Error(this.fErrorMessage) : e; + } + } + generateAuxFiles(name, code, args) { + try { + return this.fLibFaust.generateAuxFiles(name, code, args); + } catch (e) { + this.fErrorMessage = this.fLibFaust.getErrorAfterException(); + this.fLibFaust.cleanupAfterException(); + throw this.fErrorMessage ? new Error(this.fErrorMessage) : e; + } + } + deleteAllDSPFactories() { + this.fLibFaust.deleteAllDSPFactories(); + } + fs() { + return this.fLibFaust.fs(); + } + async getAsyncInternalMixerModule(isDouble = false) { + const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer"; + const moduleKey = isDouble ? "mixer64Module" : "mixer32Module"; + if (this[moduleKey]) + return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] }; + const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm"; + const mixerBuffer = this.fs().readFile(path, { encoding: "binary" }); + this[bufferKey] = mixerBuffer; + const mixerModule = await WebAssembly.compile(mixerBuffer); + this[moduleKey] = mixerModule; + return { mixerBuffer, mixerModule }; + } + getSyncInternalMixerModule(isDouble = false) { + const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer"; + const moduleKey = isDouble ? "mixer64Module" : "mixer32Module"; + if (this[moduleKey]) + return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] }; + const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm"; + const mixerBuffer = this.fs().readFile(path, { encoding: "binary" }); + this[bufferKey] = mixerBuffer; + const mixerModule = new WebAssembly.Module(mixerBuffer); + this[moduleKey] = mixerModule; + return { mixerBuffer, mixerModule }; + } +}; +_FaustCompiler.gFactories = /* @__PURE__ */ new Map(); +var FaustCompiler = _FaustCompiler; +var FaustCompiler_default = FaustCompiler; + +// src/FaustDspInstance.ts +var FaustDspInstance = class { + constructor(exports) { + this.fExports = exports; + } + compute($dsp, count, $input, $output) { + this.fExports.compute($dsp, count, $input, $output); + } + getNumInputs($dsp) { + return this.fExports.getNumInputs($dsp); + } + getNumOutputs($dsp) { + return this.fExports.getNumOutputs($dsp); + } + getParamValue($dsp, index) { + return this.fExports.getParamValue($dsp, index); + } + getSampleRate($dsp) { + return this.fExports.getSampleRate($dsp); + } + init($dsp, sampleRate) { + this.fExports.init($dsp, sampleRate); + } + instanceClear($dsp) { + this.fExports.instanceClear($dsp); + } + instanceConstants($dsp, sampleRate) { + this.fExports.instanceConstants($dsp, sampleRate); + } + instanceInit($dsp, sampleRate) { + this.fExports.instanceInit($dsp, sampleRate); + } + instanceResetUserInterface($dsp) { + this.fExports.instanceResetUserInterface($dsp); + } + setParamValue($dsp, index, value) { + this.fExports.setParamValue($dsp, index, value); + } +}; + +// src/FaustWasmInstantiator.ts +var FaustWasmInstantiator = class { + static createWasmImport(memory) { + return { + env: { + memory: memory || new WebAssembly.Memory({ initial: 100 }), + memoryBase: 0, + tableBase: 0, + // Integer version + _abs: Math.abs, + // Float version + _acosf: Math.acos, + _asinf: Math.asin, + _atanf: Math.atan, + _atan2f: Math.atan2, + _ceilf: Math.ceil, + _cosf: Math.cos, + _expf: Math.exp, + _floorf: Math.floor, + _fmodf: (x, y) => x % y, + _logf: Math.log, + _log10f: Math.log10, + _max_f: Math.max, + _min_f: Math.min, + _remainderf: (x, y) => x - Math.round(x / y) * y, + _powf: Math.pow, + _roundf: Math.round, + _sinf: Math.sin, + _sqrtf: Math.sqrt, + _tanf: Math.tan, + _acoshf: Math.acosh, + _asinhf: Math.asinh, + _atanhf: Math.atanh, + _coshf: Math.cosh, + _sinhf: Math.sinh, + _tanhf: Math.tanh, + _isnanf: Number.isNaN, + _isinff: (x) => !isFinite(x), + _copysignf: (x, y) => Math.sign(x) === Math.sign(y) ? x : -x, + // Double version + _acos: Math.acos, + _asin: Math.asin, + _atan: Math.atan, + _atan2: Math.atan2, + _ceil: Math.ceil, + _cos: Math.cos, + _exp: Math.exp, + _floor: Math.floor, + _fmod: (x, y) => x % y, + _log: Math.log, + _log10: Math.log10, + _max_: Math.max, + _min_: Math.min, + _remainder: (x, y) => x - Math.round(x / y) * y, + _pow: Math.pow, + _round: Math.round, + _sin: Math.sin, + _sqrt: Math.sqrt, + _tan: Math.tan, + _acosh: Math.acosh, + _asinh: Math.asinh, + _atanh: Math.atanh, + _cosh: Math.cosh, + _sinh: Math.sinh, + _tanh: Math.tanh, + _isnan: Number.isNaN, + _isinf: (x) => !isFinite(x), + _copysign: (x, y) => Math.sign(x) === Math.sign(y) ? x : -x, + table: new WebAssembly.Table({ initial: 0, element: "anyfunc" }) + } + }; + } + static createWasmMemoryPoly(voicesIn, sampleSize, dspMeta, effectMeta, bufferSize) { + const voices = Math.max(4, voicesIn); + const ptrSize = sampleSize; + const pow2limit = (x) => { + let n = 65536; + while (n < x) { + n *= 2; + } + return n; + }; + const effectSize = effectMeta ? effectMeta.size : 0; + let memorySize = pow2limit( + effectSize + dspMeta.size * voices + (dspMeta.inputs + dspMeta.outputs * 2) * (ptrSize + bufferSize * sampleSize) + ) / 65536; + memorySize = Math.max(2, memorySize); + return new WebAssembly.Memory({ initial: memorySize }); + } + static createWasmMemoryMono(sampleSize, dspMeta, bufferSize) { + const ptrSize = sampleSize; + const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536; + return new WebAssembly.Memory({ initial: memorySize * 2 }); + } + static createMonoDSPInstanceAux(instance, json, mem = null) { + const functions = instance.exports; + const api = new FaustDspInstance(functions); + const memory = mem ? mem : instance.exports.memory; + return { memory, api, json }; + } + static createMemoryMono(monoFactory) { + const monoMeta = JSON.parse(monoFactory.json); + const sampleSize = monoMeta.compile_options.match("-double") ? 8 : 4; + return this.createWasmMemoryMono(sampleSize, monoMeta, 8192); + } + static createMemoryPoly(voices, voiceFactory, effectFactory) { + const voiceMeta = JSON.parse(voiceFactory.json); + const effectMeta = effectFactory && effectFactory.json ? JSON.parse(effectFactory.json) : null; + const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4; + return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192); + } + static createMixerAux(mixerModule, memory) { + const mixerImport = { + imports: { print: console.log }, + memory: { memory } + }; + const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport); + const mixerFunctions = mixerInstance.exports; + return mixerFunctions; + } + // Public API + static async loadDSPFactory(wasmPath, jsonPath) { + const wasmFile = await fetch(wasmPath); + if (!wasmFile.ok) { + throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`); + } + try { + const wasmBuffer = await wasmFile.arrayBuffer(); + const module = await WebAssembly.compile(wasmBuffer); + const jsonFile = await fetch(jsonPath); + const json = await jsonFile.text(); + const meta = JSON.parse(json); + const cOptions = meta.compile_options; + const poly = cOptions.indexOf("wasm-e") !== -1; + return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly }; + } catch (e) { + throw e; + } + } + static async loadDSPMixer(mixerPath, fs) { + try { + let mixerBuffer = null; + if (fs) { + mixerBuffer = fs.readFile(mixerPath, { encoding: "binary" }); + } else { + const mixerFile = await fetch(mixerPath); + mixerBuffer = await mixerFile.arrayBuffer(); + } + return WebAssembly.compile(mixerBuffer); + } catch (e) { + throw e; + } + } + static async createAsyncMonoDSPInstance(factory) { + const pattern = /"type":\s*"soundfile"/; + const isDetected = pattern.test(factory.json); + if (isDetected) { + const memory = this.createMemoryMono(factory); + const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory)); + return this.createMonoDSPInstanceAux(instance, factory.json, memory); + } else { + const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport()); + return this.createMonoDSPInstanceAux(instance, factory.json); + } + } + static createSyncMonoDSPInstance(factory) { + const pattern = /"type":\s*"soundfile"/; + const isDetected = pattern.test(factory.json); + if (isDetected) { + const memory = this.createMemoryMono(factory); + const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory)); + return this.createMonoDSPInstanceAux(instance, factory.json, memory); + } else { + const instance = new WebAssembly.Instance(factory.module, this.createWasmImport()); + return this.createMonoDSPInstanceAux(instance, factory.json); + } + } + static async createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory) { + const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory); + const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory)); + const voiceFunctions = voiceInstance.exports; + const voiceAPI = new FaustDspInstance(voiceFunctions); + const mixerAPI = this.createMixerAux(mixerModule, memory); + if (effectFactory) { + const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory)); + const effectFunctions = effectInstance.exports; + const effectAPI = new FaustDspInstance(effectFunctions); + return { + memory, + voices, + voiceAPI, + effectAPI, + mixerAPI, + voiceJSON: voiceFactory.json, + effectJSON: effectFactory.json + }; + } else { + return { + memory, + voices, + voiceAPI, + mixerAPI, + voiceJSON: voiceFactory.json + }; + } + } + static createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory) { + const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory); + const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory)); + const voiceFunctions = voiceInstance.exports; + const voiceAPI = new FaustDspInstance(voiceFunctions); + const mixerAPI = this.createMixerAux(mixerModule, memory); + if (effectFactory) { + const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory)); + const effectFunctions = effectInstance.exports; + const effectAPI = new FaustDspInstance(effectFunctions); + return { + memory, + voices, + voiceAPI, + effectAPI, + mixerAPI, + voiceJSON: voiceFactory.json, + effectJSON: effectFactory.json + }; + } else { + return { + memory, + voices, + voiceAPI, + mixerAPI, + voiceJSON: voiceFactory.json + }; + } + } +}; +var FaustWasmInstantiator_default = FaustWasmInstantiator; + +// src/FaustSensors.ts +var FaustSensors = class _FaustSensors { + /** + * Function to convert a number to an axis type + * + * @param value number + * @returns axis type + */ + static convertToAxis(value) { + switch (value) { + case 0: + return 0 /* x */; + case 1: + return 1 /* y */; + case 2: + return 2 /* z */; + default: + console.error("Error: Axis not found value: " + value); + return 0 /* x */; + } + } + /** + * Function to convert a number to a curve type + * + * @param value number + * @returns curve type + */ + static convertToCurve(value) { + switch (value) { + case 0: + return 0 /* Up */; + case 1: + return 1 /* Down */; + case 2: + return 2 /* UpDown */; + case 3: + return 3 /* DownUp */; + default: + console.error("Error: Curve not found value: " + value); + return 0 /* Up */; + } + } + static get Range() { + if (!this._Range) { + this._Range = class { + constructor(x, y) { + this.fLo = Math.min(x, y); + this.fHi = Math.max(x, y); + } + clip(x) { + if (x < this.fLo) + return this.fLo; + if (x > this.fHi) + return this.fHi; + return x; + } + }; + } + return this._Range; + } + /** + * Interpolator class + */ + static get Interpolator() { + if (!this._Interpolator) { + this._Interpolator = class { + constructor(lo, hi, v1, v2) { + this.fRange = new _FaustSensors.Range(lo, hi); + if (hi !== lo) { + this.fCoef = (v2 - v1) / (hi - lo); + this.fOffset = v1 - lo * this.fCoef; + } else { + this.fCoef = 0; + this.fOffset = (v1 + v2) / 2; + } + } + returnMappedValue(v) { + var x = this.fRange.clip(v); + return this.fOffset + x * this.fCoef; + } + getLowHigh(amin, amax) { + return { amin: this.fRange.fLo, amax: this.fRange.fHi }; + } + }; + } + return this._Interpolator; + } + /** + * Interpolator3pt class, combine two interpolators + */ + static get Interpolator3pt() { + if (!this._Interpolator3pt) { + this._Interpolator3pt = class { + constructor(lo, mid, hi, v1, vMid, v2) { + this.fSegment1 = new _FaustSensors.Interpolator(lo, mid, v1, vMid); + this.fSegment2 = new _FaustSensors.Interpolator(mid, hi, vMid, v2); + this.fMid = mid; + } + returnMappedValue(x) { + return x < this.fMid ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x); + } + getMappingValues(amin, amid, amax) { + var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid); + var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax); + return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax }; + } + }; + } + return this._Interpolator3pt; + } + /** + * UpConverter class, convert accelerometer value to Faust value + */ + static get UpConverter() { + if (!this._UpConverter) { + this._UpConverter = class { + constructor(amin, amid, amax, fmin, fmid, fmax) { + this.fActive = true; + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax); + this.fF2A = new _FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax); + } + uiToFaust(x) { + return this.fA2F.returnMappedValue(x); + } + faustToUi(x) { + return this.fF2A.returnMappedValue(x); + } + setMappingValues(amin, amid, amax, min, init, max) { + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max); + this.fF2A = new _FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax); + } + getMappingValues(amin, amid, amax) { + return this.fA2F.getMappingValues(amin, amid, amax); + } + setActive(onOff) { + this.fActive = onOff; + } + getActive() { + return this.fActive; + } + }; + } + return this._UpConverter; + } + /** + * DownConverter class, convert accelerometer value to Faust value + */ + static get DownConverter() { + if (!this._DownConverter) { + this._DownConverter = class { + constructor(amin, amid, amax, fmin, fmid, fmax) { + this.fActive = true; + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin); + this.fF2A = new _FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin); + } + uiToFaust(x) { + return this.fA2F.returnMappedValue(x); + } + faustToUi(x) { + return this.fF2A.returnMappedValue(x); + } + setMappingValues(amin, amid, amax, min, init, max) { + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min); + this.fF2A = new _FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin); + } + getMappingValues(amin, amid, amax) { + return this.fA2F.getMappingValues(amin, amid, amax); + } + setActive(onOff) { + this.fActive = onOff; + } + getActive() { + return this.fActive; + } + }; + } + return this._DownConverter; + } + /** + * UpDownConverter class, convert accelerometer value to Faust value + */ + static get UpDownConverter() { + if (!this._UpDownConverter) { + this._UpDownConverter = class { + constructor(amin, amid, amax, fmin, fmid, fmax) { + this.fActive = true; + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin); + this.fF2A = new _FaustSensors.Interpolator(fmin, fmax, amin, amax); + } + uiToFaust(x) { + return this.fA2F.returnMappedValue(x); + } + faustToUi(x) { + return this.fF2A.returnMappedValue(x); + } + setMappingValues(amin, amid, amax, min, init, max) { + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min); + this.fF2A = new _FaustSensors.Interpolator(min, max, amin, amax); + } + getMappingValues(amin, amid, amax) { + return this.fA2F.getMappingValues(amin, amid, amax); + } + setActive(onOff) { + this.fActive = onOff; + } + getActive() { + return this.fActive; + } + }; + } + return this._UpDownConverter; + } + static get DownUpConverter() { + if (!this._DownUpConverter) { + this._DownUpConverter = class { + constructor(amin, amid, amax, fmin, fmid, fmax) { + this.fActive = true; + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax); + this.fF2A = new _FaustSensors.Interpolator(fmin, fmax, amin, amax); + } + uiToFaust(x) { + return this.fA2F.returnMappedValue(x); + } + faustToUi(x) { + return this.fF2A.returnMappedValue(x); + } + setMappingValues(amin, amid, amax, min, init, max) { + this.fA2F = new _FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max); + this.fF2A = new _FaustSensors.Interpolator(min, max, amin, amax); + } + getMappingValues(amin, amid, amax) { + return this.fA2F.getMappingValues(amin, amid, amax); + } + setActive(onOff) { + this.fActive = onOff; + } + getActive() { + return this.fActive; + } + }; + } + return this._DownUpConverter; + } + /** + * Public function to build the accelerometer handler + * + * @returns `UpdatableValueConverter` built for the given curve + */ + static buildHandler(curve, amin, amid, amax, min, init, max) { + switch (curve) { + case 0 /* Up */: + return new _FaustSensors.UpConverter(amin, amid, amax, min, init, max); + case 1 /* Down */: + return new _FaustSensors.DownConverter(amin, amid, amax, min, init, max); + case 2 /* UpDown */: + return new _FaustSensors.UpDownConverter(amin, amid, amax, min, init, max); + case 3 /* DownUp */: + return new _FaustSensors.DownUpConverter(amin, amid, amax, min, init, max); + default: + return new _FaustSensors.UpConverter(amin, amid, amax, min, init, max); + } + } +}; + +// src/FaustWebAudioDsp.ts +var WasmAllocator = class { + constructor(memory, offset) { + this.memory = memory; + this.allocatedBytes = offset; + } + /** + * Allocates a block of memory of the specified size, returning the pointer to the + * beginning of the block. The block is allocated at the current offset and the + * offset is incremented by the size of the block. + * + * @param sizeInBytes The size of the block to allocate in bytes. + * @returns The offset (pointer) to the beginning of the allocated block. + */ + alloc(sizeInBytes) { + const currentOffset = this.allocatedBytes; + const newOffset = currentOffset + sizeInBytes; + const totalMemoryBytes = this.memory.buffer.byteLength; + if (newOffset > totalMemoryBytes) { + const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536); + console.log(`GROW: ${neededPages} pages`); + this.memory.grow(neededPages); + } + this.allocatedBytes = newOffset; + return currentOffset; + } + /** + * Returns the underlying buffer object. + * + * @returns The buffer object. + */ + getBuffer() { + return this.memory.buffer; + } + /** + * Returns the Int32 view of the underlying buffer object. + * + * @returns The view of the memory buffer as Int32Array. + */ + getInt32Array() { + return new Int32Array(this.memory.buffer); + } + /** + * Returns the Int64 view of the underlying buffer object. + * + * @returns The view of the memory buffer as BigInt64Array. + */ + getInt64Array() { + return new BigInt64Array(this.memory.buffer); + } + /** + * Returns the Float32 view of the underlying buffer object. + * + * @returns The view of the memory buffer as Float32Array. + */ + getFloat32Array() { + return new Float32Array(this.memory.buffer); + } + /** + * Returns the Float64 view of the underlying buffer object.. + * + * @returns The view of the memory buffer as Float64Array. + */ + getFloat64Array() { + return new Float64Array(this.memory.buffer); + } +}; +var Soundfile = class _Soundfile { + /** Maximum number of soundfile parts. */ + static get MAX_SOUNDFILE_PARTS() { + return 256; + } + /** Maximum number of channels. */ + static get MAX_CHAN() { + return 64; + } + /** Maximum buffer size in frames. */ + static get BUFFER_SIZE() { + return 1024; + } + /** Default sample rate. */ + static get SAMPLE_RATE() { + return 44100; + } + constructor(allocator, sampleSize, curChan, length, maxChan, totalParts) { + this.fSampleSize = sampleSize; + this.fIntSize = this.fSampleSize; + this.fPtrSize = 4; + this.fAllocator = allocator; + console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`); + this.fPtr = allocator.alloc(4 * this.fPtrSize); + this.fLength = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize); + this.fSR = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize); + this.fOffset = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize); + this.fBuffers = this.allocBuffers(curChan, length, maxChan); + const HEAP32 = this.fAllocator.getInt32Array(); + HEAP32[this.fPtr >> 2] = this.fBuffers; + HEAP32[this.fPtr + this.fPtrSize >> 2] = this.fLength; + HEAP32[this.fPtr + 2 * this.fPtrSize >> 2] = this.fSR; + HEAP32[this.fPtr + 3 * this.fPtrSize >> 2] = this.fOffset; + for (let chan = 0; chan < curChan; chan++) { + const buffer = HEAP32[(this.fBuffers >> 2) + chan]; + console.log(`allocBuffers AFTER: ${chan} - ${buffer}`); + } + } + allocBuffers(curChan, length, maxChan) { + const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize); + console.log(`allocBuffers buffers: ${buffers}`); + for (let chan = 0; chan < curChan; chan++) { + const buffer = this.fAllocator.alloc(length * this.fSampleSize); + const HEAP32 = this.fAllocator.getInt32Array(); + HEAP32[(buffers >> 2) + chan] = buffer; + } + return buffers; + } + shareBuffers(curChan, maxChan) { + const HEAP32 = this.fAllocator.getInt32Array(); + for (let chan = curChan; chan < maxChan; chan++) { + HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan]; + } + } + copyToOut(part, maxChannels, offset, audioData) { + if (this.fIntSize === 4) { + const HEAP32 = this.fAllocator.getInt32Array(); + HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length; + HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate; + HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset; + } else { + const HEAP64 = this.fAllocator.getInt64Array(); + HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length); + HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate); + HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset); + } + console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`); + if (this.fSampleSize === 8) { + this.copyToOutReal64(maxChannels, offset, audioData); + } else { + this.copyToOutReal32(maxChannels, offset, audioData); + } + } + copyToOutReal32(maxChannels, offset, audioData) { + const HEAP32 = this.fAllocator.getInt32Array(); + const HEAPF = this.fAllocator.getFloat32Array(); + for (let chan = 0; chan < audioData.audioBuffer.length; chan++) { + const input = audioData.audioBuffer[chan]; + const output = HEAP32[(this.fBuffers >> 2) + chan]; + const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize); + const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize); + console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`); + const outputReal = HEAPF.subarray( + output + offset * this.fSampleSize >> Math.log2(this.fSampleSize), + output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize) + ); + for (let sample = 0; sample < input.length; sample++) { + outputReal[sample] = input[sample]; + } + } + } + copyToOutReal64(maxChannels, offset, audioData) { + const HEAP32 = this.fAllocator.getInt32Array(); + const HEAPF = this.fAllocator.getFloat64Array(); + for (let chan = 0; chan < audioData.audioBuffer.length; chan++) { + const input = audioData.audioBuffer[chan]; + const output = HEAP32[(this.fBuffers >> 2) + chan]; + const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize); + const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize); + console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`); + const outputReal = HEAPF.subarray( + output + offset * this.fSampleSize >> Math.log2(this.fSampleSize), + output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize) + ); + for (let sample = 0; sample < input.length; sample++) { + outputReal[sample] = input[sample]; + } + } + } + emptyFile(part, offset) { + if (this.fIntSize === 4) { + const HEAP32 = this.fAllocator.getInt32Array(); + HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = _Soundfile.BUFFER_SIZE; + HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = _Soundfile.SAMPLE_RATE; + HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset; + } else { + const HEAP64 = this.fAllocator.getInt64Array(); + HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(_Soundfile.BUFFER_SIZE); + HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(_Soundfile.SAMPLE_RATE); + HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset); + } + return offset + _Soundfile.BUFFER_SIZE; + } + displayMemory(where = "", mem = false) { + console.log("Soundfile memory: " + where); + console.log(`fPtr: ${this.fPtr}`); + console.log(`fBuffers: ${this.fBuffers}`); + console.log(`fLength: ${this.fLength}`); + console.log(`fSR: ${this.fSR}`); + console.log(`fOffset: ${this.fOffset}`); + const HEAP32 = this.fAllocator.getInt32Array(); + if (mem) + console.log(`HEAP32: ${HEAP32}`); + console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`); + console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[this.fPtr + this.fPtrSize >> 2]}`); + console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 2 * this.fPtrSize >> 2]}`); + console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 3 * this.fPtrSize >> 2]}`); + } + // Return the pointer to the soundfile structure in wasm memory + getPtr() { + return this.fPtr; + } + getHEAP32() { + return this.fAllocator.getInt32Array(); + } + getHEAPFloat32() { + return this.fAllocator.getFloat32Array(); + } + getHEAPFloat64() { + return this.fAllocator.getFloat64Array(); + } +}; +var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp { + constructor(sampleSize, bufferSize, soundfiles) { + this.fOutputHandler = null; + this.fComputeHandler = null; + // To handle MIDI events plot + this.fPlotHandler = null; + this.fCachedEvents = []; + this.fBufferNum = 0; + this.fInChannels = []; + this.fOutChannels = []; + this.fOutputsTimer = 5; + // UI items path + this.fInputsItems = []; + this.fOutputsItems = []; + this.fDescriptor = []; + // Soundfile handling + this.fSoundfiles = []; + this.fSoundfileBuffers = {}; + // MIDI handling + this.fPitchwheelLabel = []; + this.fCtrlLabel = new Array(128).fill(null).map(() => []); + this.fPathTable = {}; + this.fUICallback = (item) => { + if (item.type === "hbargraph" || item.type === "vbargraph") { + this.fOutputsItems.push(item.address); + this.fPathTable[item.address] = item.index; + } else if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") { + this.fInputsItems.push(item.address); + this.fPathTable[item.address] = item.index; + this.fDescriptor.push(item); + if (!item.meta) + return; + item.meta.forEach((meta) => { + const { midi, acc, gyr } = meta; + if (midi) { + const strMidi = midi.trim(); + if (strMidi === "pitchwheel") { + const matched = strMidi.match(/^pitchwheel\s(\d+)/); + if (matched) { + this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min, max: item.max }); + } else { + this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min, max: item.max }); + } + } else { + const matched2 = strMidi.match(/^ctrl\s(\d+)\s(\d+)/); + const matched1 = strMidi.match(/^ctrl\s(\d+)/); + if (matched2) { + this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min, max: item.max }); + } else if (matched1) { + this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min, max: item.max }); + } + } + } + if (acc) { + const numAcc = acc.trim().split(" ").map(Number); + this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min, item.init, item.max); + } + if (gyr) { + const numAcc = gyr.trim().split(" ").map(Number); + this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min, item.init, item.max); + } + }); + } else if (item.type === "soundfile") { + this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 }); + } + }; + // Audio callback + this.fProcessing = false; + this.fDestroyed = false; + this.fFirstCall = true; + this.fBufferSize = bufferSize; + this.fPtrSize = sampleSize; + this.fSampleSize = sampleSize; + this.fSoundfileBuffers = soundfiles; + this.fAcc = { x: [], y: [], z: [] }; + this.fGyr = { x: [], y: [], z: [] }; + } + // Tools + static remap(v, mn0, mx0, mn1, mx1) { + return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1; + } + // JSON parsing functions + static parseUI(ui, callback) { + ui.forEach((group) => this.parseGroup(group, callback)); + } + static parseGroup(group, callback) { + if (group.items) { + this.parseItems(group.items, callback); + } + } + static parseItems(items, callback) { + items.forEach((item) => this.parseItem(item, callback)); + } + static parseItem(item, callback) { + if (item.type === "vgroup" || item.type === "hgroup" || item.type === "tgroup") { + this.parseItems(item.items, callback); + } else { + callback(item); + } + } + /** Split the soundfile names and return an array of names */ + static splitSoundfileNames(input) { + let trimmed = input.replace(/^\{|\}$/g, ""); + return trimmed.split(";").map((str) => str.length <= 2 ? "" : str.substring(1, str.length - 1)); + } + get hasAccInput() { + return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; + } + propagateAcc(accelerationIncludingGravity, invert = false) { + const { x, y, z } = accelerationIncludingGravity; + if (invert) { + if (x !== null) + this.fAcc.x.forEach((handler) => handler(-x)); + if (y !== null) + this.fAcc.y.forEach((handler) => handler(-y)); + if (z !== null) + this.fAcc.z.forEach((handler) => handler(-z)); + } else { + if (x !== null) + this.fAcc.x.forEach((handler) => handler(x)); + if (y !== null) + this.fAcc.y.forEach((handler) => handler(y)); + if (z !== null) + this.fAcc.z.forEach((handler) => handler(z)); + } + } + get hasGyrInput() { + return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; + } + propagateGyr(event) { + const { alpha, beta, gamma } = event; + if (alpha !== null) + this.fGyr.x.forEach((handler) => handler(alpha)); + if (beta !== null) + this.fGyr.y.forEach((handler) => handler(beta)); + if (gamma !== null) + this.fGyr.z.forEach((handler) => handler(gamma)); + } + /** Build the accelerometer handler */ + setupAccHandler(path, axis, curve, amin, amid, amax, min, init, max) { + const handler = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max); + switch (axis) { + case 0 /* x */: + this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + case 1 /* y */: + this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + case 2 /* z */: + this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + } + } + /** Build the gyroscope handler */ + setupGyrHandler(path, axis, curve, amin, amid, amax, min, init, max) { + const handler = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max); + switch (axis) { + case 0 /* x */: + this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + case 1 /* y */: + this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + case 2 /* z */: + this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val))); + break; + } + } + static extractUrlsFromMeta(dspMeta) { + const soundfilesEntry = dspMeta.meta.find((entry) => entry.soundfiles !== void 0); + if (soundfilesEntry) { + return soundfilesEntry.soundfiles.split(";").filter((url) => url !== ""); + } else { + return []; + } + } + /** + * Load a soundfile possibly containing several parts in the DSP struct. + * Soundfile pointers are located at 'index' offset, to be read in the JSON file. + * The DSP struct is located at baseDSP in the wasm memory, + * either a monophonic DSP, or a voice in a polyphonic context. + * + * @param allocator : the wasm memory allocator + * @param baseDSP : the base DSP in the wasm memory + * @param name : the name of the soundfile + * @param url : the url of the soundfile + */ + loadSoundfile(allocator, baseDSP, name, url) { + console.log(`Soundfile ${name} paths: ${url}`); + const soundfileIds = _FaustBaseWebAudioDsp.splitSoundfileNames(url); + const item = this.fSoundfiles.find((item2) => item2.url === url); + if (!item) + throw new Error(`Soundfile with ${url} cannot be found !}`); + if (item.basePtr !== -1) { + const HEAP32 = allocator.getInt32Array(); + console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`); + HEAP32[baseDSP + item.index >> 2] = item.basePtr; + } else { + const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers); + if (soundfile) { + const HEAP32 = soundfile.getHEAP32(); + item.basePtr = soundfile.getPtr(); + console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`); + HEAP32[baseDSP + item.index >> 2] = item.basePtr; + } else { + console.log(`Soundfile ${name} for ${url} cannot be created !}`); + } + } + } + createSoundfile(allocator, soundfileIdList, soundfiles, maxChan = Soundfile.MAX_CHAN) { + let curChan = 1; + let totalLength = 0; + for (const soundfileId of soundfileIdList) { + let chan = 0; + let len = 0; + const audioData = soundfiles[soundfileId]; + if (audioData) { + chan = audioData.audioBuffer.length; + len = audioData.audioBuffer[0].length; + } else { + len = Soundfile.BUFFER_SIZE; + chan = 1; + } + curChan = Math.max(curChan, chan); + totalLength += len; + } + totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE; + const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length); + let offset = 0; + for (let part = 0; part < soundfileIdList.length; part++) { + const soundfileId = soundfileIdList[part]; + const audioData = soundfiles[soundfileId]; + if (audioData) { + soundfile.copyToOut(part, maxChan, offset, audioData); + offset += audioData.audioBuffer[0].length; + } else { + offset = soundfile.emptyFile(part, offset); + } + } + for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) { + offset = soundfile.emptyFile(part, offset); + } + soundfile.shareBuffers(curChan, maxChan); + return soundfile; + } + /** + * Init soundfiles memory. + * + * @param allocator : the wasm memory allocator + * @param sfReader : the soundfile reader + * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory + */ + initSoundfileMemory(allocator, baseDSP) { + for (const { name, url } of this.fSoundfiles) { + this.loadSoundfile(allocator, baseDSP, name, url); + } + ; + } + updateOutputs() { + if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) { + this.fOutputsTimer = 5; + this.fOutputsItems.forEach((item) => { + var _a; + return (_a = this.fOutputHandler) == null ? void 0 : _a.call(this, item, this.getParamValue(item)); + }); + } + } + // Public API + metadata(handler) { + if (this.fJSONDsp.meta) { + this.fJSONDsp.meta.forEach((meta) => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]])); + } + } + compute(input, output) { + return false; + } + setOutputParamHandler(handler) { + this.fOutputHandler = handler; + } + getOutputParamHandler() { + return this.fOutputHandler; + } + setComputeHandler(handler) { + this.fComputeHandler = handler; + } + getComputeHandler() { + return this.fComputeHandler; + } + setPlotHandler(handler) { + this.fPlotHandler = handler; + } + getPlotHandler() { + return this.fPlotHandler; + } + getNumInputs() { + return -1; + } + getNumOutputs() { + return -1; + } + midiMessage(data) { + if (this.fPlotHandler) + this.fCachedEvents.push({ data, type: "midi" }); + const cmd = data[0] >> 4; + const channel = data[0] & 15; + const data1 = data[1]; + const data2 = data[2]; + if (cmd === 11) + return this.ctrlChange(channel, data1, data2); + if (cmd === 14) + return this.pitchWheel(channel, data2 * 128 + data1); + } + ctrlChange(channel, ctrl, value) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "ctrlChange", data: [channel, ctrl, value] }); + if (this.fCtrlLabel[ctrl].length) { + this.fCtrlLabel[ctrl].forEach((ctrl2) => { + const { path, chan } = ctrl2; + if (chan === 0 || channel === chan - 1) { + this.setParamValue(path, _FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl2.min, ctrl2.max)); + if (this.fOutputHandler) + this.fOutputHandler(path, this.getParamValue(path)); + } + }); + } + } + pitchWheel(channel, wheel) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "pitchWheel", data: [channel, wheel] }); + this.fPitchwheelLabel.forEach((pw) => { + const { path, chan } = pw; + if (chan === 0 || channel === chan - 1) { + this.setParamValue(path, _FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max)); + if (this.fOutputHandler) + this.fOutputHandler(path, this.getParamValue(path)); + } + }); + } + setParamValue(path, value) { + } + getParamValue(path) { + return 0; + } + getParams() { + return this.fInputsItems; + } + getMeta() { + return this.fJSONDsp; + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.fJSONDsp.ui; + } + getDescriptors() { + return this.fDescriptor; + } + hasSoundfiles() { + return this.fSoundfiles.length > 0; + } + start() { + this.fProcessing = true; + } + stop() { + this.fProcessing = false; + } + destroy() { + this.fDestroyed = true; + this.fOutputHandler = null; + this.fComputeHandler = null; + this.fPlotHandler = null; + } +}; +var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp { + constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) { + super(sampleSize, bufferSize, soundfiles); + this.fInstance = instance; + console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`); + this.fJSONDsp = JSON.parse(this.fInstance.json); + FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback); + this.fEndMemory = this.initMemory(); + this.fInstance.api.init(this.fDSP, sampleRate); + if (this.fSoundfiles.length > 0) { + const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory); + this.initSoundfileMemory(allocator, this.fDSP); + } + } + initMemory() { + this.fDSP = 0; + const $audio = this.fJSONDsp.size; + this.fAudioInputs = $audio; + this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize; + const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize; + const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize; + const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize; + const HEAP = this.fInstance.memory.buffer; + const HEAP32 = new Int32Array(HEAP); + const HEAPF = this.fSampleSize === 4 ? new Float32Array(HEAP) : new Float64Array(HEAP); + if (this.getNumInputs() > 0) { + for (let chan = 0; chan < this.getNumInputs(); chan++) { + HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan; + } + const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, this.fAudioInputs + this.getNumInputs() * this.fPtrSize >> 2); + for (let chan = 0; chan < this.getNumInputs(); chan++) { + this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), dspInChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)); + } + } + if (this.getNumOutputs() > 0) { + for (let chan = 0; chan < this.getNumOutputs(); chan++) { + HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan; + } + const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize >> 2); + for (let chan = 0; chan < this.getNumOutputs(); chan++) { + this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), dspOutChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)); + } + } + return endMemory; + } + toString() { + return `============== Mono Memory layout ============== + this.fBufferSize: ${this.fBufferSize} + this.fJSONDsp.size: ${this.fJSONDsp.size} + this.fAudioInputs: ${this.fAudioInputs} + this.fAudioOutputs: ${this.fAudioOutputs} + this.fDSP: ${this.fDSP}`; + } + // Public API + compute(input, output) { + if (this.fDestroyed) + return false; + if (!this.fProcessing) + return true; + if (this.fFirstCall) { + this.initMemory(); + this.fFirstCall = false; + } + if (typeof input === "function") { + input(this.fInChannels); + } else { + if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) { + return true; + } + if (this.getNumOutputs() > 0 && typeof output !== "function" && (!output || !output[0] || output[0].length === 0)) { + return true; + } + if (input !== void 0) { + for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) { + const dspInput = this.fInChannels[chan]; + dspInput.set(input[chan]); + } + } + } + if (this.fComputeHandler) + this.fComputeHandler(this.fBufferSize); + this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs); + this.updateOutputs(); + let forPlot = this.fOutChannels; + if (typeof output === "function") { + output(this.fOutChannels); + } else { + for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) { + const dspOutput = this.fOutChannels[chan]; + output[chan].set(dspOutput); + } + forPlot = output; + } + if (this.fPlotHandler) { + this.fPlotHandler(forPlot, this.fBufferNum++, this.fCachedEvents.length ? this.fCachedEvents : void 0); + this.fCachedEvents = []; + } + return true; + } + metadata(handler) { + super.metadata(handler); + } + getNumInputs() { + return this.fInstance.api.getNumInputs(this.fDSP); + } + getNumOutputs() { + return this.fInstance.api.getNumOutputs(this.fDSP); + } + setParamValue(path, value) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "param", data: { path, value } }); + this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value); + } + getParamValue(path) { + return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]); + } + getMeta() { + return this.fJSONDsp; + } + getJSON() { + return this.fInstance.json; + } + getDescriptors() { + return this.fDescriptor; + } + getUI() { + return this.fJSONDsp.ui; + } +}; +var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice { + constructor($dsp, api, inputItems, pathTable, sampleRate) { + this.fFreqLabel = []; + this.fGateLabel = []; + this.fGainLabel = []; + this.fKeyLabel = []; + this.fVelLabel = []; + // Voice DSP code + // Accessed by PolyDSPImp class + this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice; + this.fNextNote = -1; + this.fNextVel = -1; + this.fDate = 0; + this.fLevel = 0; + this.fRelease = 0; + this.fDSP = $dsp; + this.fAPI = api; + this.fAPI.init(this.fDSP, sampleRate); + this.extractPaths(inputItems, pathTable); + } + // Voice state + static get kActiveVoice() { + return 0; + } + static get kFreeVoice() { + return -1; + } + static get kReleaseVoice() { + return -2; + } + static get kLegatoVoice() { + return -3; + } + static get kNoVoice() { + return -4; + } + static get VOICE_STOP_LEVEL() { + return 5e-4; + } + static midiToFreq(note) { + return 440 * 2 ** ((note - 69) / 12); + } + static normalizeVelocity(velocity) { + return velocity / 127; + } + extractPaths(inputItems, pathTable) { + inputItems.forEach((item) => { + if (item.endsWith("/gate")) { + this.fGateLabel.push(pathTable[item]); + } else if (item.endsWith("/freq")) { + this.fFreqLabel.push(pathTable[item]); + } else if (item.endsWith("/key")) { + this.fKeyLabel.push(pathTable[item]); + } else if (item.endsWith("/gain")) { + this.fGainLabel.push(pathTable[item]); + } else if (item.endsWith("/vel") && item.endsWith("/velocity")) { + this.fVelLabel.push(pathTable[item]); + } + }); + } + // Public API + keyOn(pitch, velocity, legato = false) { + if (legato) { + this.fNextNote = pitch; + this.fNextVel = velocity; + } else { + this.fFreqLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, _FaustWebAudioDspVoice.midiToFreq(pitch))); + this.fGateLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, 1)); + this.fGainLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, _FaustWebAudioDspVoice.normalizeVelocity(velocity))); + this.fKeyLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, pitch)); + this.fVelLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, velocity)); + this.fCurNote = pitch; + } + } + keyOff(hard = false) { + this.fGateLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, 0)); + if (hard) { + this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice; + } else { + this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2; + this.fCurNote = _FaustWebAudioDspVoice.kReleaseVoice; + } + } + computeLegato(bufferSize, $inputs, $outputZero, $outputsHalf) { + let size = bufferSize / 2; + this.fGateLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, 0)); + this.fAPI.compute(this.fDSP, size, $inputs, $outputZero); + this.keyOn(this.fNextNote, this.fNextVel); + this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf); + } + compute(bufferSize, $inputs, $outputs) { + this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs); + } + setParamValue(index, value) { + this.fAPI.setParamValue(this.fDSP, index, value); + } + getParamValue(index) { + return this.fAPI.getParamValue(this.fDSP, index); + } +}; +var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp { + constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) { + super(sampleSize, bufferSize, soundfiles); + this.fInstance = instance; + console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`); + this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON); + this.fJSONEffect = this.fInstance.effectAPI && this.fInstance.effectJSON ? JSON.parse(this.fInstance.effectJSON) : null; + FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback); + if (this.fJSONEffect) + FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback); + this.fEndMemory = this.initMemory(); + this.fVoiceTable = []; + for (let voice = 0; voice < this.fInstance.voices; voice++) { + this.fVoiceTable.push(new FaustWebAudioDspVoice( + this.fJSONDsp.size * voice, + this.fInstance.voiceAPI, + this.fInputsItems, + this.fPathTable, + sampleRate + )); + } + if (this.fInstance.effectAPI) + this.fInstance.effectAPI.init(this.fEffect, sampleRate); + if (this.fSoundfiles.length > 0) { + const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory); + for (let voice = 0; voice < this.fInstance.voices; voice++) { + this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice); + } + } + } + initMemory() { + this.fEffect = this.fJSONDsp.size * this.fInstance.voices; + const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0); + this.fAudioInputs = $audio; + this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize; + this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize; + this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize; + const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize; + const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize; + const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize; + const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize; + const HEAP = this.fInstance.memory.buffer; + const HEAP32 = new Int32Array(HEAP); + const HEAPF = this.fSampleSize === 4 ? new Float32Array(HEAP) : new Float64Array(HEAP); + if (this.getNumInputs() > 0) { + for (let chan = 0; chan < this.getNumInputs(); chan++) { + HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan; + } + const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, this.fAudioInputs + this.getNumInputs() * this.fPtrSize >> 2); + for (let chan = 0; chan < this.getNumInputs(); chan++) { + this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), dspInChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)); + } + } + if (this.getNumOutputs() > 0) { + for (let chan = 0; chan < this.getNumOutputs(); chan++) { + HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan; + HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan; + HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize; + } + const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize >> 2); + for (let chan = 0; chan < this.getNumOutputs(); chan++) { + this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), dspOutChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)); + } + } + return endMemory; + } + toString() { + return `============== Poly Memory layout ============== + this.fBufferSize: ${this.fBufferSize} + this.fJSONDsp.size: ${this.fJSONDsp.size} + this.fAudioInputs: ${this.fAudioInputs} + this.fAudioOutputs: ${this.fAudioOutputs} + this.fAudioMixing: ${this.fAudioMixing} + this.fAudioMixingHalf: ${this.fAudioMixingHalf}`; + } + allocVoice(voice, type) { + this.fVoiceTable[voice].fDate++; + this.fVoiceTable[voice].fCurNote = type; + return voice; + } + getPlayingVoice(pitch) { + let voicePlaying = FaustWebAudioDspVoice.kNoVoice; + let oldestDatePlaying = Number.MAX_VALUE; + for (let voice = 0; voice < this.fInstance.voices; voice++) { + if (this.fVoiceTable[voice].fCurNote === pitch) { + if (this.fVoiceTable[voice].fDate < oldestDatePlaying) { + oldestDatePlaying = this.fVoiceTable[voice].fDate; + voicePlaying = voice; + } + } + } + return voicePlaying; + } + getFreeVoice() { + for (let voice = 0; voice < this.fInstance.voices; voice++) { + if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) { + return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice); + } + } + let voiceRelease = FaustWebAudioDspVoice.kNoVoice; + let voicePlaying = FaustWebAudioDspVoice.kNoVoice; + let oldestDateRelease = Number.MAX_VALUE; + let oldestDatePlaying = Number.MAX_VALUE; + for (let voice = 0; voice < this.fInstance.voices; voice++) { + if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) { + if (this.fVoiceTable[voice].fDate < oldestDateRelease) { + oldestDateRelease = this.fVoiceTable[voice].fDate; + voiceRelease = voice; + } + } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) { + oldestDatePlaying = this.fVoiceTable[voice].fDate; + voicePlaying = voice; + } + } + if (oldestDateRelease !== Number.MAX_VALUE) { + console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`); + return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice); + } + if (oldestDatePlaying !== Number.MAX_VALUE) { + console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`); + return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice); + } + return FaustWebAudioDspVoice.kNoVoice; + } + // Public API + compute(input, output) { + if (this.fDestroyed) + return false; + if (this.fFirstCall) { + this.initMemory(); + this.fFirstCall = false; + } + if (!this.fProcessing) + return true; + if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) { + return true; + } + if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) { + return true; + } + if (input !== void 0) { + for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) { + const dspInput = this.fInChannels[chan]; + dspInput.set(input[chan]); + } + } + if (this.fComputeHandler) + this.fComputeHandler(this.fBufferSize); + this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs); + this.fVoiceTable.forEach((voice) => { + if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) { + voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf); + this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing); + voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs); + } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) { + voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing); + voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs); + voice.fRelease -= this.fBufferSize; + if (voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice && (voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL && voice.fRelease < 0)) { + voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice; + } + } + }); + if (this.fInstance.effectAPI) + this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs); + this.updateOutputs(); + if (output !== void 0) { + for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) { + const dspOutput = this.fOutChannels[chan]; + output[chan].set(dspOutput); + } + if (this.fPlotHandler) { + this.fPlotHandler(output, this.fBufferNum++, this.fCachedEvents.length ? this.fCachedEvents : void 0); + this.fCachedEvents = []; + } + } + return true; + } + getNumInputs() { + return this.fInstance.voiceAPI.getNumInputs(0); + } + getNumOutputs() { + return this.fInstance.voiceAPI.getNumOutputs(0); + } + static findPath(o, p) { + if (typeof o !== "object") { + return false; + } else if (o.address) { + return o.address === p; + } else { + for (const k in o) { + if (_FaustPolyWebAudioDsp.findPath(o[k], p)) + return true; + } + return false; + } + } + setParamValue(path, value) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "param", data: { path, value } }); + if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) { + this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value); + } else { + this.fVoiceTable.forEach((voice) => voice.setParamValue(this.fPathTable[path], value)); + } + } + getParamValue(path) { + if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) { + return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]); + } else { + return this.fVoiceTable[0].getParamValue(this.fPathTable[path]); + } + } + getMeta() { + const o = this.fJSONDsp; + const e = this.fJSONEffect; + const r = { ...o }; + if (e) { + r.ui = [{ + type: "tgroup", + label: "Sequencer", + items: [ + { type: "vgroup", label: "Instrument", items: o.ui }, + { type: "vgroup", label: "Effect", items: e.ui } + ] + }]; + } else { + r.ui = [{ + type: "tgroup", + label: "Polyphonic", + items: [ + { type: "vgroup", label: "Voices", items: o.ui } + ] + }]; + } + return r; + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.getMeta().ui; + } + getDescriptors() { + return this.fDescriptor; + } + midiMessage(data) { + const cmd = data[0] >> 4; + const channel = data[0] & 15; + const data1 = data[1]; + const data2 = data[2]; + if (cmd === 8 || cmd === 9 && data2 === 0) + return this.keyOff(channel, data1, data2); + else if (cmd === 9) + return this.keyOn(channel, data1, data2); + else + super.midiMessage(data); + } + ctrlChange(channel, ctrl, value) { + if (ctrl === 123 || ctrl === 120) { + this.allNotesOff(true); + } else { + super.ctrlChange(channel, ctrl, value); + } + } + keyOn(channel, pitch, velocity) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] }); + const voice = this.getFreeVoice(); + this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice); + } + keyOff(channel, pitch, velocity) { + if (this.fPlotHandler) + this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] }); + const voice = this.getPlayingVoice(pitch); + if (voice !== FaustWebAudioDspVoice.kNoVoice) { + this.fVoiceTable[voice].keyOff(); + } else { + console.log("Playing pitch = %d not found\n", pitch); + } + } + allNotesOff(hard = true) { + this.fCachedEvents.push({ type: "ctrlChange", data: [0, 123, 0] }); + this.fVoiceTable.forEach((voice) => voice.keyOff(hard)); + } +}; + +// src/FaustOfflineProcessor.ts +var FaustOfflineProcessor = class { + constructor(instance, bufferSize) { + this.fDSPCode = instance; + this.fBufferSize = bufferSize; + this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize)); + this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize)); + } + // Public API + getParameterDescriptors() { + const params = []; + const callback = (item) => { + let param = null; + const polyKeywords = ["/gate", "/freq", "/gain", "/key", "/vel", "/velocity"]; + const isPolyReserved = "address" in item && !!polyKeywords.find((k) => item.address.endsWith(k)); + if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) { + if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") { + param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 }; + } else if (item.type === "button" || item.type === "checkbox") { + param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 }; + } + } + if (param) + params.push(param); + }; + FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback); + return params; + } + compute(input, output) { + return this.fDSPCode.compute(input, output); + } + setOutputParamHandler(handler) { + this.fDSPCode.setOutputParamHandler(handler); + } + getOutputParamHandler() { + return this.fDSPCode.getOutputParamHandler(); + } + setComputeHandler(handler) { + this.fDSPCode.setComputeHandler(handler); + } + getComputeHandler() { + return this.fDSPCode.getComputeHandler(); + } + setPlotHandler(handler) { + this.fDSPCode.setPlotHandler(handler); + } + getPlotHandler() { + return this.fDSPCode.getPlotHandler(); + } + getNumInputs() { + return this.fDSPCode.getNumInputs(); + } + getNumOutputs() { + return this.fDSPCode.getNumOutputs(); + } + metadata(handler) { + } + midiMessage(data) { + this.fDSPCode.midiMessage(data); + } + ctrlChange(chan, ctrl, value) { + this.fDSPCode.ctrlChange(chan, ctrl, value); + } + pitchWheel(chan, value) { + this.fDSPCode.pitchWheel(chan, value); + } + setParamValue(path, value) { + this.fDSPCode.setParamValue(path, value); + } + getParamValue(path) { + return this.fDSPCode.getParamValue(path); + } + getParams() { + return this.fDSPCode.getParams(); + } + getMeta() { + return this.fDSPCode.getMeta(); + } + getJSON() { + return this.fDSPCode.getJSON(); + } + getDescriptors() { + return this.fDSPCode.getDescriptors(); + } + getUI() { + return this.fDSPCode.getUI(); + } + start() { + this.fDSPCode.start(); + } + stop() { + this.fDSPCode.stop(); + } + destroy() { + this.fDSPCode.destroy(); + } + get hasAccInput() { + return this.fDSPCode.hasAccInput; + } + propagateAcc(accelerationIncludingGravity, invert = false) { + this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert); + } + get hasGyrInput() { + return this.fDSPCode.hasGyrInput; + } + propagateGyr(event) { + this.fDSPCode.propagateGyr(event); + } + /** + * Render frames in an array. + * + * @param inputs - input signal + * @param length - the number of frames to render (default: bufferSize) + * @param onUpdate - a callback after each buffer calculated, with an argument "current sample" + * @return an array of Float32Array with the rendered frames + */ + render(inputs = [], length = this.fBufferSize, onUpdate) { + let l = 0; + const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length)); + this.fDSPCode.start(); + while (l < length) { + const sliceLength = Math.min(length - l, this.fBufferSize); + for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) { + let input; + if (inputs[i]) { + if (inputs[i].length <= l) { + input = new Float32Array(sliceLength); + } else if (inputs[i].length > l + sliceLength) { + input = inputs[i].subarray(l, l + sliceLength); + } else { + input = inputs[i].subarray(l, inputs[i].length); + } + } else { + input = new Float32Array(sliceLength); + } + this.fInputs[i] = input; + } + this.fDSPCode.compute(this.fInputs, this.fOutputs); + for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) { + const output = this.fOutputs[i]; + if (sliceLength < this.fBufferSize) { + outputs[i].set(output.subarray(0, sliceLength), l); + } else { + outputs[i].set(output, l); + } + } + l += this.fBufferSize; + onUpdate == null ? void 0 : onUpdate(l); + } + this.fDSPCode.stop(); + return outputs; + } +}; +var FaustMonoOfflineProcessor = class extends FaustOfflineProcessor { +}; +var FaustPolyOfflineProcessor = class extends FaustOfflineProcessor { + keyOn(channel, pitch, velocity) { + this.fDSPCode.keyOn(channel, pitch, velocity); + } + keyOff(channel, pitch, velocity) { + this.fDSPCode.keyOff(channel, pitch, velocity); + } + allNotesOff(hard) { + this.fDSPCode.allNotesOff(hard); + } +}; +var FaustOfflineProcessor_default = FaustOfflineProcessor; + +// src/FaustSvgDiagrams.ts +var FaustSvgDiagrams = class { + constructor(compiler) { + this.compiler = compiler; + } + from(name, code, args) { + const fs = this.compiler.fs(); + try { + const files2 = fs.readdir(`/${name}-svg/`); + files2.filter((file) => file !== "." && file !== "..").forEach((file) => fs.unlink(`/${name}-svg/${file}`)); + } catch { + } + const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`); + if (!success) + throw new Error(this.compiler.getErrorMessage()); + const svgs = {}; + const files = fs.readdir(`/${name}-svg/`); + files.filter((file) => file !== "." && file !== "..").forEach((file) => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: "utf8" })); + return svgs; + } +}; +var FaustSvgDiagrams_default = FaustSvgDiagrams; + +// src/FaustCmajor.ts +var FaustCmajor = class { + constructor(compiler) { + this.fCompiler = compiler; + } + compile(name, code, args) { + const fs = this.fCompiler.fs(); + const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`); + return success ? fs.readFile(`${name}.cmajor`, { encoding: "utf8" }) : ""; + } +}; +var FaustCmajor_default = FaustCmajor; + +// src/LibFaust.ts +var LibFaust = class { + constructor(module) { + this.fModule = module; + this.fCompiler = new module.libFaustWasm(); + this.fFileSystem = this.fModule.FS; + } + module() { + return this.fModule; + } + fs() { + return this.fFileSystem; + } + version() { + return this.fCompiler.version(); + } + createDSPFactory(name, code, args, useInternalMemory) { + return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory); + } + deleteDSPFactory(cFactory) { + return this.fCompiler.deleteDSPFactory(cFactory); + } + expandDSP(name, code, args) { + return this.fCompiler.expandDSP(name, code, args); + } + generateAuxFiles(name, code, args) { + return this.fCompiler.generateAuxFiles(name, code, args); + } + deleteAllDSPFactories() { + return this.fCompiler.deleteAllDSPFactories(); + } + getErrorAfterException() { + return this.fCompiler.getErrorAfterException(); + } + cleanupAfterException() { + return this.fCompiler.cleanupAfterException(); + } + getInfos(what) { + return this.fCompiler.getInfos(what); + } + toString() { + return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`; + } +}; +var LibFaust_default = LibFaust; + +// src/WavEncoder.ts +var WavEncoder = class { + static encode(audioBuffer, options) { + const numberOfChannels = audioBuffer.length; + const length = audioBuffer[0].length; + const { shared, float } = options; + const bitDepth = float ? 32 : options.bitDepth | 0 || 16; + const byteDepth = bitDepth >> 3; + const byteLength = length * numberOfChannels * byteDepth; + const AB = shared ? globalThis.SharedArrayBuffer || globalThis.ArrayBuffer : globalThis.ArrayBuffer; + const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT); + const dataView = new DataView(ab); + const writer = new Writer(dataView); + const format = { + formatId: float ? 3 : 1, + float: !!float, + numberOfChannels, + sampleRate: options.sampleRate, + symmetric: !!options.symmetric, + length, + bitDepth, + byteDepth + }; + this.writeHeader(writer, format); + this.writeData(writer, audioBuffer, format); + return ab; + } + static writeHeader(writer, format) { + const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format; + writer.string("RIFF"); + writer.uint32(writer.dataView.byteLength - 8); + writer.string("WAVE"); + writer.string("fmt "); + writer.uint32(16); + writer.uint16(formatId); + writer.uint16(numberOfChannels); + writer.uint32(sampleRate); + writer.uint32(sampleRate * numberOfChannels * byteDepth); + writer.uint16(numberOfChannels * byteDepth); + writer.uint16(bitDepth); + writer.string("data"); + writer.uint32(length * numberOfChannels * byteDepth); + return writer.pos; + } + static writeData(writer, audioBuffer, format) { + const { bitDepth, float, length, numberOfChannels, symmetric } = format; + if (bitDepth === 32 && float) { + const { dataView, pos } = writer; + const ab = dataView.buffer; + const f32View = new Float32Array(ab, pos); + if (numberOfChannels === 1) { + f32View.set(audioBuffer[0]); + return; + } + for (let ch = 0; ch < numberOfChannels; ch++) { + const channel = audioBuffer[ch]; + for (let i = 0; i < length; i++) { + f32View[i * numberOfChannels + ch] = channel[i]; + } + } + return; + } + const encoderOption = float ? "f" : symmetric ? "s" : ""; + const methodName = "pcm" + bitDepth + encoderOption; + if (!writer[methodName]) { + throw new TypeError("Not supported bit depth: " + bitDepth); + } + const write = writer[methodName].bind(writer); + for (let i = 0; i < length; i++) { + for (let j = 0; j < numberOfChannels; j++) { + write(audioBuffer[j][i]); + } + } + } +}; +var Writer = class { + constructor(dataView) { + this.pos = 0; + this.dataView = dataView; + } + int16(value) { + this.dataView.setInt16(this.pos, value, true); + this.pos += 2; + } + uint16(value) { + this.dataView.setUint16(this.pos, value, true); + this.pos += 2; + } + uint32(value) { + this.dataView.setUint32(this.pos, value, true); + this.pos += 4; + } + string(value) { + for (let i = 0, imax = value.length; i < imax; i++) { + this.dataView.setUint8(this.pos++, value.charCodeAt(i)); + } + } + pcm8(valueIn) { + let value = valueIn; + value = Math.max(-1, Math.min(value, 1)); + value = (value * 0.5 + 0.5) * 255; + value = Math.round(value) | 0; + this.dataView.setUint8( + this.pos, + value + /* , true*/ + ); + this.pos += 1; + } + pcm8s(valueIn) { + let value = valueIn; + value = Math.round(value * 128) + 128; + value = Math.max(0, Math.min(value, 255)); + this.dataView.setUint8( + this.pos, + value + /* , true*/ + ); + this.pos += 1; + } + pcm16(valueIn) { + let value = valueIn; + value = Math.max(-1, Math.min(value, 1)); + value = value < 0 ? value * 32768 : value * 32767; + value = Math.round(value) | 0; + this.dataView.setInt16(this.pos, value, true); + this.pos += 2; + } + pcm16s(valueIn) { + let value = valueIn; + value = Math.round(value * 32768); + value = Math.max(-32768, Math.min(value, 32767)); + this.dataView.setInt16(this.pos, value, true); + this.pos += 2; + } + pcm24(valueIn) { + let value = valueIn; + value = Math.max(-1, Math.min(value, 1)); + value = value < 0 ? 16777216 + value * 8388608 : value * 8388607; + value = Math.round(value) | 0; + const x0 = value >> 0 & 255; + const x1 = value >> 8 & 255; + const x2 = value >> 16 & 255; + this.dataView.setUint8(this.pos + 0, x0); + this.dataView.setUint8(this.pos + 1, x1); + this.dataView.setUint8(this.pos + 2, x2); + this.pos += 3; + } + pcm24s(valueIn) { + let value = valueIn; + value = Math.round(value * 8388608); + value = Math.max(-8388608, Math.min(value, 8388607)); + const x0 = value >> 0 & 255; + const x1 = value >> 8 & 255; + const x2 = value >> 16 & 255; + this.dataView.setUint8(this.pos + 0, x0); + this.dataView.setUint8(this.pos + 1, x1); + this.dataView.setUint8(this.pos + 2, x2); + this.pos += 3; + } + pcm32(valueIn) { + let value = valueIn; + value = Math.max(-1, Math.min(value, 1)); + value = value < 0 ? value * 2147483648 : value * 2147483647; + value = Math.round(value) | 0; + this.dataView.setInt32(this.pos, value, true); + this.pos += 4; + } + pcm32s(valueIn) { + let value = valueIn; + value = Math.round(value * 2147483648); + value = Math.max(-2147483648, Math.min(value, 2147483647)); + this.dataView.setInt32(this.pos, value, true); + this.pos += 4; + } + pcm32f(value) { + this.dataView.setFloat32(this.pos, value, true); + this.pos += 4; + } +}; +var WavEncoder_default = WavEncoder; + +// src/WavDecoder.ts +var WavDecoder = class { + static decode(buffer, options) { + const dataView = new DataView(buffer); + const reader = new Reader(dataView); + if (reader.string(4) !== "RIFF") { + throw new TypeError("Invalid WAV file"); + } + reader.uint32(); + if (reader.string(4) !== "WAVE") { + throw new TypeError("Invalid WAV file"); + } + let format = null; + let audioData = null; + do { + const chunkType = reader.string(4); + const chunkSize = reader.uint32(); + if (chunkType === "fmt ") { + format = this.decodeFormat(reader, chunkSize); + } else if (chunkType === "data") { + audioData = this.decodeData(reader, chunkSize, format, options || {}); + } else { + reader.skip(chunkSize); + } + } while (audioData === null); + return audioData; + } + static decodeFormat(reader, chunkSize) { + const formats = { + 1: "lpcm", + 3: "lpcm" + }; + const formatId = reader.uint16(); + if (!formats.hasOwnProperty(formatId)) { + throw new TypeError("Unsupported format in WAV file: 0x" + formatId.toString(16)); + } + const format = { + formatId, + float: formatId === 3, + numberOfChannels: reader.uint16(), + sampleRate: reader.uint32(), + byteRate: reader.uint32(), + blockSize: reader.uint16(), + bitDepth: reader.uint16() + }; + reader.skip(chunkSize - 16); + return format; + } + static decodeData(reader, chunkSizeIn, format, options) { + const chunkSize = Math.min(chunkSizeIn, reader.remain()); + const length = Math.floor(chunkSize / format.blockSize); + const numberOfChannels = format.numberOfChannels; + const sampleRate = format.sampleRate; + const channelData = new Array(numberOfChannels); + for (let ch = 0; ch < numberOfChannels; ch++) { + const AB = options.shared ? globalThis.SharedArrayBuffer || globalThis.ArrayBuffer : globalThis.ArrayBuffer; + const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT); + channelData[ch] = new Float32Array(ab); + } + this.readPCM(reader, channelData, length, format, options); + return { + numberOfChannels, + length, + sampleRate, + channelData + }; + } + static readPCM(reader, channelData, length, format, options) { + const bitDepth = format.bitDepth; + const decoderOption = format.float ? "f" : options.symmetric ? "s" : ""; + const methodName = "pcm" + bitDepth + decoderOption; + if (!reader[methodName]) { + throw new TypeError("Not supported bit depth: " + format.bitDepth); + } + const read = reader[methodName].bind(reader); + const numberOfChannels = format.numberOfChannels; + for (let i = 0; i < length; i++) { + for (let ch = 0; ch < numberOfChannels; ch++) { + channelData[ch][i] = read(); + } + } + } +}; +var Reader = class { + constructor(dataView) { + this.pos = 0; + this.dataView = dataView; + } + remain() { + return this.dataView.byteLength - this.pos; + } + skip(n) { + this.pos += n; + } + uint8() { + const data = this.dataView.getUint8(this.pos); + this.pos += 1; + return data; + } + int16() { + const data = this.dataView.getInt16(this.pos, true); + this.pos += 2; + return data; + } + uint16() { + const data = this.dataView.getUint16(this.pos, true); + this.pos += 2; + return data; + } + uint32() { + const data = this.dataView.getUint32(this.pos, true); + this.pos += 4; + return data; + } + string(n) { + let data = ""; + for (let i = 0; i < n; i++) { + data += String.fromCharCode(this.uint8()); + } + return data; + } + pcm8() { + const data = this.dataView.getUint8(this.pos) - 128; + this.pos += 1; + return data < 0 ? data / 128 : data / 127; + } + pcm8s() { + const data = this.dataView.getUint8(this.pos) - 127.5; + this.pos += 1; + return data / 127.5; + } + pcm16() { + const data = this.dataView.getInt16(this.pos, true); + this.pos += 2; + return data < 0 ? data / 32768 : data / 32767; + } + pcm16s() { + const data = this.dataView.getInt16(this.pos, true); + this.pos += 2; + return data / 32768; + } + pcm24() { + const x0 = this.dataView.getUint8(this.pos + 0); + const x1 = this.dataView.getUint8(this.pos + 1); + const x2 = this.dataView.getUint8(this.pos + 2); + const xx = x0 + (x1 << 8) + (x2 << 16); + const data = xx > 8388608 ? xx - 16777216 : xx; + this.pos += 3; + return data < 0 ? data / 8388608 : data / 8388607; + } + pcm24s() { + const x0 = this.dataView.getUint8(this.pos + 0); + const x1 = this.dataView.getUint8(this.pos + 1); + const x2 = this.dataView.getUint8(this.pos + 2); + const xx = x0 + (x1 << 8) + (x2 << 16); + const data = xx > 8388608 ? xx - 16777216 : xx; + this.pos += 3; + return data / 8388608; + } + pcm32() { + const data = this.dataView.getInt32(this.pos, true); + this.pos += 4; + return data < 0 ? data / 2147483648 : data / 2147483647; + } + pcm32s() { + const data = this.dataView.getInt32(this.pos, true); + this.pos += 4; + return data / 2147483648; + } + pcm32f() { + const data = this.dataView.getFloat32(this.pos, true); + this.pos += 4; + return data; + } + pcm64f() { + const data = this.dataView.getFloat64(this.pos, true); + this.pos += 8; + return data; + } +}; +var WavDecoder_default = WavDecoder; + +// src/SoundfileReader.ts +var SoundfileReader = class { + // Set the fallback paths + static get fallbackPaths() { + return [location.href, this.getParentUrl(location.href), location.origin]; + } + /** + * Extract the parent URL from an URL. + * @param url : the URL + * @returns : the parent URL + */ + static getParentUrl(url) { + return url.substring(0, url.lastIndexOf("/") + 1); + } + /** + * Convert an audio buffer to audio data. + * + * @param audioBuffer : the audio buffer to convert + * @returns : the audio data + */ + static toAudioData(audioBuffer) { + const { sampleRate, numberOfChannels } = audioBuffer; + return { + sampleRate, + audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i)) + }; + } + /** + * Extract the URLs from the metadata. + * + * @param dspMeta : the metadata + * @returns : the URLs + */ + static findSoundfilesFromMeta(dspMeta) { + const soundfiles = {}; + const callback = (item) => { + if (item.type === "soundfile") { + const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url); + urls.forEach((url) => soundfiles[url] = null); + } + }; + FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback); + return soundfiles; + } + /** + * Check if the file exists. + * + * @param url : the url of the file to check + * @returns : true if the file exists, otherwise false + */ + static async checkFileExists(url) { + try { + console.log(`"checkFileExists" url: ${url}`); + const response = await fetch(url); + console.log(`"checkFileExists" response.ok: ${response.ok}`); + return response.ok; + } catch (error) { + console.error("Fetch error:", error); + return false; + } + } + /** + * Fetch the soundfile. + * + * @param url : the url of the soundfile + * @param audioCtx : the audio context + * @returns : the audio data + */ + static async fetchSoundfile(url, audioCtx) { + console.log(`Loading sound file from ${url}`); + const response = await fetch(url); + if (!response.ok) + throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`); + const arrayBuffer = await response.arrayBuffer(); + const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer); + return this.toAudioData(audioBuffer); + } + /** + * Load the soundfile. + * + * @param filename : the filename + * @param metaUrls : the metadata URLs + * @param soundfiles : the soundfiles + * @param audioCtx : the audio context + */ + static async loadSoundfile(filename, metaUrls, soundfiles, audioCtx) { + if (soundfiles[filename]) + return; + const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map((path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href)]; + const checkResults = await Promise.all(urlsToCheck.map((url) => this.checkFileExists(url))); + const successIndex = checkResults.findIndex((r) => !!r); + if (successIndex === -1) + throw new Error(`Failed to load sound file ${filename}, all check failed.`); + soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx); + } + /** + * Load the soundfiles, public API. + * + * @param dspMeta : the metadata + * @param soundfilesIn : the soundfiles + * @param audioCtx : the audio context + * @returns : the soundfiles + */ + static async loadSoundfiles(dspMeta, soundfilesIn, audioCtx) { + const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta); + const soundfiles = this.findSoundfilesFromMeta(dspMeta); + for (const id in soundfiles) { + if (soundfilesIn[id]) { + soundfiles[id] = soundfilesIn[id]; + continue; + } + try { + await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx); + } catch (error) { + console.error(error); + } + } + return soundfiles; + } +}; +var SoundfileReader_default = SoundfileReader; + +// src/FaustAudioWorkletNode.ts +var _hasAccInput, _hasGyrInput; +var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) { + constructor(context, name, factory, options = {}) { + const JSONObj = JSON.parse(factory.json); + super(context, name, { + numberOfInputs: JSONObj.inputs > 0 ? 1 : 0, + numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0, + channelCount: Math.max(1, JSONObj.inputs), + outputChannelCount: [JSONObj.outputs], + channelCountMode: "explicit", + channelInterpretation: "speakers", + processorOptions: options.processorOptions, + ...options + }); + __privateAdd(this, _hasAccInput, false); + __privateAdd(this, _hasGyrInput, false); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + this.fJSONDsp = JSONObj; + this.fJSON = factory.json; + this.fOutputHandler = null; + this.fComputeHandler = null; + this.fPlotHandler = null; + this.fDescriptor = []; + this.fInputsItems = []; + this.fUICallback = (item) => { + if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") { + this.fInputsItems.push(item.address); + this.fDescriptor.push(item); + if (!item.meta) + return; + item.meta.forEach((meta) => { + const { midi, acc, gyr } = meta; + if (acc) + __privateSet(this, _hasAccInput, true); + if (gyr) + __privateSet(this, _hasGyrInput, true); + }); + } + }; + FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback); + this.port.onmessage = (e) => { + if (e.data.type === "param" && this.fOutputHandler) { + this.fOutputHandler(e.data.path, e.data.value); + } else if (e.data.type === "plot" && this.fPlotHandler) { + this.fPlotHandler(e.data.value, e.data.index, e.data.events); + } + }; + } + /** Setup accelerometer and gyroscope handlers */ + async startSensors() { + if (this.hasAccInput) { + if (window.DeviceMotionEvent) { + if (typeof window.DeviceMotionEvent.requestPermission === "function") { + try { + const response = await window.DeviceMotionEvent.requestPermission(); + if (response === "granted") { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); + throw new Error("Unable to access the accelerometer."); + } + } catch (error) { + console.error(error); + } + } else { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } + } else { + console.log("Cannot set the accelerometer handler."); + } + } + if (this.hasGyrInput) { + if (window.DeviceMotionEvent) { + if (typeof window.DeviceOrientationEvent.requestPermission === "function") { + try { + const response = await window.DeviceOrientationEvent.requestPermission(); + if (response === "granted") { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } else if (response === "denied") { + alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access."); + throw new Error("Unable to access the gyroscope."); + } + } catch (error) { + console.error(error); + } + } else { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } else { + console.log("Cannot set the gyroscope handler."); + } + } + } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } + setOutputParamHandler(handler) { + this.fOutputHandler = handler; + } + getOutputParamHandler() { + return this.fOutputHandler; + } + setComputeHandler(handler) { + this.fComputeHandler = handler; + } + getComputeHandler() { + return this.fComputeHandler; + } + setPlotHandler(handler) { + this.fPlotHandler = handler; + if (this.fPlotHandler) { + this.port.postMessage({ type: "setPlotHandler", data: true }); + } else { + this.port.postMessage({ type: "setPlotHandler", data: false }); + } + } + getPlotHandler() { + return this.fPlotHandler; + } + setupWamEventHandler() { + this.port.postMessage({ type: "setupWamEventHandler" }); + } + getNumInputs() { + return this.fJSONDsp.inputs; + } + getNumOutputs() { + return this.fJSONDsp.outputs; + } + // Implemented in subclasses + compute(inputs, outputs) { + return false; + } + metadata(handler) { + if (this.fJSONDsp.meta) { + this.fJSONDsp.meta.forEach((meta) => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]])); + } + } + midiMessage(data) { + const cmd = data[0] >> 4; + const channel = data[0] & 15; + const data1 = data[1]; + const data2 = data[2]; + if (cmd === 11) + this.ctrlChange(channel, data1, data2); + else if (cmd === 14) + this.pitchWheel(channel, data2 * 128 + data1); + else + this.port.postMessage({ type: "midi", data }); + } + ctrlChange(channel, ctrl, value) { + const e = { type: "ctrlChange", data: [channel, ctrl, value] }; + this.port.postMessage(e); + } + pitchWheel(channel, wheel) { + const e = { type: "pitchWheel", data: [channel, wheel] }; + this.port.postMessage(e); + } + get hasAccInput() { + return __privateGet(this, _hasAccInput); + } + propagateAcc(accelerationIncludingGravity, invert = false) { + if (!accelerationIncludingGravity) + return; + const e = { type: "acc", data: accelerationIncludingGravity, invert }; + this.port.postMessage(e); + } + get hasGyrInput() { + return __privateGet(this, _hasGyrInput); + } + propagateGyr(event) { + if (!event) + return; + const e = { type: "gyr", data: event }; + this.port.postMessage(e); + } + setParamValue(path, value) { + const e = { type: "param", data: { path, value } }; + this.port.postMessage(e); + const param = this.parameters.get(path); + if (param) + param.setValueAtTime(value, this.context.currentTime); + } + getParamValue(path) { + const param = this.parameters.get(path); + return param ? param.value : 0; + } + getParams() { + return this.fInputsItems; + } + getMeta() { + return this.fJSONDsp; + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.fJSONDsp.ui; + } + getDescriptors() { + return this.fDescriptor; + } + start() { + this.port.postMessage({ type: "start" }); + } + stop() { + this.port.postMessage({ type: "stop" }); + } + destroy() { + this.port.postMessage({ type: "destroy" }); + this.port.close(); + } +}; +_hasAccInput = new WeakMap(); +_hasGyrInput = new WeakMap(); +var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode { + constructor(context, options) { + super(context, options.processorOptions.name, options.processorOptions.factory, options); + this.onprocessorerror = (e) => { + throw e; + }; + } +}; +var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode { + constructor(context, options) { + super( + context, + options.processorOptions.name, + options.processorOptions.voiceFactory, + options + ); + this.onprocessorerror = (e) => { + throw e; + }; + this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null; + if (this.fJSONEffect) { + FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback); + } + } + // Public API + keyOn(channel, pitch, velocity) { + const e = { type: "keyOn", data: [channel, pitch, velocity] }; + this.port.postMessage(e); + } + keyOff(channel, pitch, velocity) { + const e = { type: "keyOff", data: [channel, pitch, velocity] }; + this.port.postMessage(e); + } + allNotesOff(hard) { + const e = { type: "ctrlChange", data: [0, 123, 0] }; + this.port.postMessage(e); + } + getMeta() { + const o = this.fJSONDsp; + const e = this.fJSONEffect; + const r = { ...o }; + if (e) { + r.ui = [{ + type: "tgroup", + label: "Sequencer", + items: [ + { type: "vgroup", label: "Instrument", items: o.ui }, + { type: "vgroup", label: "Effect", items: e.ui } + ] + }]; + } else { + r.ui = [{ + type: "tgroup", + label: "Polyphonic", + items: [ + { type: "vgroup", label: "Voices", items: o.ui } + ] + }]; + } + return r; + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.getMeta().ui; + } +}; + +// src/FaustScriptProcessorNode.ts +var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) { + constructor() { + super(...arguments); + // Public API + // Accelerometer and gyroscope handlers + this.handleDeviceMotion = ({ accelerationIncludingGravity }) => { + const isAndroid = /Android/i.test(navigator.userAgent); + if (!accelerationIncludingGravity) + return; + const { x, y, z } = accelerationIncludingGravity; + this.propagateAcc({ x, y, z }, isAndroid); + }; + this.handleDeviceOrientation = ({ alpha, beta, gamma }) => { + this.propagateGyr({ alpha, beta, gamma }); + }; + } + init(instance) { + this.fDSPCode = instance; + this.fInputs = new Array(this.fDSPCode.getNumInputs()); + this.fOutputs = new Array(this.fDSPCode.getNumOutputs()); + this.onaudioprocess = (e) => { + for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) { + this.fInputs[chan] = e.inputBuffer.getChannelData(chan); + } + for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) { + this.fOutputs[chan] = e.outputBuffer.getChannelData(chan); + } + return this.fDSPCode.compute(this.fInputs, this.fOutputs); + }; + this.start(); + } + /** Setup accelerometer and gyroscope handlers */ + async startSensors() { + if (this.hasAccInput) { + if (window.DeviceMotionEvent) { + if (typeof window.DeviceMotionEvent.requestPermission === "function") { + try { + const response = await window.DeviceMotionEvent.requestPermission(); + if (response !== "granted") + throw new Error("Unable to access the accelerometer."); + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } catch (error) { + console.error(error); + } + } else { + window.addEventListener("devicemotion", this.handleDeviceMotion, true); + } + } else { + console.log("Cannot set the accelerometer handler."); + } + } + if (this.hasGyrInput) { + if (window.DeviceMotionEvent) { + if (typeof window.DeviceOrientationEvent.requestPermission === "function") { + try { + const response = await window.DeviceOrientationEvent.requestPermission(); + if (response !== "granted") + throw new Error("Unable to access the gyroscope."); + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } catch (error) { + console.error(error); + } + } else { + window.addEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } else { + console.log("Cannot set the gyroscope handler."); + } + } + } + stopSensors() { + if (this.hasAccInput) { + window.removeEventListener("devicemotion", this.handleDeviceMotion, true); + } + if (this.hasGyrInput) { + window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true); + } + } + compute(input, output) { + return this.fDSPCode.compute(input, output); + } + setOutputParamHandler(handler) { + this.fDSPCode.setOutputParamHandler(handler); + } + getOutputParamHandler() { + return this.fDSPCode.getOutputParamHandler(); + } + setComputeHandler(handler) { + this.fDSPCode.setComputeHandler(handler); + } + getComputeHandler() { + return this.fDSPCode.getComputeHandler(); + } + setPlotHandler(handler) { + this.fDSPCode.setPlotHandler(handler); + } + getPlotHandler() { + return this.fDSPCode.getPlotHandler(); + } + getNumInputs() { + return this.fDSPCode.getNumInputs(); + } + getNumOutputs() { + return this.fDSPCode.getNumOutputs(); + } + metadata(handler) { + } + midiMessage(data) { + this.fDSPCode.midiMessage(data); + } + ctrlChange(chan, ctrl, value) { + this.fDSPCode.ctrlChange(chan, ctrl, value); + } + pitchWheel(chan, value) { + this.fDSPCode.pitchWheel(chan, value); + } + setParamValue(path, value) { + this.fDSPCode.setParamValue(path, value); + } + getParamValue(path) { + return this.fDSPCode.getParamValue(path); + } + getParams() { + return this.fDSPCode.getParams(); + } + getMeta() { + return this.fDSPCode.getMeta(); + } + getJSON() { + return this.fDSPCode.getJSON(); + } + getDescriptors() { + return this.fDSPCode.getDescriptors(); + } + getUI() { + return this.fDSPCode.getUI(); + } + start() { + this.fDSPCode.start(); + } + stop() { + this.fDSPCode.stop(); + } + destroy() { + this.fDSPCode.destroy(); + } + get hasAccInput() { + return this.fDSPCode.hasAccInput; + } + propagateAcc(accelerationIncludingGravity, invert = false) { + this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert); + } + get hasGyrInput() { + return this.fDSPCode.hasGyrInput; + } + propagateGyr(event) { + this.fDSPCode.propagateGyr(event); + } +}; +var FaustMonoScriptProcessorNode = class extends FaustScriptProcessorNode { +}; +var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode { + keyOn(channel, pitch, velocity) { + this.fDSPCode.keyOn(channel, pitch, velocity); + } + keyOff(channel, pitch, velocity) { + this.fDSPCode.keyOff(channel, pitch, velocity); + } + allNotesOff(hard) { + this.fDSPCode.allNotesOff(hard); + } +}; + +// src/FaustDspGenerator.ts +var _FaustMonoDspGenerator = class _FaustMonoDspGenerator { + constructor() { + this.factory = null; + } + async compile(compiler, name, code, args) { + this.factory = await compiler.createMonoDSPFactory(name, code, args); + if (this.factory) { + this.name = name; + return this; + } else { + return null; + } + } + addSoundfiles(soundfileMap) { + if (!this.factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + for (const id in soundfileMap) { + this.factory.soundfiles[id] = soundfileMap[id]; + } + } + getSoundfileList() { + if (!this.factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(this.factory.json); + const map = SoundfileReader_default.findSoundfilesFromMeta(meta); + return Object.keys(map); + } + async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) { + var _a, _b; + if (!factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(factory.json); + const sampleSize = meta.compile_options.match("-double") ? 8 : 4; + factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context); + if (sp) { + const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory); + const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles); + const sp2 = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()); + Object.setPrototypeOf(sp2, FaustMonoScriptProcessorNode.prototype); + sp2.init(monoDsp); + return sp2; + } else { + if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context)) + _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set()); + if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) { + try { + const processorCode = ` +// DSP name and JSON string for DSP are generated +const faustData = ${JSON.stringify({ + processorName, + dspName: name, + dspMeta: meta, + poly: false + })}; +// Implementation needed classes of functions +var ${FaustDspInstance.name} = ${FaustDspInstance.toString()} +var FaustDspInstance = ${FaustDspInstance.name}; +var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()} +var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name}; +var ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()} +var FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name}; +var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()} +var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name}; +var ${Soundfile.name} = ${Soundfile.toString()} +var Soundfile = ${Soundfile.name}; +var ${WasmAllocator.name} = ${WasmAllocator.toString()} +var WasmAllocator = ${WasmAllocator.name}; +var ${FaustSensors.name} = ${FaustSensors.toString()} +var FaustSensors = ${FaustSensors.name}; +// Put them in dependencies +const dependencies = { + FaustBaseWebAudioDsp, + FaustMonoWebAudioDsp, + FaustWasmInstantiator +}; +// Generate the actual AudioWorkletProcessor code +(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData); +`; + const url = URL.createObjectURL(new Blob([processorCode], { type: "text/javascript" })); + await context.audioWorklet.addModule(url); + (_b = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName); + } catch (e) { + throw e; + } + } + const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } }); + return node; + } + } + async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) { + var _a, _b; + if (!factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(factory.json); + const sampleSize = meta.compile_options.match("-double") ? 8 : 4; + factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context); + if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context)) + _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set()); + if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) { + try { + const processorCode = ` +// DSP name and JSON string for DSP are generated +const faustData = ${JSON.stringify({ + processorName, + dspName: name, + dspMeta: meta, + fftOptions + })}; +// Implementation needed classes of functions +var ${FaustDspInstance.name} = ${FaustDspInstance.toString()} +var FaustDspInstance = ${FaustDspInstance.name}; +var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()} +var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name}; +var ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()} +var FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name}; +var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()} +var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name}; +var ${Soundfile.name} = ${Soundfile.toString()} +var Soundfile = ${Soundfile.name}; +var ${WasmAllocator.name} = ${WasmAllocator.toString()} +var WasmAllocator = ${WasmAllocator.name}; +var ${FaustSensors.name} = ${FaustSensors.toString()} +var FaustSensors = ${FaustSensors.name}; +var FFTUtils = ${fftUtils.toString()} +// Put them in dependencies +const dependencies = { + FaustBaseWebAudioDsp, + FaustMonoWebAudioDsp, + FaustWasmInstantiator, + FFTUtils +}; +// Generate the actual AudioWorkletProcessor code +(${FaustFFTAudioWorkletProcessor_default.toString()})(dependencies, faustData); +`; + const url = URL.createObjectURL(new Blob([processorCode], { type: "text/javascript" })); + await context.audioWorklet.addModule(url); + (_b = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName); + } catch (e) { + throw e; + } + } + const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } }); + if (fftOptions.fftSize) { + const param = node.parameters.get("fftSize"); + if (param) + param.value = fftOptions.fftSize; + } + if (fftOptions.fftOverlap) { + const param = node.parameters.get("fftOverlap"); + if (param) + param.value = fftOptions.fftOverlap; + } + if (typeof fftOptions.defaultWindowFunction === "number") { + const param = node.parameters.get("windowFunction"); + if (param) + param.value = fftOptions.defaultWindowFunction + 1; + } + if (typeof fftOptions.noIFFT === "boolean") { + const param = node.parameters.get("noIFFT"); + if (param) + param.value = +fftOptions.noIFFT; + } + return node; + } + async createAudioWorkletProcessor(name = this.name, factory = this.factory, processorName = (factory == null ? void 0 : factory.shaKey) || name) { + if (!factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(factory.json); + const dependencies = { + FaustBaseWebAudioDsp, + FaustMonoWebAudioDsp, + FaustWasmInstantiator: FaustWasmInstantiator_default, + FaustPolyWebAudioDsp: void 0, + FaustWebAudioDspVoice: void 0 + }; + try { + const faustData = { + processorName, + dspName: name, + dspMeta: meta, + poly: false + }; + const Processor = FaustAudioWorkletProcessor_default(dependencies, faustData); + return Processor; + } catch (e) { + throw e; + } + } + async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory, context) { + if (!factory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(factory.json); + const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory); + const sampleSize = meta.compile_options.match("-double") ? 8 : 4; + if (context) + factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context); + const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles); + return new FaustMonoOfflineProcessor(monoDsp, bufferSize); + } + getMeta() { + return JSON.parse(this.factory.json); + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.getMeta().ui; + } +}; +// Set of all created WorkletProcessors, each of them has to be unique +_FaustMonoDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map(); +var FaustMonoDspGenerator = _FaustMonoDspGenerator; +var _FaustPolyDspGenerator = class _FaustPolyDspGenerator { + constructor() { + this.voiceFactory = null; + this.effectFactory = null; + } + async compile(compiler, name, dspCodeAux, args, effectCodeAux = `dsp_code = environment{ + ${dspCodeAux} + }; + process = dsp_code.effect;`) { + try { + this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args); + if (this.effectFactory) { + const effectJSON = JSON.parse(this.effectFactory.json); + const dspCode = `// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs, +// so that the effect can process the 2 channels of the voice +adaptOut(1,1,1) = _; +adaptOut(1,1,2) = _ <: _,0; // The left channel only is kept +adaptOut(1,2,1) = _ <: _,_; +adaptOut(1,2,2) = _ <: _,_; +adaptOut(2,1,1) = _,_; +adaptOut(2,1,2) = _,_; +adaptOut(2,2,1) = _,_; +adaptOut(2,2,2) = _,_; +adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs}); +dsp_code = environment{ + ${dspCodeAux} +}; +process = dsp_code.process : adaptor(dsp_code.process); +`; + const effectCode = `// Inputs +adaptIn(1,1,1) = _; +adaptIn(1,1,2) = _,_ :> _; +adaptIn(1,2,1) = _,_; +adaptIn(1,2,2) = _,_; +adaptIn(2,1,1) = _,_ :> _; +adaptIn(2,1,2) = _,_ :> _; +adaptIn(2,2,1) = _,_; +adaptIn(2,2,2) = _,_; +// Outputs +adaptOut(1,1) = _ <: _,0; // The left channel only is kept +adaptOut(1,2) = _,_; +adaptOut(2,1) = _ <: _,0; // The left channel only is kept +adaptOut(2,2) = _,_; +adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs}); +adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs}); +dsp_code = environment{ + ${dspCodeAux} +}; +process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts; +`; + this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args); + try { + this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl"); + } catch (e) { + console.warn(e); + } + } + } catch (e) { + console.warn(e); + this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args); + } + if (this.voiceFactory) { + this.name = name; + const voiceMeta = JSON.parse(this.voiceFactory.json); + const isDouble = voiceMeta.compile_options.match("-double"); + const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble); + this.mixerBuffer = mixerBuffer; + this.mixerModule = mixerModule; + return this; + } else { + return null; + } + } + addSoundfiles(soundfileMap) { + if (!this.voiceFactory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + for (const id in soundfileMap) { + this.voiceFactory.soundfiles[id] = soundfileMap[id]; + } + } + getSoundfileList() { + if (!this.voiceFactory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const meta = JSON.parse(this.voiceFactory.json); + const map = SoundfileReader_default.findSoundfilesFromMeta(meta); + if (!this.effectFactory) + return Object.keys(map); + const effectMeta = JSON.parse(this.effectFactory.json); + const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta); + return Object.keys({ ...effectMap, ...map }); + } + async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`, processorOptions = {}) { + var _a, _b; + if (!voiceFactory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const voiceMeta = JSON.parse(voiceFactory.json); + const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0; + const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4; + voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context); + if (effectFactory) + effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context); + if (sp) { + const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0); + const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles }; + const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles); + const sp2 = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()); + Object.setPrototypeOf(sp2, FaustPolyScriptProcessorNode.prototype); + sp2.init(polyDsp); + return sp2; + } else { + if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context)) + _FaustPolyDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set()); + if (!((_a = _FaustPolyDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) { + try { + const processorCode = ` +// DSP name and JSON string for DSP are generated +const faustData = ${JSON.stringify({ + processorName, + dspName: name, + dspMeta: voiceMeta, + poly: true, + effectMeta + })}; +// Implementation needed classes of functions +var ${FaustDspInstance.name} = ${FaustDspInstance.toString()} +var FaustDspInstance = ${FaustDspInstance.name}; +var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()} +var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name}; +var ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()} +var FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name}; +var ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()} +var FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name}; +var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()} +var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name}; +var ${Soundfile.name} = ${Soundfile.toString()} +var Soundfile = ${Soundfile.name}; +var ${WasmAllocator.name} = ${WasmAllocator.toString()} +var WasmAllocator = ${WasmAllocator.name}; +var ${FaustSensors.name} = ${FaustSensors.toString()} +var FaustSensors = ${FaustSensors.name}; +// Put them in dependencies +const dependencies = { + FaustBaseWebAudioDsp, + FaustPolyWebAudioDsp, + FaustWasmInstantiator +}; +// Generate the actual AudioWorkletProcessor code +(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData); +`; + const url = URL.createObjectURL(new Blob([processorCode], { type: "text/javascript" })); + await context.audioWorklet.addModule(url); + (_b = _FaustPolyDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName); + } catch (e) { + throw e; + } + } + const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || void 0, ...processorOptions } }); + return node; + } + } + async createAudioWorkletProcessor(name = this.name, voiceFactory = this.voiceFactory, effectFactory = this.effectFactory, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`) { + if (!voiceFactory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const voiceMeta = JSON.parse(voiceFactory.json); + const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0; + const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4; + try { + const dependencies = { + FaustBaseWebAudioDsp, + FaustMonoWebAudioDsp: void 0, + FaustWasmInstantiator: FaustWasmInstantiator_default, + FaustPolyWebAudioDsp, + FaustWebAudioDspVoice + }; + const faustData = { + processorName, + dspName: name, + dspMeta: voiceMeta, + poly: true, + effectMeta + }; + const Processor = FaustAudioWorkletProcessor_default(dependencies, faustData); + return Processor; + } catch (e) { + throw e; + } + } + async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, context) { + if (!voiceFactory) + throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first."); + const voiceMeta = JSON.parse(voiceFactory.json); + const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0; + const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0); + const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4; + if (context) { + voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context); + if (effectFactory) + effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context); + } + const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles }; + const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles); + return new FaustPolyOfflineProcessor(polyDsp, bufferSize); + } + getMeta() { + const o = this.voiceFactory ? JSON.parse(this.voiceFactory.json) : null; + const e = this.effectFactory ? JSON.parse(this.effectFactory.json) : null; + const r = { ...o }; + if (e) { + r.ui = [{ + type: "tgroup", + label: "Sequencer", + items: [ + { type: "vgroup", label: "Instrument", items: o.ui }, + { type: "vgroup", label: "Effect", items: e.ui } + ] + }]; + } else { + r.ui = [{ + type: "tgroup", + label: "Polyphonic", + items: [ + { type: "vgroup", label: "Voices", items: o.ui } + ] + }]; + } + return r; + } + getJSON() { + return JSON.stringify(this.getMeta()); + } + getUI() { + return this.getMeta().ui; + } +}; +// Set of all created WorkletProcessors, each of them has to be unique +_FaustPolyDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map(); +var FaustPolyDspGenerator = _FaustPolyDspGenerator; +export { + FaustAudioWorkletNode, + FaustBaseWebAudioDsp, + FaustCmajor_default as FaustCmajor, + FaustCompiler_default as FaustCompiler, + FaustDspInstance, + FaustMonoAudioWorkletNode, + FaustMonoDspGenerator, + FaustMonoOfflineProcessor, + FaustMonoScriptProcessorNode, + FaustMonoWebAudioDsp, + FaustOfflineProcessor_default as FaustOfflineProcessor, + FaustPolyAudioWorkletNode, + FaustPolyDspGenerator, + FaustPolyOfflineProcessor, + FaustPolyScriptProcessorNode, + FaustPolyWebAudioDsp, + FaustScriptProcessorNode, + FaustSvgDiagrams_default as FaustSvgDiagrams, + FaustWasmInstantiator_default as FaustWasmInstantiator, + FaustWebAudioDspVoice, + LibFaust_default as LibFaust, + Soundfile, + SoundfileReader_default as SoundfileReader, + WasmAllocator, + WavDecoder_default as WavDecoder, + WavEncoder_default as WavEncoder, + ab2str, + FaustAudioWorkletProcessor_default as getFaustAudioWorkletProcessor, + FaustFFTAudioWorkletProcessor_default as getFaustFFTAudioWorkletProcessor, + instantiateFaustModuleFromFile_default as instantiateFaustModuleFromFile, + str2ab +}; +//# sourceMappingURL=index.js.map diff --git a/docs/gamelan/sinusoide2/faustwasm/index.js.map b/docs/gamelan/sinusoide2/faustwasm/index.js.map new file mode 100644 index 0000000..599e3fa --- /dev/null +++ b/docs/gamelan/sinusoide2/faustwasm/index.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../../src/instantiateFaustModuleFromFile.ts", "../../src/FaustAudioWorkletProcessor.ts", "../../src/FaustFFTAudioWorkletProcessor.ts", "../../node_modules/tslib/tslib.es6.mjs", "../../node_modules/@aws-crypto/sha256-js/src/constants.ts", "../../node_modules/@aws-crypto/sha256-js/src/RawSha256.ts", "../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js", "../../node_modules/@aws-crypto/util/src/convertToBuffer.ts", "../../node_modules/@aws-crypto/util/src/isEmptyData.ts", "../../node_modules/@aws-crypto/sha256-js/src/jsSha256.ts", "../../src/FaustCompiler.ts", "../../src/FaustDspInstance.ts", "../../src/FaustWasmInstantiator.ts", "../../src/FaustSensors.ts", "../../src/FaustWebAudioDsp.ts", "../../src/FaustOfflineProcessor.ts", "../../src/FaustSvgDiagrams.ts", "../../src/FaustCmajor.ts", "../../src/LibFaust.ts", "../../src/WavEncoder.ts", "../../src/WavDecoder.ts", "../../src/SoundfileReader.ts", "../../src/FaustAudioWorkletNode.ts", "../../src/FaustScriptProcessorNode.ts", "../../src/FaustDspGenerator.ts"], + "sourcesContent": ["import type { FaustModuleFactory } from \"./types\";\n\n/**\n * Load libfaust-wasm files, than instantiate libFaust\n * @param jsFile path to `libfaust-wasm.js`\n * @param dataFile path to `libfaust-wasm.data`\n * @param wasmFile path to `libfaust-wasm.wasm`\n */\nconst instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, \"data\"), wasmFile = jsFile.replace(/c?js$/, \"wasm\")) => {\n let FaustModule: FaustModuleFactory;\n let dataBinary: ArrayBuffer;\n let wasmBinary: Uint8Array | ArrayBuffer;\n const jsCodeHead = /var (.+) = \\(/;\n if (typeof window === \"object\") {\n let jsCode = await (await fetch(jsFile)).text();\n jsCode = `${jsCode}\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: \"text/javascript\" }));\n FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;\n dataBinary = await (await fetch(dataFile)).arrayBuffer();\n wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());\n } else {\n const { promises: fs } = await import(\"fs\");\n const { pathToFileURL } = await import(\"url\");\n let jsCode = (await fs.readFile(jsFile, { encoding: \"utf-8\" }));\n jsCode = `\nimport process from \"process\";\nimport * as path from \"path\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst __filename = fileURLToPath(import.meta.url);\nconst require = createRequire(import.meta.url);\n\n${jsCode}\n\nexport default ${jsCode.match(jsCodeHead)?.[1]};\n`;\n const jsFileMod = jsFile.replace(/c?js$/, \"mjs\");\n await fs.writeFile(jsFileMod, jsCode);\n FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;\n await fs.unlink(jsFileMod);\n dataBinary = (await fs.readFile(dataFile)).buffer;\n wasmBinary = (await fs.readFile(wasmFile)).buffer;\n }\n const faustModule = await FaustModule({\n wasmBinary,\n getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {\n if (remotePackageName === \"libfaust-wasm.data\") return dataBinary;\n return new ArrayBuffer(0);\n }});\n return faustModule;\n};\n\nexport default instantiateFaustModuleFromFile;\n", "import type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport type { FaustBaseWebAudioDsp, FaustWebAudioDspVoice, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem } from \"./types\";\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\n\n/**\n * Injected in the string to be compiled on AudioWorkletProcessor side\n */\nexport interface FaustData {\n processorName: string;\n dspName: string;\n dspMeta: FaustDspMeta;\n poly: boolean;\n effectMeta?: FaustDspMeta;\n};\nexport interface FaustAudioWorkletProcessorDependencies {\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\n FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;\n FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;\n FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\n}\nexport interface FaustAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustMonoAudioWorkletProcessorOptions;\n}\nexport interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\n processorOptions: FaustPolyAudioWorkletProcessorOptions;\n}\nexport interface FaustAudioWorkletProcessorOptions {\n name: string;\n sampleSize: number;\n // for WAMs\n moduleId?: string;\n instanceId?: string;\n}\nexport interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n factory: LooseFaustDspFactory;\n}\nexport interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {\n voiceFactory: LooseFaustDspFactory;\n mixerModule: WebAssembly.Module;\n voices: number;\n effectFactory?: LooseFaustDspFactory;\n}\n\n// Dynamic AudioWorkletProcessor code generator\nconst getFaustAudioWorkletProcessor = (dependencies: FaustAudioWorkletProcessorDependencies, faustData: FaustData, register = true): typeof AudioWorkletProcessor => {\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\n\n const {\n FaustBaseWebAudioDsp,\n FaustWasmInstantiator\n } = dependencies;\n\n const {\n processorName,\n dspName,\n dspMeta,\n effectMeta,\n poly\n } = faustData;\n\n // Analyse voice JSON to generate AudioParam parameters\n const analysePolyParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (poly && isPolyReserved) return null;\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n return null;\n }\n\n /**\n * Base class for Monophonic and Polyphonic AudioWorkletProcessor\n */\n class FaustAudioWorkletProcessor extends AudioWorkletProcessor {\n\n // Use ! syntax when the field is not defined in the constructor\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected paramValuesCache: Record = {};\n\n protected wamInfo?: { moduleId: string; instanceId: string };\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\n parameterDescriptors.forEach((pd) => {\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\n })\n \n const { moduleId, instanceId } = options.processorOptions;\n if (!moduleId || !instanceId) return;\n this.wamInfo = { moduleId, instanceId };\n }\n\n static get parameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n const param = analysePolyParameters(item);\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\n // Analyse effect JSON to generate AudioParam parameters\n if (effectMeta) FaustBaseWebAudioDsp.parseUI(effectMeta.ui, callback);\n return params;\n }\n\n setupWamEventHandler() {\n if (!this.wamInfo) return;\n const { moduleId, instanceId } = this.wamInfo;\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\n if (!paramMgrProcessor) return;\n if (paramMgrProcessor.handleEvent) return;\n paramMgrProcessor.handleEvent = (event) => {\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\n };\n }\n\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\n\n // Update controls (possibly needed for sample accurate control)\n for (const path in parameters) {\n const [paramValue] = parameters[path];\n if (paramValue !== this.paramValuesCache[path]) {\n this.fDSPCode.setParamValue(path, paramValue);\n this.paramValuesCache[path] = paramValue;\n }\n }\n\n return this.fDSPCode.compute(inputs[0], outputs[0]);\n }\n\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\n const msg = e.data;\n\n switch (msg.type) {\n // Sensors messages\n case \"acc\": {\n this.propagateAcc(msg.data, msg.invert);\n break;\n }\n case \"gyr\": {\n this.propagateGyr(msg.data);\n break;\n }\n // Generic MIDI message\n case \"midi\": {\n this.midiMessage(msg.data);\n break;\n }\n // Typed MIDI message\n case \"ctrlChange\": {\n this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);\n break;\n }\n case \"pitchWheel\": {\n this.pitchWheel(msg.data[0], msg.data[1]);\n break;\n }\n // Generic data message\n case \"param\": {\n this.setParamValue(msg.data.path, msg.data.value);\n break;\n }\n // Plot handler set on demand\n case \"setPlotHandler\": {\n if (msg.data) {\n this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: \"plot\", value: output, index, events }));\n } else {\n this.fDSPCode.setPlotHandler(null);\n }\n break;\n }\n case \"setupWamEventHandler\": {\n this.setupWamEventHandler();\n break;\n }\n case \"start\": {\n this.fDSPCode.start();\n break;\n }\n case \"stop\": {\n this.fDSPCode.stop();\n break;\n }\n case \"destroy\": {\n this.port.close();\n this.fDSPCode.destroy();\n break;\n }\n default:\n break;\n }\n }\n\n protected setParamValue(path: string, value: number) {\n this.fDSPCode.setParamValue(path, value);\n this.paramValuesCache[path] = value;\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n this.fDSPCode.midiMessage(data);\n }\n\n protected ctrlChange(channel: number, ctrl: number, value: number) {\n this.fDSPCode.ctrlChange(channel, ctrl, value);\n }\n\n protected pitchWheel(channel: number, wheel: number) {\n this.fDSPCode.pitchWheel(channel, wheel);\n }\n\n protected propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n protected propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n }\n\n /**\n * Monophonic AudioWorkletProcessor\n */\n class FaustMonoAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustAudioWorkletNodeOptions) {\n super(options);\n const { FaustMonoWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n const { factory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\n\n // Create Monophonic DSP\n this.fDSPCode = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, 128, factory.soundfiles);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n }\n\n /**\n * Polyphonic AudioWorkletProcessor\n */\n class FaustPolyAudioWorkletProcessor extends FaustAudioWorkletProcessor {\n\n constructor(options: FaustPolyAudioWorkletNodeOptions) {\n super(options);\n const { FaustPolyWebAudioDsp } = dependencies as FaustAudioWorkletProcessorDependencies;\n\n const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;\n\n const instance = FaustWasmInstantiator.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);\n\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n // Create Polyphonic DSP\n this.fDSPCode = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, 128, soundfiles);\n\n // Setup port message handling\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\n\n // Setup output handler\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\n\n this.fDSPCode.start();\n }\n\n protected midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) this.keyOff(channel, data1, data2);\n else if (cmd === 9) this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n }\n\n protected handleMessageAux = (e: MessageEvent) => { // use arrow function for binding\n const msg = e.data;\n switch (msg.type) {\n case \"keyOn\": this.keyOn(msg.data[0], msg.data[1], msg.data[2]); break;\n case \"keyOff\": this.keyOff(msg.data[0], msg.data[1], msg.data[2]); break;\n default:\n super.handleMessageAux(e);\n break;\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOn(channel, pitch, velocity);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n this.fDSPCode.keyOff(channel, pitch, velocity);\n }\n\n allNotesOff(hard: boolean) {\n this.fDSPCode.allNotesOff(hard);\n }\n }\n\n const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n if (register) {\n try {\n registerProcessor(processorName || dspName || (poly ? \"mydsp_poly\" : \"mydsp\"), Processor);\n } catch (error) {\n console.warn(error);\n }\n }\n\n return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;\n}\n\nexport default getFaustAudioWorkletProcessor;\n", "import type { FaustMonoDspInstance } from \"./FaustDspInstance\";\r\nimport type FaustWasmInstantiator from \"./FaustWasmInstantiator\";\r\nimport type { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, PlotHandler } from \"./FaustWebAudioDsp\";\r\nimport type { AudioParamDescriptor, AudioWorkletGlobalScope, LooseFaustDspFactory, FaustDspMeta, FaustUIItem, InterfaceFFT, TWindowFunction, Writeable, TypedArray, FFTUtils } from \"./types\";\r\nimport type { AudioWorkletGlobalScope as WamAudioWorkletGlobalScope, WamParamMgrSDKBaseModuleScope } from \"@webaudiomodules/sdk-parammgr\";\r\n\r\nexport interface FaustFFTOptionsData {\r\n fftSize: number;\r\n fftOverlap: number;\r\n noIFFT: boolean;\r\n /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */\r\n defaultWindowFunction: number;\r\n}\r\n\r\n/**\r\n * Injected in the string to be compiled on AudioWorkletProcessor side\r\n */\r\nexport interface FaustFFTData {\r\n processorName: string;\r\n dspName: string;\r\n dspMeta: FaustDspMeta;\r\n fftOptions?: Partial;\r\n};\r\nexport interface FaustFFTAudioWorkletProcessorDependencies {\r\n FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;\r\n FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;\r\n FaustWasmInstantiator: typeof FaustWasmInstantiator;\r\n FFTUtils: typeof FFTUtils;\r\n}\r\nexport interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {\r\n processorOptions: FaustFFTAudioWorkletProcessorOptions;\r\n}\r\nexport interface FaustFFTAudioWorkletProcessorOptions {\r\n name: string;\r\n sampleSize: number;\r\n factory: LooseFaustDspFactory;\r\n // for WAMs\r\n moduleId?: string;\r\n instanceId?: string;\r\n}\r\n\r\n\r\n// Dynamic AudioWorkletProcessor code generator\r\nconst getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register = true): typeof AudioWorkletProcessor => {\r\n const { registerProcessor, AudioWorkletProcessor, sampleRate } = globalThis as unknown as AudioWorkletGlobalScope;\r\n\r\n const {\r\n FaustBaseWebAudioDsp,\r\n FaustWasmInstantiator,\r\n FaustMonoWebAudioDsp,\r\n FFTUtils\r\n } = dependencies;\r\n \r\n const {\r\n processorName,\r\n dspName,\r\n dspMeta,\r\n fftOptions\r\n } = faustData;\r\n\r\n const {\r\n windowFunctions,\r\n getFFT,\r\n fftToSignal,\r\n signalToFFT,\r\n signalToNoFFT\r\n } = FFTUtils;\r\n\r\n /**\r\n * Ceil a number to multiple of another\r\n */\r\n const ceil = (x: number, to: number): number => (Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to);\r\n\r\n /**\r\n * Mod support wrapping with negative numbers\r\n */\r\n const mod = (x: number, y: number): number => (x % y + y) % y;\r\n\r\n const apply = (array: Writeable>, windowFunction: TWindowFunction) => {\r\n for (let i = 0; i < array.length; i++) {\r\n array[i] *= windowFunction(i, array.length);\r\n }\r\n };\r\n\r\n const fftParamKeywords = [\"/fftSize\", \"/fftHopSize\", \"/fftOverlap\", \"/windowFunction\", \"/noIFFT\"];\r\n\r\n /**\r\n * Copy buffer to another, support negative offset index\r\n */\r\n const setTypedArray = (to: T, from: T, offsetTo = 0, offsetFrom = 0) => {\r\n const toLength = to.length;\r\n const fromLength = from.length;\r\n const spillLength = Math.min(toLength, fromLength);\r\n let spilled = 0;\r\n let $to = mod(offsetTo, toLength) || 0;\r\n let $from = mod(offsetFrom, fromLength) || 0;\r\n while (spilled < spillLength) {\r\n const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);\r\n const $fromEnd = $from + $spillLength;\r\n if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);\r\n else to.set(from.subarray($from, $fromEnd), $to);\r\n $to = ($to + $spillLength) % toLength;\r\n $from = $fromEnd % fromLength;\r\n spilled += $spillLength;\r\n }\r\n return $to;\r\n };\r\n\r\n // Analyse JSON to generate AudioParam parameters\r\n const analyseParameters = (item: FaustUIItem): AudioParamDescriptor | null => {\r\n const isFFTReserved = \"address\" in item && !!fftParamKeywords.find(k => item.address.endsWith(k));\r\n if (isFFTReserved) return null;\r\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\r\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\r\n return { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\r\n }\r\n return null;\r\n }\r\n /**\r\n * Class for Faust FFT AudioWorkletProcessor\r\n */\r\n class FaustFFTAudioWorkletProcessor extends AudioWorkletProcessor {\r\n\r\n protected fDSPCode: FaustMonoWebAudioDsp;\r\n\r\n protected paramValuesCache: Record = {};\r\n\r\n protected wamInfo?: { moduleId: string; instanceId: string };\r\n\r\n private dspInstance!: FaustMonoDspInstance;\r\n private sampleSize!: number;\r\n\r\n private destroyed = false;\r\n /** Pointer of next start sample to write of the FFT input window */\r\n private $inputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT input window */\r\n private $inputRead = 0;\r\n /** Pointer of next start sample to write of the FFT output window */\r\n private $outputWrite = 0;\r\n /** Pointer of next start sample to read of the FFT output window */\r\n private $outputRead = 0;\r\n /** Not perform in IFFT when reconstruct the audio signal */\r\n private noIFFT = false;\r\n /** audio data from input, array of channels */\r\n private readonly fftInput: Float32Array[] = [];\r\n /** audio data for output, array of channels */\r\n private readonly fftOutput: Float32Array[] = [];\r\n /** Generated from the current window function */\r\n private window: Float32Array;\r\n /** Generated from the current window's rolling sum square */\r\n private windowSumSquare: Float32Array;\r\n \r\n /** FFT constructor */\r\n private FFT: typeof InterfaceFFT;\r\n /** Real FFT interface */\r\n private rfft: InterfaceFFT;\r\n /** Faust param name of fftHopSize */\r\n private fftHopSizeParam: string | undefined;\r\n /** FFT Overlaps, 1 means no overlap */\r\n private fftOverlap = 0;\r\n private fftHopSize = 0;\r\n private fftSize = 0;\r\n private fftBufferSize = 0;\r\n private fftProcessorZeros: Float32Array;\r\n private noIFFTBuffer: Float32Array;\r\n\r\n private fPlotHandler: PlotHandler | null = null;\r\n private fCachedEvents: { type: string; data: any }[] = [];\r\n private fBufferNum = 0;\r\n private soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n get fftProcessorBufferSize() {\r\n return this.fftSize / 2 + 1;\r\n }\r\n private windowFunction: TWindowFunction | null = null;\r\n\r\n constructor(options: FaustFFTAudioWorkletNodeOptions) {\r\n super(options);\r\n\r\n // Setup port message handling\r\n this.port.onmessage = (e: MessageEvent) => this.handleMessageAux(e);\r\n \r\n const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);\r\n parameterDescriptors.forEach((pd) => {\r\n this.paramValuesCache[pd.name] = pd.defaultValue || 0;\r\n })\r\n\r\n const { factory, sampleSize } = options.processorOptions;\r\n\r\n this.dspInstance = FaustWasmInstantiator.createSyncMonoDSPInstance(factory);\r\n this.sampleSize = sampleSize;\r\n this.soundfiles = factory.soundfiles;\r\n\r\n // Init the FFT constructor and the Faust FFT Processor\r\n this.initFFT();\r\n\r\n const { moduleId, instanceId } = options.processorOptions;\r\n if (!moduleId || !instanceId) return;\r\n this.wamInfo = { moduleId, instanceId };\r\n }\r\n\r\n async initFFT(): Promise {\r\n // Use injected function to instantiate the FFT constructor\r\n this.FFT = await getFFT();\r\n // Init Faust FFT Processor\r\n await this.createFFTProcessor();\r\n return true;\r\n }\r\n\r\n static get parameterDescriptors() {\r\n const params = [] as AudioParamDescriptor[];\r\n // Analyse voice JSON to generate AudioParam parameters\r\n const callback = (item: FaustUIItem) => {\r\n const param = analyseParameters(item);\r\n if (param) params.push(param);\r\n }\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n // Add to Faust parameters, FFT specified parameters\r\n return [\r\n ...params,\r\n {\r\n defaultValue: fftOptions?.fftSize || 1024,\r\n maxValue: 2 ** 32,\r\n minValue: 2,\r\n name: \"fftSize\"\r\n }, {\r\n defaultValue: fftOptions?.fftOverlap || 2,\r\n maxValue: 32,\r\n minValue: 1,\r\n name: \"fftOverlap\"\r\n }, {\r\n defaultValue: typeof fftOptions?.defaultWindowFunction === \"number\" ? fftOptions.defaultWindowFunction + 1 : 0,\r\n maxValue: windowFunctions?.length || 0,\r\n minValue: 0,\r\n name: \"windowFunction\"\r\n }, {\r\n defaultValue: +!!fftOptions?.noIFFT || 0,\r\n maxValue: 1,\r\n minValue: 0,\r\n name: \"noIFFT\"\r\n }\r\n ];\r\n }\r\n\r\n setupWamEventHandler() {\r\n if (!this.wamInfo) return;\r\n const { moduleId, instanceId } = this.wamInfo;\r\n\t const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);\r\n const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;\r\n const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];\r\n if (!paramMgrProcessor) return;\r\n if (paramMgrProcessor.handleEvent) return;\r\n paramMgrProcessor.handleEvent = (event) => {\r\n if (event.type === \"wam-midi\") this.midiMessage(event.data.bytes);\r\n };\r\n }\r\n\r\n processFFT() {\r\n // Get the number of samples that need to proceed, from the input r/w pointers\r\n let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;\r\n // Start process, until no more enough samples\r\n while (samplesForFFT >= this.fftSize) {\r\n let fftProcessorOutputs: Float32Array[] = [];\r\n // Faust processing, use a callback to avoid extra data copy\r\n this.fDSPCode.compute((inputs) => {\r\n // for each audio input channel, three Faust FFT input buffers can be generated (real, imag, FFT bin index)\r\n for (let i = 0; i < Math.min(this.fftInput.length, Math.ceil(inputs.length / 3)); i++) {\r\n // FFT forward, use a callback to avoid extra data copy\r\n const ffted = this.rfft.forward((fftBuffer) => {\r\n setTypedArray(fftBuffer, this.fftInput[i], 0, this.$inputRead);\r\n // Windowing the input\r\n for (let j = 0; j < fftBuffer.length; j++) {\r\n fftBuffer[j] *= this.window[j];\r\n }\r\n // data for FFT (fftBuffer) is prepared\r\n });\r\n // write FFTed spectral data to three Faust FFT input buffers (real, imag, FFT bin index)\r\n fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);\r\n // Faust inputs are prepared\r\n }\r\n // If the Faust DSP has more inputs, fill them (zeros or real/imag, fill FFT bin indexes)\r\n for (let i = this.fftInput.length * 3; i < inputs.length; i++) {\r\n if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);\r\n else inputs[i].fill(0);\r\n }\r\n }, (outputs) => {\r\n // Get the Faust DSP outputs\r\n fftProcessorOutputs = outputs as Float32Array[];\r\n });\r\n\r\n // Advance FFT input read pointers\r\n this.$inputRead += this.fftHopSize;\r\n this.$inputRead %= this.fftBufferSize;\r\n\r\n samplesForFFT -= this.fftHopSize;\r\n\r\n // Do inverse FFT on the processed data by Faust DSP, and write the reconstructed signal to the output buffer\r\n for (let i = 0; i < this.fftOutput.length; i++) {\r\n let iffted: Float32Array;\r\n // If noIFFT option in enabled, then no need to do inverse IFFT, use the injected function to convert\r\n if (this.noIFFT) {\r\n iffted = this.noIFFTBuffer;\r\n signalToNoFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, iffted);\r\n } else {\r\n // FFT inverse, use a callback to avoid extra data copy\r\n iffted = this.rfft.inverse((ifftBuffer) => {\r\n // Convert the Faust DSP output (real/imag plans) to an array for inverse FFT\r\n signalToFFT(fftProcessorOutputs[i * 2] || this.fftProcessorZeros, fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros, ifftBuffer);\r\n // ifftBuffer is prepared\r\n });\r\n }\r\n // Windowing the output\r\n for (let j = 0; j < iffted.length; j++) {\r\n iffted[j] *= this.window[j];\r\n }\r\n // Overlap-add, preparing the windowSumSquare array for reverse the windowing effect when output the audio\r\n let $: number;\r\n // First part, add the part that is overlaped with the previous window\r\n for (let j = 0; j < iffted.length - this.fftHopSize; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] += iffted[j];\r\n if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n // Second part, write directly to the output buffer\r\n for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {\r\n $ = mod(this.$outputWrite + j, this.fftBufferSize);\r\n this.fftOutput[i][$] = iffted[j];\r\n if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;\r\n }\r\n }\r\n // Advance FFT output write pointers\r\n this.$outputWrite += this.fftHopSize;\r\n this.$outputWrite %= this.fftBufferSize;\r\n }\r\n }\r\n\r\n process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: { [key: string]: Float32Array }) {\r\n\r\n if (this.destroyed) return false;\r\n if (!this.FFT) return true;\r\n const input = inputs[0];\r\n const output = outputs[0];\r\n const inputChannels = input?.length || 0;\r\n const outputChannels = output?.length || 0;\r\n // if (input.length === 0) return true;\r\n \r\n const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;\r\n \r\n // Reset FFT and related buffers if necessary (checks in the resetFFT method)\r\n this.noIFFT = !!parameters.noIFFT[0];\r\n this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);\r\n \r\n if (!this.fDSPCode) return true;\r\n \r\n for (const path in parameters) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n const [paramValue] = parameters[path];\r\n if (paramValue !== this.paramValuesCache[path]) {\r\n this.fDSPCode.setParamValue(path, paramValue);\r\n this.paramValuesCache[path] = paramValue;\r\n }\r\n }\r\n\r\n // Write audio input into fftInput buffer, advance pointers\r\n if (input?.length) {\r\n let $inputWrite = 0;\r\n for (let i = 0; i < input.length; i++) {\r\n const inputWindow = this.fftInput[i];\r\n const channel = input[i].length ? input[i] : new Float32Array(bufferSize);\r\n $inputWrite = setTypedArray(inputWindow, channel, this.$inputWrite);\r\n }\r\n this.$inputWrite = $inputWrite;\r\n } else {\r\n this.$inputWrite += bufferSize;\r\n this.$inputWrite %= this.fftBufferSize;\r\n }\r\n \r\n // Do FFT if necessary\r\n this.processFFT();\r\n \r\n // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect\r\n for (let i = 0; i < output.length; i++) {\r\n setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);\r\n // let a = 0;\r\n let div = 0;\r\n for (let j = 0; j < bufferSize; j++) {\r\n div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];\r\n output[i][j] /= div < 1e-8 ? 1 : div;\r\n }\r\n }\r\n // Advance pointers\r\n this.$outputRead += bufferSize;\r\n this.$outputRead %= this.fftBufferSize;\r\n\r\n // plot\r\n if (this.fPlotHandler) {\r\n this.port.postMessage({ type: \"plot\", value: output, index: this.fBufferNum++, events: this.fCachedEvents });\r\n this.fCachedEvents = [];\r\n }\r\n return true;\r\n }\r\n\r\n protected handleMessageAux(e: MessageEvent) { // use arrow function for binding\r\n const msg = e.data;\r\n\r\n switch (msg.type) {\r\n // Generic MIDI message\r\n case \"midi\": this.midiMessage(msg.data); break;\r\n // Typed MIDI message\r\n case \"ctrlChange\": this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]); break;\r\n case \"pitchWheel\": this.pitchWheel(msg.data[0], msg.data[1]); break;\r\n // Generic data message\r\n case \"param\": this.setParamValue(msg.data.path, msg.data.value); break;\r\n // Plot handler set on demand\r\n case \"setPlotHandler\": {\r\n if (msg.data) {\r\n this.fPlotHandler = (output, index, events) => {\r\n if (events) this.fCachedEvents.push(...events);\r\n };\r\n } else {\r\n this.fPlotHandler = null;\r\n }\r\n this.fDSPCode?.setPlotHandler(this.fPlotHandler);\r\n break;\r\n }\r\n case \"setupWamEventHandler\": {\r\n this.setupWamEventHandler();\r\n break;\r\n }\r\n case \"start\": {\r\n this.fDSPCode?.start();\r\n break;\r\n }\r\n case \"stop\": {\r\n this.fDSPCode?.stop();\r\n break;\r\n }\r\n case \"destroy\": {\r\n this.port.close();\r\n this.destroy();\r\n break;\r\n }\r\n default:\r\n break;\r\n }\r\n }\r\n\r\n protected setParamValue(path: string, value: number) {\r\n this.fDSPCode?.setParamValue(path, value);\r\n this.paramValuesCache[path] = value;\r\n }\r\n\r\n protected midiMessage(data: number[] | Uint8Array) {\r\n this.fDSPCode?.midiMessage(data);\r\n }\r\n\r\n protected ctrlChange(channel: number, ctrl: number, value: number) {\r\n this.fDSPCode?.ctrlChange(channel, ctrl, value);\r\n }\r\n\r\n protected pitchWheel(channel: number, wheel: number) {\r\n this.fDSPCode?.pitchWheel(channel, wheel);\r\n }\r\n\r\n resetFFT(sizeIn: number, overlapIn: number, windowFunctionIn: number, inputChannels: number, outputChannels: number, bufferSize: number) {\r\n const fftSize = ~~ceil(Math.max(2, sizeIn || 1024), 2);\r\n const fftOverlap = ~~Math.min(fftSize, Math.max(1, overlapIn));\r\n const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);\r\n const latency = fftSize - Math.min(fftHopSize, bufferSize);\r\n let windowFunction: TWindowFunction | null = null;\r\n \r\n // set the window function from the injected list\r\n if (windowFunctionIn !== 0) {\r\n windowFunction = typeof windowFunctions === \"object\" ? windowFunctions[~~windowFunctionIn - 1] || null : null;\r\n }\r\n const fftSizeChanged = fftSize !== this.fftSize;\r\n\r\n const fftOverlapChanged = fftOverlap !== this.fftOverlap;\r\n // Reset FFT vars if the size is changed\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n this.fftSize = fftSize;\r\n this.fftOverlap = fftOverlap;\r\n this.fftHopSize = fftHopSize;\r\n this.$inputWrite = 0;\r\n this.$inputRead = 0;\r\n this.$outputWrite = 0;\r\n this.$outputRead = -latency;\r\n this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);\r\n if (!fftSizeChanged && this.fftHopSizeParam) this.fDSPCode?.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n }\r\n\r\n // Reset the FFT interface and the Faust Processor\r\n if (fftSizeChanged) {\r\n this.rfft?.dispose();\r\n this.rfft = new this.FFT(fftSize);\r\n this.noIFFTBuffer = new Float32Array(this.fftSize);\r\n this.createFFTProcessor();\r\n }\r\n \r\n // Calculate a window from the window function, prepare the windowSumSquare buffer \r\n if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {\r\n this.windowFunction = windowFunction;\r\n this.window = new Float32Array(fftSize);\r\n this.window.fill(1);\r\n if (windowFunction) apply(this.window, windowFunction);\r\n this.windowSumSquare = new Float32Array(this.fftBufferSize);\r\n }\r\n\r\n // Reset FFT I/O buffers if necessary\r\n if (this.fftInput.length > inputChannels) {\r\n this.fftInput.splice(inputChannels);\r\n }\r\n if (this.fftOutput.length > outputChannels) {\r\n this.fftOutput.splice(outputChannels);\r\n }\r\n if (fftSizeChanged || fftOverlapChanged) {\r\n for (let i = 0; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n for (let i = 0; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n } else {\r\n if (this.fftInput.length < inputChannels) {\r\n for (let i = this.fftInput.length; i < inputChannels; i++) {\r\n this.fftInput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n if (this.fftOutput.length < outputChannels) {\r\n for (let i = this.fftOutput.length; i < outputChannels; i++) {\r\n this.fftOutput[i] = new Float32Array(this.fftBufferSize);\r\n }\r\n }\r\n }\r\n }\r\n async createFFTProcessor() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n\r\n // Create Monophonic DSP\r\n this.fDSPCode = new FaustMonoWebAudioDsp(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);\r\n\r\n // Setup output handler\r\n this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: \"param\" }));\r\n this.fDSPCode.setPlotHandler(this.fPlotHandler);\r\n const params = this.fDSPCode.getParams();\r\n this.fDSPCode.start();\r\n // Write the cached parameters\r\n for (const path in this.paramValuesCache) {\r\n if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;\r\n this.fDSPCode.setParamValue(path, this.paramValuesCache[path])\r\n }\r\n // Write the FFT reverved parameters\r\n const fftSizeParam = params.find(s => s.endsWith(\"/fftSize\"));\r\n if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);\r\n this.fftHopSizeParam = params.find(s => s.endsWith(\"/fftHopSize\"));\r\n if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);\r\n // Prepare a array of zeros for furthur usage\r\n this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);\r\n }\r\n destroy() {\r\n this.fDSPCode?.stop();\r\n this.fDSPCode?.destroy();\r\n this.rfft?.dispose();\r\n this.destroyed = true;\r\n }\r\n\r\n }\r\n\r\n const Processor = FaustFFTAudioWorkletProcessor;\r\n if (register) {\r\n try {\r\n registerProcessor(processorName || dspName || \"myfftdsp\", Processor);\r\n } catch (error) {\r\n console.warn(error);\r\n }\r\n }\r\n\r\n return FaustFFTAudioWorkletProcessor;\r\n\r\n};\r\n\r\nexport default getFaustFFTAudioWorkletProcessor;\r\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n", "/**\n * @internal\n */\nexport const BLOCK_SIZE: number = 64;\n\n/**\n * @internal\n */\nexport const DIGEST_LENGTH: number = 32;\n\n/**\n * @internal\n */\nexport const KEY = new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n\n/**\n * @internal\n */\nexport const INIT = [\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n];\n\n/**\n * @internal\n */\nexport const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;\n", "import {\n BLOCK_SIZE,\n DIGEST_LENGTH,\n INIT,\n KEY,\n MAX_HASHABLE_LENGTH\n} from \"./constants\";\n\n/**\n * @internal\n */\nexport class RawSha256 {\n private state: Int32Array = Int32Array.from(INIT);\n private temp: Int32Array = new Int32Array(64);\n private buffer: Uint8Array = new Uint8Array(64);\n private bufferLength: number = 0;\n private bytesHashed: number = 0;\n\n /**\n * @internal\n */\n finished: boolean = false;\n\n update(data: Uint8Array): void {\n if (this.finished) {\n throw new Error(\"Attempted to update an already finished hash.\");\n }\n\n let position = 0;\n let { byteLength } = data;\n this.bytesHashed += byteLength;\n\n if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {\n throw new Error(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n while (byteLength > 0) {\n this.buffer[this.bufferLength++] = data[position++];\n byteLength--;\n\n if (this.bufferLength === BLOCK_SIZE) {\n this.hashBuffer();\n this.bufferLength = 0;\n }\n }\n }\n\n digest(): Uint8Array {\n if (!this.finished) {\n const bitsHashed = this.bytesHashed * 8;\n const bufferView = new DataView(\n this.buffer.buffer,\n this.buffer.byteOffset,\n this.buffer.byteLength\n );\n\n const undecoratedLength = this.bufferLength;\n bufferView.setUint8(this.bufferLength++, 0x80);\n\n // Ensure the final block has enough room for the hashed length\n if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {\n for (let i = this.bufferLength; i < BLOCK_SIZE; i++) {\n bufferView.setUint8(i, 0);\n }\n this.hashBuffer();\n this.bufferLength = 0;\n }\n\n for (let i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {\n bufferView.setUint8(i, 0);\n }\n bufferView.setUint32(\n BLOCK_SIZE - 8,\n Math.floor(bitsHashed / 0x100000000),\n true\n );\n bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);\n\n this.hashBuffer();\n\n this.finished = true;\n }\n\n // The value in state is little-endian rather than big-endian, so flip\n // each word into a new Uint8Array\n const out = new Uint8Array(DIGEST_LENGTH);\n for (let i = 0; i < 8; i++) {\n out[i * 4] = (this.state[i] >>> 24) & 0xff;\n out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;\n out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;\n out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;\n }\n\n return out;\n }\n\n private hashBuffer(): void {\n const { buffer, state } = this;\n\n let state0 = state[0],\n state1 = state[1],\n state2 = state[2],\n state3 = state[3],\n state4 = state[4],\n state5 = state[5],\n state6 = state[6],\n state7 = state[7];\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n if (i < 16) {\n this.temp[i] =\n ((buffer[i * 4] & 0xff) << 24) |\n ((buffer[i * 4 + 1] & 0xff) << 16) |\n ((buffer[i * 4 + 2] & 0xff) << 8) |\n (buffer[i * 4 + 3] & 0xff);\n } else {\n let u = this.temp[i - 2];\n const t1 =\n ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);\n\n u = this.temp[i - 15];\n const t2 =\n ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);\n\n this.temp[i] =\n ((t1 + this.temp[i - 7]) | 0) + ((t2 + this.temp[i - 16]) | 0);\n }\n\n const t1 =\n ((((((state4 >>> 6) | (state4 << 26)) ^\n ((state4 >>> 11) | (state4 << 21)) ^\n ((state4 >>> 25) | (state4 << 7))) +\n ((state4 & state5) ^ (~state4 & state6))) |\n 0) +\n ((state7 + ((KEY[i] + this.temp[i]) | 0)) | 0)) |\n 0;\n\n const t2 =\n ((((state0 >>> 2) | (state0 << 30)) ^\n ((state0 >>> 13) | (state0 << 19)) ^\n ((state0 >>> 22) | (state0 << 10))) +\n ((state0 & state1) ^ (state0 & state2) ^ (state1 & state2))) |\n 0;\n\n state7 = state6;\n state6 = state5;\n state5 = state4;\n state4 = (state3 + t1) | 0;\n state3 = state2;\n state2 = state1;\n state1 = state0;\n state0 = (t1 + t2) | 0;\n }\n\n state[0] += state0;\n state[1] += state1;\n state[2] += state2;\n state[3] += state3;\n state[4] += state4;\n state[5] += state5;\n state[6] += state6;\n state[7] += state7;\n }\n}\n", "export const fromUtf8 = (input) => new TextEncoder().encode(input);\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\nimport { fromUtf8 as fromUtf8Browser } from \"@smithy/util-utf8\";\n\n// Quick polyfill\nconst fromUtf8 =\n typeof Buffer !== \"undefined\" && Buffer.from\n ? (input: string) => Buffer.from(input, \"utf8\")\n : fromUtf8Browser;\n\nexport function convertToBuffer(data: SourceData): Uint8Array {\n // Already a Uint8, do nothing\n if (data instanceof Uint8Array) return data;\n\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(\n data.buffer,\n data.byteOffset,\n data.byteLength / Uint8Array.BYTES_PER_ELEMENT\n );\n }\n\n return new Uint8Array(data);\n}\n", "// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SourceData } from \"@aws-sdk/types\";\n\nexport function isEmptyData(data: SourceData): boolean {\n if (typeof data === \"string\") {\n return data.length === 0;\n }\n\n return data.byteLength === 0;\n}\n", "import { BLOCK_SIZE } from \"./constants\";\nimport { RawSha256 } from \"./RawSha256\";\nimport { Checksum, SourceData } from \"@aws-sdk/types\";\nimport { isEmptyData, convertToBuffer } from \"@aws-crypto/util\";\n\nexport class Sha256 implements Checksum {\n private readonly secret?: SourceData;\n private hash: RawSha256;\n private outer?: RawSha256;\n private error: any;\n\n constructor(secret?: SourceData) {\n this.secret = secret;\n this.hash = new RawSha256();\n this.reset();\n }\n\n update(toHash: SourceData): void {\n if (isEmptyData(toHash) || this.error) {\n return;\n }\n\n try {\n this.hash.update(convertToBuffer(toHash));\n } catch (e) {\n this.error = e;\n }\n }\n\n /* This synchronous method keeps compatibility\n * with the v2 aws-sdk.\n */\n digestSync(): Uint8Array {\n if (this.error) {\n throw this.error;\n }\n\n if (this.outer) {\n if (!this.outer.finished) {\n this.outer.update(this.hash.digest());\n }\n\n return this.outer.digest();\n }\n\n return this.hash.digest();\n }\n\n /* The underlying digest method here is synchronous.\n * To keep the same interface with the other hash functions\n * the default is to expose this as an async method.\n * However, it can sometimes be useful to have a sync method.\n */\n async digest(): Promise {\n return this.digestSync();\n }\n\n reset(): void {\n this.hash = new RawSha256();\n if (this.secret) {\n this.outer = new RawSha256();\n const inner = bufferFromSecret(this.secret);\n const outer = new Uint8Array(BLOCK_SIZE);\n outer.set(inner);\n\n for (let i = 0; i < BLOCK_SIZE; i++) {\n inner[i] ^= 0x36;\n outer[i] ^= 0x5c;\n }\n\n this.hash.update(inner);\n this.outer.update(outer);\n\n // overwrite the copied key in memory\n for (let i = 0; i < inner.byteLength; i++) {\n inner[i] = 0;\n }\n }\n }\n}\n\nfunction bufferFromSecret(secret: SourceData): Uint8Array {\n let input = convertToBuffer(secret);\n\n if (input.byteLength > BLOCK_SIZE) {\n const bufferHash = new RawSha256();\n bufferHash.update(input);\n input = bufferHash.digest();\n }\n\n const buffer = new Uint8Array(BLOCK_SIZE);\n buffer.set(input);\n return buffer;\n}\n", "import { Sha256 } from \"@aws-crypto/sha256-js\";\nimport type { ILibFaust } from \"./LibFaust\";\nimport type { FaustDspFactory, IntVector } from \"./types\";\n\nexport const ab2str = (buf: Uint8Array) => String.fromCharCode.apply(null, buf);\n\nexport const str2ab = (str: string) => {\n const buf = new ArrayBuffer(str.length);\n const bufView = new Uint8Array(buf);\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i);\n }\n return bufView;\n};\nconst sha256 = async (str: string) => {\n const sha256 = new Sha256();\n sha256.update(str);\n const hashArray = Array.from(await sha256.digest());\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return hashHex;\n};\n\nexport interface IFaustCompiler {\n /**\n * Gives the Faust compiler version.\n * @return a version string\n */\n version(): string;\n\n /**\n * Gives the last compilation error.\n * @return an error string\n */\n getErrorMessage(): string;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createMonoDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances. \n * This function is running asynchronously.\n *\n * @param name - an arbitrary name for the Faust factory\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the wasm factory\n */\n createPolyDSPFactory(name: string, code: string, args: string): Promise;\n\n /**\n * Delete a dsp factory.\n *\n * @param factory - the factory to be deleted\n */\n deleteDSPFactory(factory: FaustDspFactory): void;\n\n /**\n * Expand Faust code i.e. linearize included libraries.\n *\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns returns the expanded dsp code\n */\n expandDSP(code: string, args: string): string | null;\n\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - an arbitrary name for the Faust module\n * @param code - Faust dsp code\n * @param args - the compiler options\n * @returns whether the generation actually succeded\n */\n generateAuxFiles(name: string, code: string, args: string): boolean;\n\n /**\n * Delete all factories.\n */\n deleteAllDSPFactories(): void;\n\n fs(): typeof FS;\n\n getAsyncInternalMixerModule(isDouble?: boolean): Promise<{ mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module }>;\n getSyncInternalMixerModule(isDouble?: boolean): { mixerBuffer: Uint8Array; mixerModule: WebAssembly.Module };\n}\n\nclass FaustCompiler implements IFaustCompiler {\n private fLibFaust: ILibFaust;\n private fErrorMessage: string;\n private static gFactories: Map = new Map();\n private mixer32Buffer!: Uint8Array;\n private mixer64Buffer!: Uint8Array;\n private mixer32Module!: WebAssembly.Module;\n private mixer64Module!: WebAssembly.Module;\n\n /**\n * Get a stringified DSP factories table\n */\n static serializeDSPFactories() {\n const table: Record = {};\n this.gFactories.forEach((factory, shaKey) => {\n const { code, json, poly } = factory;\n table[shaKey] = { code: btoa(ab2str(code)), json: JSON.parse(json), poly };\n });\n return table;\n }\n /**\n * Get a stringified DSP factories table as string\n */\n static stringifyDSPFactories() {\n return JSON.stringify(this.serializeDSPFactories());\n }\n /**\n * Import a DSP factories table\n */\n static deserializeDSPFactories(table: Record) {\n const awaited: Promise>[] = [];\n for (const shaKey in table) {\n const factory = table[shaKey];\n const { code, json, poly } = factory;\n const ab = str2ab(atob(code))\n awaited.push(WebAssembly.compile(ab).then(module => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));\n }\n return Promise.all(awaited);\n }\n /**\n * Import a stringified DSP factories table\n */\n static importDSPFactories(tableStr: string) {\n const table: Record = JSON.parse(tableStr);\n return this.deserializeDSPFactories(table);\n }\n constructor(libFaust: ILibFaust) {\n this.fLibFaust = libFaust;\n this.fErrorMessage = \"\";\n }\n private intVec2intArray(vec: IntVector) {\n const size = vec.size();\n const ui8Code = new Uint8Array(size);\n for (let i = 0; i < size; i++) {\n ui8Code[i] = vec.get(i);\n }\n return ui8Code;\n }\n private async createDSPFactory(name: string, code: string, args: string, poly: boolean) {\n // Cleanup the cache\n if (FaustCompiler.gFactories.size > 10) {\n FaustCompiler.gFactories.clear();\n }\n\n // If code is already compiled, return the cached factory\n let shaKey = await sha256(name + code + args + (poly ? \"poly\" : \"mono\"));\n if (FaustCompiler.gFactories.has(shaKey)) {\n return FaustCompiler.gFactories.get(shaKey) || null;\n } else {\n try {\n // Can possibly raise a C++ exception catched by the second catch()\n const faustDspWasm = this.fLibFaust.createDSPFactory(name, code, args, !poly);\n const ui8Code = this.intVec2intArray(faustDspWasm.data);\n faustDspWasm.data.delete();\n const module = await WebAssembly.compile(ui8Code);\n const factory: FaustDspFactory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };\n // Factory C++ side can be deallocated immediately\n this.deleteDSPFactory(factory);\n // Keep the compiled factory in the cache\n FaustCompiler.gFactories.set(shaKey, factory);\n return factory;\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running createDSPFactory: ${this.fErrorMessage}`, e);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n }\n version() {\n return this.fLibFaust.version();\n }\n getErrorMessage() {\n return this.fErrorMessage;\n }\n async createMonoDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, false);\n }\n async createPolyDSPFactory(name: string, code: string, args: string) {\n return this.createDSPFactory(name, code, args, true);\n }\n deleteDSPFactory(factory: FaustDspFactory) {\n this.fLibFaust.deleteDSPFactory(factory.cfactory);\n factory.cfactory = 0;\n }\n expandDSP(code: string, args: string) {\n try {\n return this.fLibFaust.expandDSP(\"FaustDSP\", code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running expandDSP: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n generateAuxFiles(name: string, code: string, args: string) {\n try {\n return this.fLibFaust.generateAuxFiles(name, code, args);\n } catch (e) {\n this.fErrorMessage = this.fLibFaust.getErrorAfterException();\n // console.error(`=> exception raised while running generateAuxFiles: ${this.fErrorMessage}`);\n this.fLibFaust.cleanupAfterException();\n throw this.fErrorMessage ? new Error(this.fErrorMessage) : e;\n }\n }\n deleteAllDSPFactories(): void {\n this.fLibFaust.deleteAllDSPFactories();\n }\n fs() {\n return this.fLibFaust.fs();\n }\n async getAsyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = await WebAssembly.compile(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n getSyncInternalMixerModule(isDouble = false) {\n const bufferKey = isDouble ? \"mixer64Buffer\" : \"mixer32Buffer\";\n const moduleKey = isDouble ? \"mixer64Module\" : \"mixer32Module\";\n if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };\n const path = isDouble ? \"/usr/rsrc/mixer64.wasm\" : \"/usr/rsrc/mixer32.wasm\";\n const mixerBuffer = this.fs().readFile(path, { encoding: \"binary\" });\n this[bufferKey] = mixerBuffer;\n // Compile mixer\n const mixerModule = new WebAssembly.Module(mixerBuffer);\n this[moduleKey] = mixerModule;\n return { mixerBuffer, mixerModule };\n }\n}\n\nexport default FaustCompiler;\n", "/**\n * The Faust wasm instance interface.\n */\nexport interface IFaustDspInstance {\n /**\n * The dsp computation, to be called with successive input/output audio buffers.\n *\n * @param $dsp - the DSP pointer\n * @param count - the audio buffer size in frames\n * @param $inputs - the input audio buffer as in index in wasm memory\n * @param $output - the output audio buffer as in index in wasm memory\n */\n compute($dsp: number, count: number, $inputs: number, $output: number): void;\n\n /**\n * Give the number of inputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumInputs($dsp: number): number;\n\n /**\n * Give the number of outputs of a Faust wasm instance.\n * \n * @param $dsp - the DSP pointer\n */\n getNumOutputs($dsp: number): number;\n\n /**\n * Give a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @return the parameter value\n */\n getParamValue($dsp: number, index: number): number;\n\n /**\n * Give the Faust wasm instance sample rate.\n * \n * @param $dsp - the DSP pointer\n * @return the sample rate\n */\n getSampleRate($dsp: number): number;\n\n /**\n * Global init, calls the following methods:\n * - static class 'classInit': static tables initialization\n * - 'instanceInit': constants and instance state initialization\n *\n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n init($dsp: number, sampleRate: number): void;\n\n /** Init instance state (delay lines...).\n * \n * @param $dsp - the DSP pointer\n */\n instanceClear($dsp: number): void;\n\n /** Init instance constant state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceConstants($dsp: number, sampleRate: number): void;\n\n /** Init instance state.\n * \n * @param $dsp - the DSP pointer\n * @param sampleRate - the sampling rate in Hertz\n */\n instanceInit($dsp: number, sampleRate: number): void;\n\n /** Init default control parameters values.\n * \n * @param $dsp - the DSP pointer\n */\n instanceResetUserInterface($dsp: number): void;\n\n /**\n * Set a parameter current value.\n * \n * @param $dsp - the DSP pointer\n * @param index - the parameter index\n * @param value - the parameter value\n */\n setParamValue($dsp: number, index: number, value: number): void;\n}\n\n/**\n * Mixer used in polyphonic mode.\n */\nexport interface IFaustMixerInstance {\n clearOutput(bufferSize: number, chans: number, $outputs: number): void;\n mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;\n fadeOut(bufferSize: number, chans: number, $outputs: number): void;\n}\n\n/**\n * Monophonic instance.\n */\nexport interface FaustMonoDspInstance {\n memory: WebAssembly.Memory;\n api: IFaustDspInstance;\n json: string;\n}\n\n/**\n * Polyphonic instance.\n */\nexport interface FaustPolyDspInstance {\n memory: WebAssembly.Memory;\n voices: number;\n voiceAPI: IFaustDspInstance;\n effectAPI?: IFaustDspInstance;\n mixerAPI: IFaustMixerInstance;\n voiceJSON: string;\n effectJSON?: string;\n}\n\nexport class FaustDspInstance implements IFaustDspInstance {\n private readonly fExports: IFaustDspInstance;\n\n constructor(exports: IFaustDspInstance) { this.fExports = exports; }\n\n compute($dsp: number, count: number, $input: number, $output: number) { this.fExports.compute($dsp, count, $input, $output); }\n getNumInputs($dsp: number) { return this.fExports.getNumInputs($dsp); }\n getNumOutputs($dsp: number) { return this.fExports.getNumOutputs($dsp); }\n getParamValue($dsp: number, index: number) { return this.fExports.getParamValue($dsp, index); }\n getSampleRate($dsp: number) { return this.fExports.getSampleRate($dsp); }\n init($dsp: number, sampleRate: number) { this.fExports.init($dsp, sampleRate); }\n instanceClear($dsp: number) { this.fExports.instanceClear($dsp); }\n instanceConstants($dsp: number, sampleRate: number) { this.fExports.instanceConstants($dsp, sampleRate); }\n instanceInit($dsp: number, sampleRate: number) { this.fExports.instanceInit($dsp, sampleRate); }\n instanceResetUserInterface($dsp: number) { this.fExports.instanceResetUserInterface($dsp); }\n setParamValue($dsp: number, index: number, value: number) { this.fExports.setParamValue($dsp, index, value); }\n}\n", "import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from \"./FaustDspInstance\";\nimport type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from \"./types\";\n\nclass FaustWasmInstantiator {\n private static createWasmImport(memory?: WebAssembly.Memory) {\n return {\n env: {\n memory: memory || new WebAssembly.Memory({ initial: 100 }),\n memoryBase: 0,\n tableBase: 0,\n // Integer version\n _abs: Math.abs,\n // Float version\n _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,\n _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,\n _fmodf: (x: number, y: number) => x % y,\n _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,\n _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,\n _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,\n _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,\n _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,\n _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),\n _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n // Double version\n _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,\n _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,\n _fmod: (x: number, y: number) => x % y,\n _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,\n _remainder: (x: number, y: number) => x - Math.round(x / y) * y,\n _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,\n _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,\n _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,\n _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),\n _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),\n\n table: new WebAssembly.Table({ initial: 0, element: \"anyfunc\" })\n }\n };\n }\n private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {\n // Hack : at least 4 voices (to avoid weird wasm memory bug?)\n const voices = Math.max(4, voicesIn);\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const pow2limit = (x: number) => {\n let n = 65536; // Minimum = 64 kB\n while (n < x) { n *= 2; }\n return n;\n };\n const effectSize = effectMeta ? effectMeta.size : 0;\n let memorySize = pow2limit(\n effectSize\n + dspMeta.size * voices\n + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect\n * (ptrSize + bufferSize * sampleSize)\n ) / 65536;\n memorySize = Math.max(2, memorySize); // At least 2\n return new WebAssembly.Memory({ initial: memorySize });\n };\n\n private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {\n // Memory allocator\n const ptrSize = sampleSize; // Done on wast/wasm backend side\n const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;\n return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory\n }\n\n private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {\n const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;\n const api = new FaustDspInstance(functions);\n const memory: any = (mem) ? mem : instance.exports.memory;\n return { memory, api, json } as FaustMonoDspInstance;\n }\n\n private static createMemoryMono(monoFactory: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);\n const sampleSize = monoMeta.compile_options.match(\"-double\") ? 8 : 4;\n return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);\n\n }\n private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {\n // Parse JSON to get 'size' and 'inputs/outputs' infos\n const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);\n const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Memory will be shared by voice, mixer and (possibly) effect instances\n return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);\n }\n\n private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {\n // Create mixer instance\n const mixerImport = {\n imports: { print: console.log },\n memory: { memory }\n };\n const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);\n const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;\n return mixerFunctions;\n }\n\n // Public API\n static async loadDSPFactory(wasmPath: string, jsonPath: string) {\n const wasmFile = await fetch(wasmPath);\n if (!wasmFile.ok) {\n throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);\n }\n try {\n const wasmBuffer = await wasmFile.arrayBuffer();\n const module = await WebAssembly.compile(wasmBuffer);\n const jsonFile = await fetch(jsonPath);\n const json = await jsonFile.text();\n const meta: FaustDspMeta = JSON.parse(json);\n const cOptions = meta.compile_options;\n const poly = cOptions.indexOf('wasm-e') !== -1;\n return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;\n } catch (e) {\n // console.error(`=> exception raised while running loadDSPFactory: ${e}`);\n throw e;\n }\n }\n\n static async loadDSPMixer(mixerPath: string, fs?: typeof FS) {\n try {\n let mixerBuffer = null;\n if (fs) {\n mixerBuffer = fs.readFile(mixerPath, { encoding: \"binary\" });\n } else {\n const mixerFile = await fetch(mixerPath);\n mixerBuffer = await mixerFile.arrayBuffer();\n }\n // Compile mixer\n return WebAssembly.compile(mixerBuffer);\n } catch (e) {\n // console.error(`=> exception raised while running loadMixer: ${e}`);\n throw e;\n }\n }\n\n static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {\n\n // Regular expression to match the 'type: soundfile' pattern\n const pattern = /\"type\":\\s*\"soundfile\"/;\n // Check if the pattern exists in the JSON string\n const isDetected = pattern.test(factory.json);\n\n // If the JSON contains a soundfile UI element, we need to create a memory object\n if (isDetected) {\n const memory = this.createMemoryMono(factory);\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));\n return this.createMonoDSPInstanceAux(instance, factory.json, memory);\n } else {\n // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module\n const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());\n return this.createMonoDSPInstanceAux(instance, factory.json);\n }\n }\n\n static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n\n static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {\n const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);\n // Create voice \n const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));\n const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const voiceAPI = new FaustDspInstance(voiceFunctions);\n // Create mixer\n const mixerAPI = this.createMixerAux(mixerModule, memory);\n\n // Possibly create effect instance \n if (effectFactory) {\n const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));\n const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;\n const effectAPI = new FaustDspInstance(effectFunctions);\n return {\n memory,\n voices,\n voiceAPI,\n effectAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json,\n effectJSON: effectFactory.json\n } as FaustPolyDspInstance;\n } else {\n return {\n memory,\n voices,\n voiceAPI,\n mixerAPI,\n voiceJSON: voiceFactory.json\n } as FaustPolyDspInstance;\n }\n }\n}\n\nexport default FaustWasmInstantiator;\n", "\uFEFFexport interface AccParams {\n isEnabled: boolean;\n acc: string;\n address: string;\n min: number;\n max: number;\n init: number;\n label: string;\n}\n\n/** Enum describing the axis of the accelerometer or gyroscope */\nexport enum Axis { x, y, z }\n\n/** Enum describing the curve of the accelerometer */\nexport enum Curve { Up, Down, UpDown, DownUp }\n\n/** Object describing value off accelerometer metadata values */\nclass AccMeta {\n axis: Axis;\n curve: Curve;\n amin: number;\n amid: number;\n amax: number;\n}\n\ninterface Range {\n fLo: number;\n fHi: number;\n clip(x: number): number;\n}\n\ninterface InterpolateObject {\n amin: number;\n amax: number;\n}\ninterface Interpolator {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n returnMappedValue(v: number): number;\n getLowHigh(amin: number, amax: number): InterpolateObject;\n}\n\ninterface InterpolateObject3pt {\n amin: number;\n amid: number;\n amax: number;\n}\ninterface Interpolator3pt {\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n returnMappedValue(v: number): number;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n}\n\n/**\n * ValueConverter interface\n */\ninterface ValueConverter {\n uiToFaust(x: number): number;\n faustToUi(x: number): number;\n}\n\n/**\n * UpdatableValueConverter interface\n */\nexport interface UpdatableValueConverter extends ValueConverter {\n fActive: boolean;\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void;\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt;\n\n setActive(onOff: boolean): void;\n getActive(): boolean;\n}\n\nexport default class FaustSensors {\n /**\n * Function to convert a number to an axis type\n * \n * @param value number\n * @returns axis type\n */\n static convertToAxis(value: number): Axis {\n switch (value) {\n case 0:\n return Axis.x;\n case 1:\n return Axis.y;\n case 2:\n return Axis.z;\n default:\n console.error(\"Error: Axis not found value: \" + value);\n return Axis.x;\n }\n }\n /**\n * Function to convert a number to a curve type\n * \n * @param value number\n * @returns curve type\n */\n static convertToCurve(value: number): Curve {\n switch (value) {\n case 0:\n return Curve.Up;\n case 1:\n return Curve.Down;\n case 2:\n return Curve.UpDown;\n case 3:\n return Curve.DownUp;\n default:\n console.error(\"Error: Curve not found value: \" + value);\n return Curve.Up;\n }\n }\n\n // Converter objects use to map acc and Faust value\n static _Range: new (x: number, y: number) => Range;\n static get Range() {\n if (!this._Range) {\n this._Range = class {\n fLo: number;\n fHi: number;\n\n constructor(x: number, y: number) {\n this.fLo = Math.min(x, y);\n this.fHi = Math.max(x, y);\n }\n\n clip(x: number): number {\n if (x < this.fLo) return this.fLo;\n if (x > this.fHi) return this.fHi;\n return x;\n }\n };\n }\n return this._Range;\n }\n\n static _Interpolator: new (lo: number, hi: number, v1: number, v2: number) => Interpolator;\n /**\n * Interpolator class\n */\n static get Interpolator() {\n if (!this._Interpolator) {\n this._Interpolator = class {\n fRange: Range;\n fCoef: number;\n fOffset: number;\n\n constructor(lo: number, hi: number, v1: number, v2: number) {\n this.fRange = new FaustSensors.Range(lo, hi);\n if (hi !== lo) {\n // regular case\n this.fCoef = (v2 - v1) / (hi - lo);\n this.fOffset = v1 - lo * this.fCoef;\n } else {\n // degenerate case, avoids division by zero\n this.fCoef = 0;\n this.fOffset = (v1 + v2) / 2;\n }\n }\n returnMappedValue(v: number): number {\n var x = this.fRange.clip(v);\n return this.fOffset + x * this.fCoef;\n }\n getLowHigh(amin: number, amax: number): InterpolateObject {\n return { amin: this.fRange.fLo, amax: this.fRange.fHi };\n }\n };\n }\n return this._Interpolator;\n }\n\n static _Interpolator3pt: new (lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) => Interpolator3pt;\n /**\n * Interpolator3pt class, combine two interpolators\n */\n static get Interpolator3pt() {\n if (!this._Interpolator3pt) {\n this._Interpolator3pt = class {\n\n fSegment1: Interpolator;\n fSegment2: Interpolator;\n fMid: number;\n\n constructor(lo: number, mid: number, hi: number, v1: number, vMid: number, v2: number) {\n this.fSegment1 = new FaustSensors.Interpolator(lo, mid, v1, vMid);\n this.fSegment2 = new FaustSensors.Interpolator(mid, hi, vMid, v2);\n this.fMid = mid;\n }\n returnMappedValue(x: number): number {\n return (x < this.fMid) ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n var lowHighSegment1 = this.fSegment1.getLowHigh(amin, amid);\n var lowHighSegment2 = this.fSegment2.getLowHigh(amid, amax);\n return { amin: lowHighSegment1.amin, amid: lowHighSegment2.amin, amax: lowHighSegment2.amax };\n }\n }\n\n }\n return this._Interpolator3pt;\n }\n static _UpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpConverter class, convert accelerometer value to Faust value\n */\n static get UpConverter() {\n if (!this._UpConverter) {\n this._UpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, init, max);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amin, amid, amax);\n }\n\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpConverter;\n }\n static _DownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * DownConverter class, convert accelerometer value to Faust value\n */\n static get DownConverter() {\n if (!this._DownConverter) {\n this._DownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator3pt;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);\n this.fF2A = new FaustSensors.Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, init, min);\n this.fF2A = new FaustSensors.Interpolator3pt(min, init, max, amax, amid, amin);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._DownConverter;\n }\n static _UpDownConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n /**\n * UpDownConverter class, convert accelerometer value to Faust value\n */\n static get UpDownConverter() {\n if (!this._UpDownConverter) {\n this._UpDownConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, min, max, min);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n\n }\n return this._UpDownConverter;\n }\n /**\n * DownUpConverter class, convert accelerometer value to Faust value\n */\n static _DownUpConverter: new (amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) => UpdatableValueConverter;\n static get DownUpConverter() {\n if (!this._DownUpConverter) {\n this._DownUpConverter = class implements UpdatableValueConverter {\n\n fA2F: Interpolator3pt;\n fF2A: Interpolator;\n fActive: boolean = true;\n\n constructor(amin: number, amid: number, amax: number, fmin: number, fmid: number, fmax: number) {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);\n this.fF2A = new FaustSensors.Interpolator(fmin, fmax, amin, amax);\n }\n\n uiToFaust(x: number) { return this.fA2F.returnMappedValue(x) }\n faustToUi(x: number) { return this.fF2A.returnMappedValue(x) }\n\n setMappingValues(amin: number, amid: number, amax: number, min: number, init: number, max: number): void {\n this.fA2F = new FaustSensors.Interpolator3pt(amin, amid, amax, max, min, max);\n this.fF2A = new FaustSensors.Interpolator(min, max, amin, amax);\n }\n getMappingValues(amin: number, amid: number, amax: number): InterpolateObject3pt {\n return this.fA2F.getMappingValues(amin, amid, amax);\n }\n\n setActive(onOff: boolean): void { this.fActive = onOff }\n getActive(): boolean { return this.fActive }\n }\n }\n return this._DownUpConverter;\n }\n /**\n * Public function to build the accelerometer handler\n *\n * @returns `UpdatableValueConverter` built for the given curve\n */\n static buildHandler(curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number): UpdatableValueConverter {\n switch (curve) {\n case Curve.Up:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n case Curve.Down:\n return new FaustSensors.DownConverter(amin, amid, amax, min, init, max);\n case Curve.UpDown:\n return new FaustSensors.UpDownConverter(amin, amid, amax, min, init, max);\n case Curve.DownUp:\n return new FaustSensors.DownUpConverter(amin, amid, amax, min, init, max);\n default:\n return new FaustSensors.UpConverter(amin, amid, amax, min, init, max);\n }\n }\n}\n", "import type { FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance } from \"./FaustDspInstance\";\nimport type { AudioData, FaustDspMeta, FaustUIDescriptor, FaustUIGroup, FaustUIInputItem, FaustUIItem, LooseFaustDspFactory } from \"./types\";\nimport FaustSensors, { Axis, Curve, UpdatableValueConverter } from \"./FaustSensors\";\n\n// Public API\nexport type OutputParamHandler = (path: string, value: number) => void;\nexport type ComputeHandler = (buffer_size: number) => void;\nexport type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: { type: string; data: any }[]) => void;\nexport type MetadataHandler = (key: string, value: string) => void;\n\n// Implementation API\nexport type UIHandler = (item: FaustUIItem) => void;\n\n// Accelerometer or gyroscope handler\nexport type SensorEventHandler = (val: number) => void;\n\n// Define a type for the accelerometer or gyroscope handlers\nexport type SensorEventHandlers = {\n x: SensorEventHandler[];\n y: SensorEventHandler[];\n z: SensorEventHandler[];\n};\n\n/** Definition of the AudioBufferItem type */\nexport interface AudioBufferItem {\n pathName: string;\n audioBuffer: AudioBuffer;\n};\n\n/** Definition of the SoundfileItem type */\nexport interface SoundfileItem {\n /** Name of the soundfile */\n name: string;\n /** URL of the soundfile */\n url: string;\n /** Index in the DSP struct */\n index: number;\n /** Base pointer in wasm memory */\n basePtr: number;\n};\n\n/**\n * WasmAllocator is a basic memory management class designed to allocate\n * blocks of memory within a WebAssembly.Memory object. It provides a simple\n * alloc method to allocate a contiguous block of memory of a specified size.\n * \n * The allocator operates by keeping a linear progression through the memory,\n * always allocating the next block at the end of the last. This approach does not\n * handle freeing of memory or reuse of memory spaces.\n */\nexport class WasmAllocator {\n // The WebAssembly.Memory object this allocator will manage.\n private readonly memory: WebAssembly.Memory;\n // The number of bytes currently allocated. This serves as the \"pointer\" to the\n // next free byte in the memory.\n private allocatedBytes: number;\n\n constructor(memory: WebAssembly.Memory, offset: number) {\n this.memory = memory;\n // Initialize the allocator with offset allocated bytes.\n this.allocatedBytes = offset;\n }\n\n /**\n * Allocates a block of memory of the specified size, returning the pointer to the\n * beginning of the block. The block is allocated at the current offset and the\n * offset is incremented by the size of the block.\n * \n * @param sizeInBytes The size of the block to allocate in bytes.\n * @returns The offset (pointer) to the beginning of the allocated block.\n */\n alloc(sizeInBytes: number): number {\n // Store the current offset as the start of the new block.\n const currentOffset = this.allocatedBytes;\n // Calculate the new offset after allocating the requested block.\n const newOffset = currentOffset + sizeInBytes;\n // Get the total size of the WebAssembly memory in bytes.\n const totalMemoryBytes = this.memory.buffer.byteLength;\n\n // If the new offset exceeds the total size of the memory, grow the memory.\n if (newOffset > totalMemoryBytes) {\n // Calculate the number of WebAssembly pages needed to fit the new allocation.\n // WebAssembly memory pages are 64KiB each.\n const neededPages = Math.ceil((newOffset - totalMemoryBytes) / 65536);\n // Grow the memory by the required number of pages.\n console.log(`GROW: ${neededPages} pages`);\n this.memory.grow(neededPages);\n }\n\n // Update the allocated bytes to the new offset.\n this.allocatedBytes = newOffset;\n // Return the offset at which the allocated block starts.\n return currentOffset;\n }\n\n /**\n * Returns the underlying buffer object.\n * \n * @returns The buffer object.\n */\n getBuffer(): ArrayBuffer {\n return this.memory.buffer;\n }\n\n /**\n * Returns the Int32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Int32Array.\n */\n getInt32Array(): Int32Array {\n return new Int32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Int64 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as BigInt64Array.\n */\n getInt64Array(): BigInt64Array {\n return new BigInt64Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float32 view of the underlying buffer object.\n * \n * @returns The view of the memory buffer as Float32Array.\n */\n getFloat32Array(): Float32Array {\n return new Float32Array(this.memory.buffer);\n }\n\n /**\n * Returns the Float64 view of the underlying buffer object..\n * \n * @returns The view of the memory buffer as Float64Array.\n */\n getFloat64Array(): Float64Array {\n return new Float64Array(this.memory.buffer);\n }\n}\n\n/**\n * Soundfile class to handle soundfile data in wasm memory.\n */\nexport class Soundfile {\n /** Maximum number of soundfile parts. */\n static get MAX_SOUNDFILE_PARTS() { return 256; }\n\n /** Maximum number of channels. */\n static get MAX_CHAN() { return 64; }\n\n /** Maximum buffer size in frames. */\n static get BUFFER_SIZE() { return 1024; }\n\n /** Default sample rate. */\n static get SAMPLE_RATE() { return 44100; }\n\n /** Pointer to the soundfile structure in wasm memory */\n private readonly fPtr: number;\n private readonly fBuffers: number;\n private readonly fLength: number;\n private readonly fSR: number;\n private readonly fOffset: number;\n private readonly fSampleSize: number;\n private readonly fPtrSize: number;\n private readonly fIntSize: number;\n private readonly fAllocator: WasmAllocator;\n\n constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number) {\n\n this.fSampleSize = sampleSize;\n\n // To be coherent with the code generated by the wast/wasm backends:\n // - that uses 4 bytes for int when float is used\n // - that uses 8 bytes for int when double is used (to simplify the code generation)\n this.fIntSize = this.fSampleSize;\n\n this.fPtrSize = 4; // Not related to float/double choice, so always 4\n\n this.fAllocator = allocator;\n\n console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);\n\n // Allocate wasm memory for the soundfile structure\n this.fPtr = allocator.alloc(4 * this.fPtrSize); // 4 fPtrSize: fBuffers, fLength, fSR, fOffset\n\n // Use the 4 or 8 bytes size for int. The access are then adapted in copyToOut and emptyFile methods\n this.fLength = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fSR = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n this.fOffset = allocator.alloc(Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);\n\n this.fBuffers = this.allocBuffers(curChan, length, maxChan);\n\n //this.displayMemory(\"Allocated soundfile structure 1\");\n\n // Set the soundfile structure in wasm memory\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[this.fPtr >> 2] = this.fBuffers;\n HEAP32[(this.fPtr + this.fPtrSize) >> 2] = this.fLength;\n HEAP32[(this.fPtr + (2 * this.fPtrSize)) >> 2] = this.fSR;\n HEAP32[(this.fPtr + (3 * this.fPtrSize)) >> 2] = this.fOffset;\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = HEAP32[(this.fBuffers >> 2) + chan];\n console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);\n }\n\n //this.displayMemory(\"Allocated soundfile structure 2\");\n }\n\n private allocBuffers(curChan: number, length: number, maxChan: number): number {\n const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);\n\n console.log(`allocBuffers buffers: ${buffers}`);\n\n for (let chan = 0; chan < curChan; chan++) {\n const buffer: number = this.fAllocator.alloc(length * this.fSampleSize);\n // HEAP32 is the Int32Array view of the memory buffer which can change after grow in `alloc` method\n // so we need to recompute the buffer address\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(buffers >> 2) + chan] = buffer;\n }\n //this.displayMemory(\"Allocated soundfile buffers\");\n return buffers;\n }\n\n shareBuffers(curChan: number, maxChan: number) {\n // Share the same buffers for all other channels so that we have maxChan channels available\n const HEAP32 = this.fAllocator.getInt32Array();\n for (let chan = curChan; chan < maxChan; chan++) {\n HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];\n }\n }\n\n copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData) {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);\n\n //this.displayMemory(\"IN copyToOut, BEFORE copyToOutReal\", true);\n // Copy the soundfile data to the buffer\n if (this.fSampleSize === 8) {\n this.copyToOutReal64(maxChannels, offset, audioData);\n } else {\n this.copyToOutReal32(maxChannels, offset, audioData);\n }\n //this.displayMemory(\"IN copyToOut, AFTER copyToOutReal\");\n }\n\n copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat32Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float32Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData) {\n const HEAP32 = this.fAllocator.getInt32Array();\n const HEAPF = this.fAllocator.getFloat64Array();\n for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {\n const input: Float32Array = audioData.audioBuffer[chan];\n const output: number = HEAP32[(this.fBuffers >> 2) + chan];\n const begin: number = (output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize);\n const end: number = (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize);\n console.log(`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`);\n const outputReal: Float64Array = HEAPF.subarray((output + (offset * this.fSampleSize)) >> Math.log2(this.fSampleSize),\n (output + (offset + input.length) * this.fSampleSize) >> Math.log2(this.fSampleSize));\n for (let sample = 0; sample < input.length; sample++) {\n outputReal[sample] = input[sample];\n }\n }\n }\n\n emptyFile(part: number, offset: number): number {\n // Set the soundfile fields in wasm memory\n if (this.fIntSize === 4) {\n const HEAP32 = this.fAllocator.getInt32Array();\n HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = Soundfile.BUFFER_SIZE;\n HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = Soundfile.SAMPLE_RATE;\n HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;\n } else {\n const HEAP64 = this.fAllocator.getInt64Array();\n HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.BUFFER_SIZE);\n HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(Soundfile.SAMPLE_RATE);\n HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);\n }\n\n // Update and return the new offset\n return offset + Soundfile.BUFFER_SIZE;\n }\n\n displayMemory(where: string = \"\", mem: boolean = false) {\n console.log(\"Soundfile memory: \" + where);\n console.log(`fPtr: ${this.fPtr}`);\n console.log(`fBuffers: ${this.fBuffers}`);\n console.log(`fLength: ${this.fLength}`);\n console.log(`fSR: ${this.fSR}`);\n console.log(`fOffset: ${this.fOffset}`);\n const HEAP32 = this.fAllocator.getInt32Array();\n if (mem) console.log(`HEAP32: ${HEAP32}`);\n console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);\n console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[(this.fPtr + this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 2 * this.fPtrSize) >> 2]}`);\n console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[(this.fPtr + 3 * this.fPtrSize) >> 2]}`);\n }\n\n // Return the pointer to the soundfile structure in wasm memory\n getPtr(): number {\n return this.fPtr;\n }\n\n getHEAP32(): Int32Array {\n return this.fAllocator.getInt32Array();\n }\n getHEAPFloat32(): Float32Array {\n return this.fAllocator.getFloat32Array();\n }\n\n getHEAPFloat64(): Float64Array {\n return this.fAllocator.getFloat64Array();\n }\n}\n\n/**\n * DSP implementation that mimic the C++ 'dsp' class:\n * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers\n * - an output handler can be set to treat produced output controllers (like 'bargraph') \n * - regular controllers are handled using setParamValue/getParamValue and getParams methods\n */\nexport interface IFaustBaseWebAudioDsp {\n /**\n * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).\n *\n * @param handler - the output handler\n */\n setOutputParamHandler(handler: OutputParamHandler | null): void;\n\n /**\n * Get the parameter output handler.\n *\n * @return the current output handler\n */\n getOutputParamHandler(): OutputParamHandler | null;\n\n /**\n * Set the compute handler, to be called in the 'compute' method with buffer size.\n *\n * @param handler - the compute handler\n */\n setComputeHandler(handler: ComputeHandler | null): void;\n\n /**\n * Get the compute handler.\n *\n * @return the current output handler\n */\n getComputeHandler(): ComputeHandler | null;\n\n /**\n * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).\n *\n * @param handler - the plot handler\n */\n setPlotHandler(handler: PlotHandler | null): void;\n\n /**\n * Get the plot handler.\n *\n * @return the current plot handler\n */\n getPlotHandler(): PlotHandler | null;\n\n /**\n * Return instance number of audio inputs.\n *\n * @return the instance number of audio inputs\n */\n getNumInputs(): number;\n\n /**\n * Return instance number of audio outputs.\n *\n * @return the instance number of audio outputs\n */\n getNumOutputs(): number;\n\n /**\n * DSP instance computation, to be called with successive input/output audio buffers, using their size.\n *\n * @param inputs - the input audio buffers\n * @param outputs - the output audio buffers\n */\n compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;\n\n /**\n * Give a handler to be called on 'declare key value' kind of metadata.\n *\n * @param handler - the handler to be used\n */\n metadata(handler: MetadataHandler): void;\n\n /**\n * Handle untyped MIDI messages.\n *\n * @param data - and arry of MIDI bytes\n */\n midiMessage(data: number[] | Uint8Array): void;\n\n /**\n * Handle MIDI ctrlChange messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param ctrl - the MIDI controller number (0..127)\n * @param value - the MIDI controller value (0..127)\n */\n ctrlChange(chan: number, ctrl: number, value: number): void;\n\n /**\n * Handle MIDI pitchWheel messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param value - the MIDI controller value (0..16383)\n */\n pitchWheel(chan: number, value: number): void;\n\n /**\n * Set parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n * @param val - the float value for the wanted control\n */\n setParamValue(path: string, value: number): void;\n\n /**\n * Get parameter value.\n *\n * @param path - the path to the wanted parameter (retrieved using 'getParams' method)\n *\n * @return the float value\n */\n getParamValue(path: string): number;\n\n /**\n * Get the table of all input parameters paths.\n *\n * @return the table of all input parameters paths\n */\n getParams(): string[];\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n\n /**\n * Get DSP UI items description.\n *\n * @return the DSP UI items description\n */\n getDescriptors(): FaustUIInputItem[];\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Start the DSP.\n */\n start(): void;\n\n /**\n * Stop the DSP.\n */\n stop(): void;\n\n /**\n * Destroy the DSP.\n */\n destroy(): void;\n\n /** Indicating if the DSP handles the accelerometer */\n readonly hasAccInput: boolean;\n /** Accelerometer handling */\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean): void;\n\n /** Indicating if the DSP handles the gyroscope */\n readonly hasGyrInput: boolean;\n /** Gyroscope handling */\n propagateGyr(event: Pick): void;\n}\n\nexport interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp { }\nexport interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode { }\n\nexport interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {\n /**\n * Handle MIDI keyOn messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOn(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Handle MIDI keyOff messages.\n *\n * @param channel - the MIDI channel (0..15, not used for now)\n * @param pitch - the MIDI pitch value (0..127)\n * @param velocity - the MIDI velocity value (0..127)\n */\n keyOff(channel: number, pitch: number, velocity: number): void;\n\n /**\n * Stop all playing notes.\n *\n * @param hard - whether to immediately stop notes or put them in release mode\n */\n allNotesOff(hard: boolean): void;\n}\nexport interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode { }\n\nexport class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {\n protected fOutputHandler: OutputParamHandler | null = null;\n protected fComputeHandler: ComputeHandler | null = null;\n\n // To handle MIDI events plot\n protected fPlotHandler: PlotHandler | null = null;\n protected fCachedEvents: { type: string; data: any }[] = [];\n protected fBufferNum = 0;\n\n protected fInChannels: Float32Array[] | Float64Array[] = [];\n protected fOutChannels: Float32Array[] | Float64Array[] = [];\n\n protected fOutputsTimer = 5;\n\n // UI items path\n protected fInputsItems: string[] = [];\n protected fOutputsItems: string[] = [];\n protected fDescriptor: FaustUIInputItem[] = [];\n\n // Soundfile handling\n protected fSoundfiles: SoundfileItem[] = [];\n protected fSoundfileBuffers: LooseFaustDspFactory[\"soundfiles\"] = {};\n /** Keep the end of memory offset before soundfiles */\n protected fEndMemory: number;\n\n // Accelerometer handling\n protected fAcc: SensorEventHandlers; // array of accelerometer handlers on x,y,y axes, to be called with DeviceMotionEvent\n protected fGyr: SensorEventHandlers; // array of gyroscope handlers on alpha,beta,gama axes, to be called with DeviceMotionEvent\n\n // Buffers in wasm memory\n protected fAudioInputs!: number;\n protected fAudioOutputs!: number;\n\n protected fBufferSize: number;\n protected fPtrSize: number;\n protected fSampleSize: number;\n\n // MIDI handling\n protected fPitchwheelLabel: { path: string; chan: number; min: number; max: number }[] = [];\n protected fCtrlLabel: { path: string; chan: number; min: number; max: number }[][] = new Array(128).fill(null).map(() => []);\n protected fPathTable: { [address: string]: number } = {};\n protected fUICallback: UIHandler = (item: FaustUIItem) => {\n if (item.type === \"hbargraph\" || item.type === \"vbargraph\") {\n // Keep bargraph adresses\n this.fOutputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n } else if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fPathTable[item.address] = item.index;\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n // Parse 'midi' metadata\n if (midi) {\n const strMidi = midi.trim();\n if (strMidi === \"pitchwheel\") {\n const matched = strMidi.match(/^pitchwheel\\s(\\d+)/);\n // \"pitchwheel chan\"\n if (matched) {\n this.fPitchwheelLabel.push({ path: item.address, chan: parseInt(matched[1]), min: item.min as number, max: item.max as number });\n // \"pitchwheel\"\n } else {\n this.fPitchwheelLabel.push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n } else {\n // \"ctrl num chan\"\n const matched2 = strMidi.match(/^ctrl\\s(\\d+)\\s(\\d+)/);\n // \"ctrl num\"\n const matched1 = strMidi.match(/^ctrl\\s(\\d+)/);\n if (matched2) {\n this.fCtrlLabel[parseInt(matched2[1])].push({ path: item.address, chan: parseInt(matched2[2]), min: item.min as number, max: item.max as number });\n } else if (matched1) {\n this.fCtrlLabel[parseInt(matched1[1])].push({ path: item.address, chan: 0, min: item.min as number, max: item.max as number });\n }\n }\n }\n\n // Parse 'acc' metadata\n if (acc) {\n const numAcc: number[] = acc.trim().split(\" \").map(Number);\n this.setupAccHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n // Parse 'gyr' metadata\n if (gyr) {\n const numAcc: number[] = gyr.trim().split(\" \").map(Number);\n this.setupGyrHandler(item.address, FaustSensors.convertToAxis(numAcc[0]), FaustSensors.convertToCurve(numAcc[1]), numAcc[2], numAcc[3], numAcc[4], item.min as number, item.init as number, item.max as number);\n }\n });\n } else if (item.type === \"soundfile\") {\n this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });\n }\n };\n\n // Audio callback\n protected fProcessing = false;\n protected fDestroyed = false;\n protected fFirstCall = true;\n\n protected fJSONDsp!: FaustDspMeta;\n\n constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n this.fBufferSize = bufferSize;\n this.fPtrSize = sampleSize; // Done on wast/wasm backend side\n this.fSampleSize = sampleSize;\n this.fSoundfileBuffers = soundfiles;\n this.fAcc = { x: [], y: [], z: [] };\n this.fGyr = { x: [], y: [], z: [] };\n }\n\n // Tools\n static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number) {\n return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;\n }\n\n // JSON parsing functions\n static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any) {\n ui.forEach(group => this.parseGroup(group, callback));\n }\n\n static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any) {\n if (group.items) {\n this.parseItems(group.items, callback);\n }\n }\n static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any) {\n items.forEach(item => this.parseItem(item, callback));\n }\n\n static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any) {\n if (item.type === \"vgroup\" || item.type === \"hgroup\" || item.type === \"tgroup\") {\n this.parseItems(item.items, callback);\n } else {\n callback(item);\n }\n }\n\n /** Split the soundfile names and return an array of names */\n static splitSoundfileNames(input: string): string[] {\n // Trim off the curly braces at the start and end, if present\n let trimmed = input.replace(/^\\{|\\}$/g, '');\n // Split the string into an array of strings and remove first and last characters\n return trimmed.split(\";\").map(str => str.length <= 2 ? '' : str.substring(1, str.length - 1));\n }\n\n get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n\n // Get accelerometervalues\n const { x, y, z } = accelerationIncludingGravity;\n\n if (invert) {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(-x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(-y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(-z));\n } else {\n // Call the accelerometer handlers\n if (x !== null) this.fAcc.x.forEach(handler => handler(x));\n if (y !== null) this.fAcc.y.forEach(handler => handler(y));\n if (z !== null) this.fAcc.z.forEach(handler => handler(z));\n }\n }\n\n get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }\n propagateGyr(event: Pick) {\n\n // Get gyroscope values\n const { alpha, beta, gamma } = event;\n\n // Call the gyroscope handlers\n if (alpha !== null) this.fGyr.x.forEach(handler => handler(alpha));\n if (beta !== null) this.fGyr.y.forEach(handler => handler(beta));\n if (gamma !== null) this.fGyr.z.forEach(handler => handler(gamma));\n }\n\n /** Build the accelerometer handler */\n private setupAccHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fAcc.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fAcc.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fAcc.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n /** Build the gyroscope handler */\n private setupGyrHandler(path: string, axis: Axis, curve: Curve, amin: number, amid: number, amax: number, min: number, init: number, max: number) {\n\n const handler: UpdatableValueConverter = FaustSensors.buildHandler(curve, amin, amid, amax, min, init, max);\n switch (axis) {\n case Axis.x:\n this.fGyr.x.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.y:\n this.fGyr.y.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n case Axis.z:\n this.fGyr.z.push((val) => this.setParamValue(path, handler.uiToFaust(val)));\n break;\n }\n }\n\n static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[] {\n // Find the entry with the \"soundfiles\" key\n const soundfilesEntry = dspMeta.meta.find(entry => entry.soundfiles !== undefined);\n // If the entry is found, split the string by semicolon to get the URLs\n if (soundfilesEntry) {\n return soundfilesEntry.soundfiles.split(\";\").filter(url => url !== \"\");\n } else {\n return [];\n }\n }\n\n /**\n * Load a soundfile possibly containing several parts in the DSP struct.\n * Soundfile pointers are located at 'index' offset, to be read in the JSON file.\n * The DSP struct is located at baseDSP in the wasm memory, \n * either a monophonic DSP, or a voice in a polyphonic context.\n * \n * @param allocator : the wasm memory allocator\n * @param baseDSP : the base DSP in the wasm memory\n * @param name : the name of the soundfile\n * @param url : the url of the soundfile\n */\n private loadSoundfile(allocator: WasmAllocator, baseDSP: number, name: string, url: string) {\n console.log(`Soundfile ${name} paths: ${url}`);\n const soundfileIds = FaustBaseWebAudioDsp.splitSoundfileNames(url);\n const item = this.fSoundfiles.find(item => item.url === url);\n if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);\n // Use the cached Soundfile\n if (item.basePtr !== -1) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = allocator.getInt32Array();\n // Fill the soundfile structure in wasm memory, soundfiles are at the beginning of the DSP memory\n console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n // Create the soundfiles\n const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);\n if (soundfile) {\n // Update HEAP32 after soundfile creation\n const HEAP32 = soundfile.getHEAP32();\n // Get the soundfile pointer in wasm memory\n item.basePtr = soundfile.getPtr();\n console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);\n // Soundfile is located at 'index' in the DSP struct, to be added with baseDSP in the wasm memory\n HEAP32[(baseDSP + item.index) >> 2] = item.basePtr;\n } else {\n console.log(`Soundfile ${name} for ${url} cannot be created !}`);\n }\n }\n }\n\n createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], maxChan = Soundfile.MAX_CHAN) {\n let curChan = 1; // At least one channel\n let totalLength = 0;\n\n // Compute total length and channels max of all files\n for (const soundfileId of soundfileIdList) {\n let chan = 0;\n let len = 0;\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n chan = audioData.audioBuffer.length;\n len = audioData.audioBuffer[0].length;\n } else {\n len = Soundfile.BUFFER_SIZE;\n chan = 1;\n }\n curChan = Math.max(curChan, chan);\n totalLength += len;\n }\n\n // Complete with empty parts\n totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;\n\n // Create the soundfile\n const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);\n\n //soundfile.displayMemory(\"After soundfile creation\");\n // Init offset\n let offset = 0;\n\n // Read all files\n for (let part = 0; part < soundfileIdList.length; part++) {\n const soundfileId = soundfileIdList[part];\n const audioData = soundfiles[soundfileId];\n if (audioData) {\n //soundfile.displayMemory(\"BEFORE copyToOut\");\n soundfile.copyToOut(part, maxChan, offset, audioData);\n //soundfile.displayMemory(\"AFTER copyToOut\");\n offset += audioData.audioBuffer[0].length;\n } else {\n // Empty sound\n offset = soundfile.emptyFile(part, offset);\n }\n }\n\n //soundfile.displayMemory(\"After reading soundfiles\");\n\n // Complete with empty parts\n for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {\n offset = soundfile.emptyFile(part, offset);\n }\n\n //soundfile.displayMemory(\"After emptyFile\");\n\n // Share the same buffers for all other channels so that we have maxChan channels available\n soundfile.shareBuffers(curChan, maxChan);\n\n //soundfile.displayMemory(\"After shareBuffers\");\n\n return soundfile;\n }\n /** \n * Init soundfiles memory.\n * \n * @param allocator : the wasm memory allocator\n * @param sfReader : the soundfile reader\n * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory\n */\n protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number) {\n // Create and fill the soundfile structure\n for (const { name, url } of this.fSoundfiles) {\n this.loadSoundfile(allocator, baseDSP, name, url);\n };\n }\n\n protected updateOutputs() {\n if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {\n this.fOutputsTimer = 5;\n this.fOutputsItems.forEach(item => this.fOutputHandler?.(item, this.getParamValue(item)));\n }\n }\n\n // Public API\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) {\n return false;\n }\n\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler() {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n }\n getPlotHandler() {\n return this.fPlotHandler;\n }\n\n getNumInputs() {\n return -1;\n }\n getNumOutputs() {\n return -1;\n }\n\n midiMessage(data: number[] | Uint8Array) {\n if (this.fPlotHandler) this.fCachedEvents.push({ data, type: \"midi\" });\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) return this.ctrlChange(channel, data1, data2);\n if (cmd === 14) return this.pitchWheel(channel, (data2 * 128.0 + data1));\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"ctrlChange\", data: [channel, ctrl, value] });\n if (this.fCtrlLabel[ctrl].length) {\n this.fCtrlLabel[ctrl].forEach((ctrl) => {\n const { path, chan } = ctrl;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl.min, ctrl.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n }\n\n pitchWheel(channel: number, wheel: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"pitchWheel\", data: [channel, wheel] });\n this.fPitchwheelLabel.forEach((pw) => {\n const { path, chan } = pw;\n if (chan === 0 || channel === chan - 1) {\n this.setParamValue(path, FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));\n // Typically used to reflect parameter change on GUI\n if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));\n }\n });\n }\n\n setParamValue(path: string, value: number) { }\n getParamValue(path: string) { return 0; }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n hasSoundfiles() { return this.fSoundfiles.length > 0; }\n\n start() {\n this.fProcessing = true;\n }\n\n stop() {\n this.fProcessing = false;\n }\n\n destroy() {\n this.fDestroyed = true;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n }\n}\n\nexport class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {\n\n private fInstance: FaustMonoDspInstance;\n private fDSP!: number;\n\n constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON object\n this.fJSONDsp = JSON.parse(this.fInstance.json);\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP\n this.fInstance.api.init(this.fDSP, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n\n // Init soundfiles memory\n this.initSoundfileMemory(allocator, this.fDSP);\n }\n\n }\n\n private initMemory(): number {\n\n // Start of DSP memory: Mono DSP is placed first with index 0\n this.fDSP = 0;\n\n // Audio buffer start at the end of DSP\n const $audio = this.fJSONDsp.size;\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n // Compute memory end in bytes\n const endMemory = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Mono Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fDSP: ${this.fDSP}`;\n }\n\n // Public API\n compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n if (typeof input === \"function\") {\n // Call input callback to avoid array copy\n input(this.fInChannels);\n } else {\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && typeof output !== \"function\" && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); chan++) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n }\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n let forPlot = this.fOutChannels;\n if (typeof output === \"function\") {\n // Call output callback to avoid array copy\n output(this.fOutChannels);\n } else {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n // console.log(\"chan: \" + chan + \" output: \" + dspOutput[0]);\n }\n forPlot = output;\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(forPlot, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n\n return true;\n }\n\n metadata(handler: MetadataHandler) { super.metadata(handler); }\n\n getNumInputs() {\n return this.fInstance.api.getNumInputs(this.fDSP);\n }\n getNumOutputs() {\n return this.fInstance.api.getNumOutputs(this.fDSP);\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);\n }\n getParamValue(path: string) {\n return this.fInstance.api.getParamValue(this.fDSP, this.fPathTable[path]);\n }\n\n getMeta() { return this.fJSONDsp; }\n getJSON() { return this.fInstance.json; }\n getDescriptors() { return this.fDescriptor; }\n getUI() { return this.fJSONDsp.ui; }\n}\n\nexport class FaustWebAudioDspVoice {\n // Voice state\n static get kActiveVoice() { return 0; }\n static get kFreeVoice() { return -1; }\n static get kReleaseVoice() { return -2; }\n static get kLegatoVoice() { return -3; }\n static get kNoVoice() { return -4; }\n static get VOICE_STOP_LEVEL() { return 0.0005; }\n\n private fFreqLabel: number[] = [];\n private fGateLabel: number[] = [];\n private fGainLabel: number[] = [];\n private fKeyLabel: number[] = [];\n private fVelLabel: number[] = [];\n private fDSP: number; // Voice DSP location in wasm memory\n private fAPI: IFaustDspInstance; // Voice DSP code\n // Accessed by PolyDSPImp class\n fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n fNextNote = -1;\n fNextVel = -1;\n fDate = 0;\n fLevel = 0;\n fRelease = 0;\n\n constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: { [address: string]: number }, sampleRate: number) {\n this.fDSP = $dsp;\n this.fAPI = api;\n this.fAPI.init(this.fDSP, sampleRate);\n this.extractPaths(inputItems, pathTable);\n }\n\n static midiToFreq(note: number) { return 440.0 * 2 ** ((note - 69) / 12); }\n\n static normalizeVelocity(velocity: number) { return velocity / 127.0; }\n\n private extractPaths(inputItems: string[], pathTable: { [address: string]: number }) {\n inputItems.forEach((item) => {\n if (item.endsWith(\"/gate\")) {\n this.fGateLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/freq\")) {\n this.fFreqLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/key\")) {\n this.fKeyLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/gain\")) {\n this.fGainLabel.push(pathTable[item]);\n } else if (item.endsWith(\"/vel\") && item.endsWith(\"/velocity\")) {\n this.fVelLabel.push(pathTable[item]);\n }\n });\n }\n\n // Public API\n keyOn(pitch: number, velocity: number, legato: boolean = false) {\n if (legato) {\n this.fNextNote = pitch;\n this.fNextVel = velocity;\n } else {\n this.fFreqLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.midiToFreq(pitch)));\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 1));\n this.fGainLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, FaustWebAudioDspVoice.normalizeVelocity(velocity)));\n this.fKeyLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, pitch));\n this.fVelLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, velocity));\n // Keep pitch\n this.fCurNote = pitch;\n }\n }\n\n keyOff(hard: boolean = false) {\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n if (hard) {\n this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n } else {\n this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;\n this.fCurNote = FaustWebAudioDspVoice.kReleaseVoice;\n }\n }\n\n computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number) {\n\n let size = bufferSize / 2;\n\n // Reset envelops\n this.fGateLabel.forEach(index => this.fAPI.setParamValue(this.fDSP, index, 0));\n\n // Compute current voice on half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);\n\n // Start next keyOn\n this.keyOn(this.fNextNote, this.fNextVel);\n\n // Compute on second half buffer\n this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);\n }\n\n compute(bufferSize: number, $inputs: number, $outputs: number) {\n this.fAPI.compute(this.fDSP, bufferSize, $inputs, $outputs);\n }\n\n setParamValue(index: number, value: number) {\n this.fAPI.setParamValue(this.fDSP, index, value);\n }\n getParamValue(index: number) {\n return this.fAPI.getParamValue(this.fDSP, index);\n }\n}\n\nexport class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {\n\n private fInstance: FaustPolyDspInstance;\n private fEffect!: number;\n private fJSONEffect: FaustDspMeta | null;\n private fAudioMixing!: number;\n private fAudioMixingHalf!: number;\n private fVoiceTable: FaustWebAudioDspVoice[];\n\n constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory[\"soundfiles\"]) {\n super(sampleSize, bufferSize, soundfiles);\n this.fInstance = instance;\n\n console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);\n\n // Create JSON for voice\n this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);\n\n // Create JSON for effect\n this.fJSONEffect = (this.fInstance.effectAPI && this.fInstance.effectJSON) ? JSON.parse(this.fInstance.effectJSON) : null;\n\n // Setup GUI\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n\n // Setup wasm memory\n this.fEndMemory = this.initMemory();\n\n // Init DSP voices\n this.fVoiceTable = [];\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.fVoiceTable.push(new FaustWebAudioDspVoice(\n this.fJSONDsp.size * voice,\n this.fInstance.voiceAPI,\n this.fInputsItems,\n this.fPathTable,\n sampleRate\n ));\n }\n\n // Init effect\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);\n\n // Init soundfiles memory is needed\n if (this.fSoundfiles.length > 0) {\n // Create memory allocator for soundfiles in wasm memory, starting at the end of DSP memory\n const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);\n // Init soundfiles memory for all voices\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);\n }\n }\n }\n\n private initMemory() {\n\n // Effet start at the end of all DSP voices\n this.fEffect = this.fJSONDsp.size * this.fInstance.voices;\n\n // Audio buffer start at the end of effect\n const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);\n\n // Setup audio pointers offset\n this.fAudioInputs = $audio;\n this.fAudioOutputs = this.fAudioInputs + this.getNumInputs() * this.fPtrSize;\n this.fAudioMixing = this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize;\n this.fAudioMixingHalf = this.fAudioMixing + this.getNumOutputs() * this.fPtrSize;\n\n // Prepare wasm memory layout\n const $audioInputs = this.fAudioMixingHalf + this.getNumOutputs() * this.fPtrSize;\n const $audioOutputs = $audioInputs + this.getNumInputs() * this.fBufferSize * this.fSampleSize;\n const $audioMixing = $audioOutputs + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Compute memory end in bytes\n const endMemory = $audioMixing + this.getNumOutputs() * this.fBufferSize * this.fSampleSize;\n\n // Setup Int32 and Real views of the memory\n const HEAP = this.fInstance.memory.buffer;\n const HEAP32 = new Int32Array(HEAP);\n const HEAPF = (this.fSampleSize === 4) ? new Float32Array(HEAP) : new Float64Array(HEAP);\n\n if (this.getNumInputs() > 0) {\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;\n }\n // Prepare Ins buffer tables\n const dspInChans = HEAP32.subarray(this.fAudioInputs >> 2, (this.fAudioInputs + this.getNumInputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumInputs(); chan++) {\n this.fInChannels[chan] = HEAPF.subarray(dspInChans[chan] >> Math.log2(this.fSampleSize), (dspInChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n if (this.getNumOutputs() > 0) {\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;\n HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;\n }\n // Prepare Out buffer tables\n const dspOutChans = HEAP32.subarray(this.fAudioOutputs >> 2, (this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize) >> 2);\n for (let chan = 0; chan < this.getNumOutputs(); chan++) {\n this.fOutChannels[chan] = HEAPF.subarray(dspOutChans[chan] >> Math.log2(this.fSampleSize), (dspOutChans[chan] + this.fBufferSize * this.fSampleSize) >> Math.log2(this.fSampleSize));\n }\n }\n\n return endMemory;\n }\n\n toString() {\n return `============== Poly Memory layout ==============\n this.fBufferSize: ${this.fBufferSize}\n this.fJSONDsp.size: ${this.fJSONDsp.size}\n this.fAudioInputs: ${this.fAudioInputs}\n this.fAudioOutputs: ${this.fAudioOutputs}\n this.fAudioMixing: ${this.fAudioMixing}\n this.fAudioMixingHalf: ${this.fAudioMixingHalf}`;\n }\n\n private allocVoice(voice: number, type: number) {\n this.fVoiceTable[voice].fDate++;\n this.fVoiceTable[voice].fCurNote = type;\n return voice;\n }\n\n private getPlayingVoice(pitch: number) {\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === pitch) {\n // Keeps oldest playing voice\n if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n }\n return voicePlaying;\n }\n\n private getFreeVoice() {\n for (let voice = 0; voice < this.fInstance.voices; voice++) {\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {\n return this.allocVoice(voice, FaustWebAudioDspVoice.kActiveVoice);\n }\n }\n\n let voiceRelease = FaustWebAudioDspVoice.kNoVoice;\n let voicePlaying = FaustWebAudioDspVoice.kNoVoice;\n let oldestDateRelease = Number.MAX_VALUE;\n let oldestDatePlaying = Number.MAX_VALUE;\n\n for (let voice = 0; voice < this.fInstance.voices; voice++) { // Scan all voices\n // Try to steal a voice in DspVoice.kReleaseVoice mode...\n if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kReleaseVoice) {\n // Keeps oldest release voice\n if (this.fVoiceTable[voice].fDate < oldestDateRelease) {\n oldestDateRelease = this.fVoiceTable[voice].fDate;\n voiceRelease = voice;\n }\n } else if (this.fVoiceTable[voice].fDate < oldestDatePlaying) {\n oldestDatePlaying = this.fVoiceTable[voice].fDate;\n voicePlaying = voice;\n }\n }\n // Then decide which one to steal\n if (oldestDateRelease !== Number.MAX_VALUE) {\n console.log(`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`);\n return this.allocVoice(voiceRelease, FaustWebAudioDspVoice.kLegatoVoice);\n }\n if (oldestDatePlaying !== Number.MAX_VALUE) {\n console.log(`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`);\n return this.allocVoice(voicePlaying, FaustWebAudioDspVoice.kLegatoVoice);\n }\n return FaustWebAudioDspVoice.kNoVoice;\n }\n\n // Public API\n compute(input: Float32Array[], output: Float32Array[]) {\n\n // Check DSP state\n if (this.fDestroyed) return false;\n\n // Init memory again on first call (since WebAssembly.memory.grow() may have been called)\n if (this.fFirstCall) {\n this.initMemory();\n this.fFirstCall = false;\n }\n\n // Check Processing state: the node returns 'true' to stay in the graph, even if not processing\n if (!this.fProcessing) return true;\n\n // Check inputs\n if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {\n // console.log(\"Process input error\");\n return true;\n }\n\n // Check outputs\n if (this.getNumOutputs() > 0 && (!output || !output[0] || output[0].length === 0)) {\n // console.log(\"Process output error\");\n return true;\n }\n\n // Copy inputs\n if (input !== undefined) {\n for (let chan = 0; chan < Math.min(this.getNumInputs(), input.length); ++chan) {\n const dspInput = this.fInChannels[chan];\n dspInput.set(input[chan]);\n }\n }\n\n // Possibly call an externally given callback (for instance to synchronize playing a MIDIFile...)\n if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);\n\n // Compute\n this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);\n this.fVoiceTable.forEach((voice) => {\n if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {\n // Play from current note and next note\n voice.computeLegato(this.fBufferSize, this.fAudioInputs, this.fAudioMixing, this.fAudioMixingHalf);\n // FadeOut on first half buffer\n this.fInstance.mixerAPI.fadeOut(this.fBufferSize / 2, this.getNumOutputs(), this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n } else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {\n // Compute current note\n voice.compute(this.fBufferSize, this.fAudioInputs, this.fAudioMixing);\n // Mix it in result\n voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(this.fBufferSize, this.getNumOutputs(), this.fAudioMixing, this.fAudioOutputs);\n // Check the level to possibly set the voice in kFreeVoice again\n voice.fRelease -= this.fBufferSize;\n if ((voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice) && ((voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) && (voice.fRelease < 0))) {\n voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;\n }\n }\n });\n if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);\n\n // Update bargraph\n this.updateOutputs();\n\n if (output !== undefined) {\n // Copy outputs\n for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {\n const dspOutput = this.fOutChannels[chan];\n output[chan].set(dspOutput);\n }\n\n // PlotHandler handling \n if (this.fPlotHandler) {\n this.fPlotHandler(output, this.fBufferNum++, (this.fCachedEvents.length ? this.fCachedEvents : undefined));\n this.fCachedEvents = [];\n }\n }\n\n return true;\n }\n\n getNumInputs() {\n return this.fInstance.voiceAPI.getNumInputs(0);\n }\n getNumOutputs() {\n return this.fInstance.voiceAPI.getNumOutputs(0);\n }\n\n private static findPath(o: any, p: string) {\n if (typeof o !== \"object\") {\n return false;\n } else if (o.address) {\n return (o.address === p);\n } else {\n for (const k in o) {\n if (FaustPolyWebAudioDsp.findPath(o[k], p)) return true;\n }\n return false;\n }\n }\n\n setParamValue(path: string, value: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"param\", data: { path, value } });\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);\n } else {\n this.fVoiceTable.forEach(voice => voice.setParamValue(this.fPathTable[path], value));\n }\n }\n getParamValue(path: string) {\n if (this.fJSONEffect && FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {\n return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);\n } else {\n return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);\n }\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n\n getDescriptors() { return this.fDescriptor; }\n\n midiMessage(data: number[] | Uint8Array) {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 8 || (cmd === 9 && data2 === 0)) return this.keyOff(channel, data1, data2);\n else if (cmd === 9) return this.keyOn(channel, data1, data2);\n else super.midiMessage(data);\n };\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n if (ctrl === 123 || ctrl === 120) {\n this.allNotesOff(true);\n } else {\n super.ctrlChange(channel, ctrl, value);\n }\n }\n\n keyOn(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOn\", data: [channel, pitch, velocity] });\n const voice = this.getFreeVoice();\n this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n if (this.fPlotHandler) this.fCachedEvents.push({ type: \"keyOff\", data: [channel, pitch, velocity] });\n const voice = this.getPlayingVoice(pitch);\n if (voice !== FaustWebAudioDspVoice.kNoVoice) {\n this.fVoiceTable[voice].keyOff();\n } else {\n console.log(\"Playing pitch = %d not found\\n\", pitch);\n }\n }\n\n allNotesOff(hard: boolean = true) {\n this.fCachedEvents.push({ type: \"ctrlChange\", data: [0, 123, 0] });\n this.fVoiceTable.forEach(voice => voice.keyOff(hard));\n }\n}\n", "import { ComputeHandler, FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\nimport { AudioParamDescriptor, FaustUIItem } from \"./types\";\n\n/**\n * For offline rendering.\n */\nexport interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {\n render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];\n}\n\nexport interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }\nexport interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }\n\nexport class FaustOfflineProcessor {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n protected fBufferSize: number;\n protected fInputs: Float32Array[];\n protected fOutputs: Float32Array[];\n\n constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number) {\n this.fDSPCode = instance;\n this.fBufferSize = bufferSize;\n this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));\n }\n\n // Public API\n\n getParameterDescriptors() {\n const params = [] as AudioParamDescriptor[];\n // Analyse voice JSON to generate AudioParam parameters\n const callback = (item: FaustUIItem) => {\n let param: AudioParamDescriptor | null = null;\n const polyKeywords = [\"/gate\", \"/freq\", \"/gain\", \"/key\", \"/vel\", \"/velocity\"];\n const isPolyReserved = \"address\" in item && !!polyKeywords.find(k => item.address.endsWith(k));\n if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"nentry\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };\n } else if (item.type === \"button\" || item.type === \"checkbox\") {\n param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };\n }\n }\n if (param) params.push(param);\n }\n FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);\n return params;\n }\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n\n /**\n * Render frames in an array.\n *\n * @param inputs - input signal\n * @param length - the number of frames to render (default: bufferSize)\n * @param onUpdate - a callback after each buffer calculated, with an argument \"current sample\"\n * @return an array of Float32Array with the rendered frames\n */\n render(inputs: Float32Array[] = [], length = this.fBufferSize, onUpdate?: (sample: number) => any): Float32Array[] {\n let l = 0;\n const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));\n // The node has to be started before rendering\n this.fDSPCode.start();\n while (l < length) {\n const sliceLength = Math.min(length - l, this.fBufferSize);\n for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {\n let input: Float32Array;\n if (inputs[i]) {\n if (inputs[i].length <= l) {\n input = new Float32Array(sliceLength);\n } else if (inputs[i].length > l + sliceLength) {\n input = inputs[i].subarray(l, l + sliceLength);\n } else {\n input = inputs[i].subarray(l, inputs[i].length);\n }\n } else {\n input = new Float32Array(sliceLength);\n }\n this.fInputs[i] = input;\n }\n this.fDSPCode.compute(this.fInputs, this.fOutputs);\n for (let i = 0; i < this.fDSPCode.getNumOutputs(); i++) {\n const output = this.fOutputs[i];\n if (sliceLength < this.fBufferSize) {\n outputs[i].set(output.subarray(0, sliceLength), l);\n } else {\n outputs[i].set(output, l);\n }\n }\n l += this.fBufferSize;\n onUpdate?.(l);\n }\n // The node can be stopped after rendering\n this.fDSPCode.stop();\n return outputs;\n }\n}\n\nexport class FaustMonoOfflineProcessor extends FaustOfflineProcessor implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyOfflineProcessor extends FaustOfflineProcessor implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n\nexport default FaustOfflineProcessor;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustSvgDiagrams {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the svg diagrams as a filename - svg string map\n */\n from(name: string, code: string, args: string): Record;\n}\n\nclass FaustSvgDiagrams implements IFaustSvgDiagrams {\n private compiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.compiler = compiler;\n }\n\n from(name: string, code: string, args: string) {\n const fs = this.compiler.fs();\n try {\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => fs.unlink(`/${name}-svg/${file}`));\n } catch { }\n const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);\n if (!success) throw new Error(this.compiler.getErrorMessage());\n const svgs: Record = {};\n const files: string[] = fs.readdir(`/${name}-svg/`);\n files.filter(file => file !== \".\" && file !== \"..\").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: \"utf8\" }) as string);\n return svgs;\n }\n}\n\nexport default FaustSvgDiagrams;\n", "import type FaustCompiler from \"./FaustCompiler\";\n\ninterface IFaustCmajor {\n /**\n * Generates auxiliary files from Faust code. The output depends on the compiler options.\n *\n * @param name - the DSP's name\n * @param code - Faust code\n * @param args - compilation args\n * @returns the Cmajor compiled string\n */\n compile(name: string, code: string, args: string): string;\n}\n\nclass FaustCmajor implements IFaustCmajor {\n private fCompiler: FaustCompiler;\n\n constructor(compiler: FaustCompiler) {\n this.fCompiler = compiler;\n }\n\n compile(name: string, code: string, args: string) {\n const fs = this.fCompiler.fs();\n const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);\n return (success) ? fs.readFile(`${name}.cmajor`, { encoding: \"utf8\" }) as string : \"\";\n }\n}\n\nexport default FaustCmajor;\n", "import type { FaustModule, LibFaustWasm, FaustInfoType } from \"./types\";\n\nexport interface ILibFaust extends LibFaustWasm {\n module(): FaustModule;\n fs(): typeof FS;\n}\n\nclass LibFaust implements ILibFaust {\n private fModule: FaustModule;\n private fCompiler: LibFaustWasm;\n private fFileSystem: typeof FS;\n\n constructor(module: FaustModule) {\n this.fModule = module;\n this.fCompiler = new module.libFaustWasm();\n this.fFileSystem = this.fModule.FS;\n }\n module() {\n return this.fModule;\n }\n fs() {\n return this.fFileSystem;\n }\n version() {\n return this.fCompiler.version();\n }\n createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean) {\n return this.fCompiler.createDSPFactory(name, code, args, useInternalMemory);\n }\n deleteDSPFactory(cFactory: number) {\n return this.fCompiler.deleteDSPFactory(cFactory);\n }\n expandDSP(name: string, code: string, args: string) {\n return this.fCompiler.expandDSP(name, code, args);\n }\n generateAuxFiles(name: string, code: string, args: string) {\n return this.fCompiler.generateAuxFiles(name, code, args);\n }\n deleteAllDSPFactories() {\n return this.fCompiler.deleteAllDSPFactories();\n }\n getErrorAfterException() {\n return this.fCompiler.getErrorAfterException();\n }\n cleanupAfterException() {\n return this.fCompiler.cleanupAfterException();\n }\n getInfos(what: FaustInfoType) {\n return this.fCompiler.getInfos(what);\n }\n toString() {\n return `LibFaust module: ${this.fModule}, compiler: ${this.fCompiler}`;\n }\n\n}\n\nexport default LibFaust;\n", "export interface WavEncoderOptions {\n bitDepth: number;\n float?: boolean;\n symmetric?: boolean;\n shared?: boolean;\n sampleRate: number;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n symmetric: boolean;\n numberOfChannels: number;\n sampleRate: number;\n length: number;\n bitDepth: number;\n byteDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-encoder\n */\nclass WavEncoder {\n static encode(audioBuffer: Float32Array[], options: WavEncoderOptions) {\n const numberOfChannels = audioBuffer.length;\n const length = audioBuffer[0].length;\n const { shared, float } = options;\n const bitDepth = float ? 32 : ((options.bitDepth | 0) || 16);\n const byteDepth = bitDepth >> 3;\n const byteLength = length * numberOfChannels * byteDepth;\n // eslint-disable-next-line no-undef\n const AB = shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);\n const dataView = new DataView(ab);\n const writer = new Writer(dataView);\n const format: Format = {\n formatId: float ? 0x0003 : 0x0001,\n float: !!float,\n numberOfChannels,\n sampleRate: options.sampleRate,\n symmetric: !!options.symmetric,\n length,\n bitDepth,\n byteDepth\n };\n this.writeHeader(writer, format);\n this.writeData(writer, audioBuffer, format);\n return ab;\n }\n private static writeHeader(writer: Writer, format: Format) {\n const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;\n writer.string(\"RIFF\");\n writer.uint32(writer.dataView.byteLength - 8);\n writer.string(\"WAVE\");\n writer.string(\"fmt \");\n writer.uint32(16);\n writer.uint16(formatId);\n writer.uint16(numberOfChannels);\n writer.uint32(sampleRate);\n writer.uint32(sampleRate * numberOfChannels * byteDepth);\n writer.uint16(numberOfChannels * byteDepth);\n writer.uint16(bitDepth);\n writer.string(\"data\");\n writer.uint32(length * numberOfChannels * byteDepth);\n return writer.pos;\n }\n private static writeData(writer: Writer, audioBuffer: Float32Array[], format: Format) {\n const { bitDepth, float, length, numberOfChannels, symmetric } = format;\n if (bitDepth === 32 && float) {\n const { dataView, pos } = writer;\n const ab = dataView.buffer;\n const f32View = new Float32Array(ab, pos);\n if (numberOfChannels === 1) {\n f32View.set(audioBuffer[0]);\n return;\n }\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const channel = audioBuffer[ch];\n for (let i = 0; i < length; i++) {\n f32View[i * numberOfChannels + ch] = channel[i];\n }\n }\n return;\n }\n const encoderOption = float ? \"f\" : symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + encoderOption;\n\n if (!(writer as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + bitDepth);\n }\n\n const write: (value: number) => void = (writer as any)[methodName].bind(writer);\n\n for (let i = 0; i < length; i++) {\n for (let j = 0; j < numberOfChannels; j++) {\n write(audioBuffer[j][i]);\n }\n }\n }\n}\n\nclass Writer {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n int16(value: number) {\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n uint16(value: number) {\n this.dataView.setUint16(this.pos, value, true);\n this.pos += 2;\n }\n uint32(value: number) {\n this.dataView.setUint32(this.pos, value, true);\n this.pos += 4;\n }\n string(value: string) {\n for (let i = 0, imax = value.length; i < imax; i++) {\n this.dataView.setUint8(this.pos++, value.charCodeAt(i));\n }\n }\n pcm8(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = (value * 0.5 + 0.5) * 255;\n value = Math.round(value) | 0;\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm8s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 128) + 128;\n value = Math.max(0, Math.min(value, 255));\n this.dataView.setUint8(this.pos, value/* , true*/);\n this.pos += 1;\n }\n pcm16(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 32768 : value * 32767;\n value = Math.round(value) | 0;\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm16s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 32768);\n value = Math.max(-32768, Math.min(value, 32767));\n this.dataView.setInt16(this.pos, value, true);\n this.pos += 2;\n }\n pcm24(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? 0x1000000 + value * 8388608 : value * 8388607;\n value = Math.round(value) | 0;\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm24s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 8388608);\n value = Math.max(-8388608, Math.min(value, 8388607));\n\n const x0 = (value >> 0) & 0xFF;\n const x1 = (value >> 8) & 0xFF;\n const x2 = (value >> 16) & 0xFF;\n\n this.dataView.setUint8(this.pos + 0, x0);\n this.dataView.setUint8(this.pos + 1, x1);\n this.dataView.setUint8(this.pos + 2, x2);\n this.pos += 3;\n }\n pcm32(valueIn: number) {\n let value = valueIn;\n value = Math.max(-1, Math.min(value, +1));\n value = value < 0 ? value * 2147483648 : value * 2147483647;\n value = Math.round(value) | 0;\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32s(valueIn: number) {\n let value = valueIn;\n value = Math.round(value * 2147483648);\n value = Math.max(-2147483648, Math.min(value, +2147483647));\n this.dataView.setInt32(this.pos, value, true);\n this.pos += 4;\n }\n pcm32f(value: number) {\n this.dataView.setFloat32(this.pos, value, true);\n this.pos += 4;\n }\n}\n\nexport default WavEncoder;\n", "export interface WavDecoderOptions {\n symmetric?: boolean;\n shared?: boolean;\n}\ninterface Format {\n formatId: number;\n float: boolean;\n numberOfChannels: number;\n sampleRate: number;\n byteRate: number;\n blockSize: number;\n bitDepth: number;\n}\n\n/**\n * Code from https://github.com/mohayonao/wav-decoder\n */\nclass WavDecoder {\n static decode(buffer: ArrayBuffer, options?: WavDecoderOptions) {\n const dataView = new DataView(buffer);\n const reader = new Reader(dataView);\n if (reader.string(4) !== \"RIFF\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n reader.uint32(); // skip file length\n if (reader.string(4) !== \"WAVE\") {\n throw new TypeError(\"Invalid WAV file\");\n }\n let format: Format | null = null;\n let audioData: {\n numberOfChannels: number;\n length: number;\n sampleRate: number;\n channelData: Float32Array[];\n } | null = null;\n do {\n const chunkType = reader.string(4);\n const chunkSize = reader.uint32();\n if (chunkType === \"fmt \") {\n format = this.decodeFormat(reader, chunkSize);\n } else if (chunkType === \"data\") {\n audioData = this.decodeData(reader, chunkSize, format as Format, options || {});\n } else {\n reader.skip(chunkSize);\n }\n } while (audioData === null);\n return audioData;\n }\n private static decodeFormat(reader: Reader, chunkSize: number) {\n const formats = {\n 0x0001: \"lpcm\",\n 0x0003: \"lpcm\"\n };\n const formatId = reader.uint16();\n if (!formats.hasOwnProperty(formatId)) {\n throw new TypeError(\"Unsupported format in WAV file: 0x\" + formatId.toString(16));\n }\n const format: Format = {\n formatId: formatId,\n float: formatId === 0x0003,\n numberOfChannels: reader.uint16(),\n sampleRate: reader.uint32(),\n byteRate: reader.uint32(),\n blockSize: reader.uint16(),\n bitDepth: reader.uint16()\n };\n reader.skip(chunkSize - 16);\n return format;\n }\n private static decodeData(reader: Reader, chunkSizeIn: number, format: Format, options: WavDecoderOptions) {\n const chunkSize = Math.min(chunkSizeIn, reader.remain());\n const length = Math.floor(chunkSize / format.blockSize);\n const numberOfChannels = format.numberOfChannels;\n const sampleRate = format.sampleRate;\n const channelData: Float32Array[] = new Array(numberOfChannels);\n for (let ch = 0; ch < numberOfChannels; ch++) {\n const AB = options.shared ? (globalThis.SharedArrayBuffer || globalThis.ArrayBuffer) : globalThis.ArrayBuffer;\n const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);\n channelData[ch] = new Float32Array(ab);\n }\n this.readPCM(reader, channelData, length, format, options);\n return {\n numberOfChannels,\n length,\n sampleRate,\n channelData\n };\n }\n private static readPCM(reader: Reader, channelData: Float32Array[], length: number, format: Format, options: WavDecoderOptions) {\n const bitDepth = format.bitDepth;\n const decoderOption = format.float ? \"f\" : options.symmetric ? \"s\" : \"\";\n const methodName = \"pcm\" + bitDepth + decoderOption as `pcm${8 | 16 | 32}${\"f\" | \"s\" | \"\"}`;\n if (!(reader as any)[methodName]) {\n throw new TypeError(\"Not supported bit depth: \" + format.bitDepth);\n }\n const read: () => number = (reader as any)[methodName].bind(reader);\n const numberOfChannels = format.numberOfChannels;\n for (let i = 0; i < length; i++) {\n for (let ch = 0; ch < numberOfChannels; ch++) {\n channelData[ch][i] = read();\n }\n }\n }\n}\n\nclass Reader {\n pos = 0;\n dataView: DataView;\n constructor(dataView: DataView) {\n this.dataView = dataView;\n }\n remain() {\n return this.dataView.byteLength - this.pos;\n }\n skip(n: number) {\n this.pos += n;\n }\n uint8() {\n const data = this.dataView.getUint8(this.pos);\n this.pos += 1;\n return data;\n }\n int16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint16() {\n const data = this.dataView.getUint16(this.pos, true);\n this.pos += 2;\n return data;\n }\n uint32() {\n const data = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return data;\n }\n string(n: number) {\n let data = \"\";\n for (let i = 0; i < n; i++) {\n data += String.fromCharCode(this.uint8());\n }\n return data;\n }\n pcm8() {\n const data = this.dataView.getUint8(this.pos) - 128;\n this.pos += 1;\n return data < 0 ? data / 128 : data / 127;\n }\n pcm8s() {\n const data = this.dataView.getUint8(this.pos) - 127.5;\n this.pos += 1;\n return data / 127.5;\n }\n pcm16() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data < 0 ? data / 32768 : data / 32767;\n }\n pcm16s() {\n const data = this.dataView.getInt16(this.pos, true);\n this.pos += 2;\n return data / 32768;\n }\n pcm24() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data < 0 ? data / 8388608 : data / 8388607;\n }\n pcm24s() {\n const x0 = this.dataView.getUint8(this.pos + 0);\n const x1 = this.dataView.getUint8(this.pos + 1);\n const x2 = this.dataView.getUint8(this.pos + 2);\n const xx = (x0 + (x1 << 8) + (x2 << 16));\n\n const data = xx > 0x800000 ? xx - 0x1000000 : xx;\n this.pos += 3;\n return data / 8388608;\n }\n pcm32() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data < 0 ? data / 2147483648 : data / 2147483647;\n }\n pcm32s() {\n const data = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return data / 2147483648;\n }\n pcm32f() {\n const data = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return data;\n }\n pcm64f() {\n const data = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return data;\n }\n}\n\nexport default WavDecoder;\n", "import { FaustBaseWebAudioDsp } from \"./FaustWebAudioDsp\";\r\nimport type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from \"./types\";\r\n\r\n/** Read metadata and fetch soundfiles */\r\nclass SoundfileReader {\r\n\r\n // Set the fallback paths\r\n static get fallbackPaths() { return [location.href, this.getParentUrl(location.href), location.origin]; }\r\n\r\n /**\r\n * Extract the parent URL from an URL.\r\n * @param url : the URL\r\n * @returns : the parent URL\r\n */\r\n private static getParentUrl(url: string) {\r\n return url.substring(0, url.lastIndexOf('/') + 1);\r\n }\r\n\r\n /**\r\n * Convert an audio buffer to audio data.\r\n * \r\n * @param audioBuffer : the audio buffer to convert\r\n * @returns : the audio data\r\n */\r\n private static toAudioData(audioBuffer: AudioBuffer): AudioData {\r\n const { sampleRate, numberOfChannels } = audioBuffer;\r\n return {\r\n sampleRate,\r\n audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))\r\n } as AudioData;\r\n }\r\n\r\n /**\r\n * Extract the URLs from the metadata.\r\n * \r\n * @param dspMeta : the metadata\r\n * @returns : the URLs\r\n */\r\n static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory[\"soundfiles\"] {\r\n const soundfiles: LooseFaustDspFactory[\"soundfiles\"] = {};\r\n const callback = (item: FaustUIItem) => {\r\n if (item.type === \"soundfile\") {\r\n const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);\r\n // soundfiles.map[item.label] = urls;\r\n urls.forEach(url => soundfiles[url] = null);\r\n }\r\n };\r\n FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);\r\n return soundfiles;\r\n }\r\n /**\r\n * Check if the file exists.\r\n * \r\n * @param url : the url of the file to check\r\n * @returns : true if the file exists, otherwise false\r\n */\r\n private static async checkFileExists(url: string): Promise {\r\n try {\r\n console.log(`\"checkFileExists\" url: ${url}`);\r\n // Fetch in \"HEAD\" mode does not properly work with the service-worker.js cache, so use \"GET\" mode for now\r\n //const response = await fetch(url, { method: \"HEAD\" });\r\n const response = await fetch(url);\r\n console.log(`\"checkFileExists\" response.ok: ${response.ok}`);\r\n return response.ok; // Will be true if the status code is 200-299\r\n } catch (error) {\r\n console.error('Fetch error:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Fetch the soundfile.\r\n * \r\n * @param url : the url of the soundfile\r\n * @param audioCtx : the audio context\r\n * @returns : the audio data\r\n */\r\n private static async fetchSoundfile(url: string, audioCtx: BaseAudioContext): Promise {\r\n console.log(`Loading sound file from ${url}`);\r\n const response = await fetch(url);\r\n if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);\r\n // Decode the audio data\r\n const arrayBuffer = await response.arrayBuffer();\r\n const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);\r\n return this.toAudioData(audioBuffer);\r\n }\r\n\r\n /**\r\n * Load the soundfile.\r\n * \r\n * @param filename : the filename\r\n * @param metaUrls : the metadata URLs\r\n * @param soundfiles : the soundfiles\r\n * @param audioCtx : the audio context\r\n */\r\n private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n if (soundfiles[filename]) return;\r\n const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith(\"/\") ? path : `${path}/`).href)];\r\n const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));\r\n const successIndex = checkResults.findIndex(r => !!r);\r\n if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);\r\n soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);\r\n }\r\n\r\n /**\r\n * Load the soundfiles, public API.\r\n * \r\n * @param dspMeta : the metadata\r\n * @param soundfilesIn : the soundfiles\r\n * @param audioCtx : the audio context\r\n * @returns : the soundfiles\r\n */\r\n static async loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory[\"soundfiles\"], audioCtx: BaseAudioContext): Promise {\r\n const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);\r\n const soundfiles = this.findSoundfilesFromMeta(dspMeta);\r\n for (const id in soundfiles) {\r\n if (soundfilesIn[id]) {\r\n soundfiles[id] = soundfilesIn[id];\r\n continue;\r\n }\r\n try {\r\n await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n }\r\n return soundfiles;\r\n }\r\n}\r\n\r\nexport default SoundfileReader;\r\n", "import { OutputParamHandler, ComputeHandler, PlotHandler, UIHandler, MetadataHandler, FaustBaseWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp } from \"./FaustWebAudioDsp\";\nimport type { FaustAudioWorkletNodeOptions } from \"./FaustAudioWorkletProcessor\";\nimport type { LooseFaustDspFactory, FaustDspMeta, FaustUIInputItem, FaustUIItem } from \"./types\";\n\n/**\n * Base class for Monophonic and Polyphonic AudioWorkletNode\n */\nexport class FaustAudioWorkletNode extends (globalThis.AudioWorkletNode || null) {\n\n protected fJSONDsp: FaustDspMeta;\n protected fJSON: string;\n protected fInputsItems: string[];\n protected fOutputHandler: OutputParamHandler | null;\n protected fComputeHandler: ComputeHandler | null;\n protected fPlotHandler: PlotHandler | null;\n protected fUICallback: UIHandler;\n protected fDescriptor: FaustUIInputItem[];\n #hasAccInput = false;\n #hasGyrInput = false;\n\n constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: Partial> = {}) {\n\n // Create JSON object\n const JSONObj: FaustDspMeta = JSON.parse(factory.json);\n\n // Create proxy FaustAudioWorkletProcessor\n super(context, name, {\n numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,\n numberOfOutputs: JSONObj.outputs > 0 ? 1 : 0,\n channelCount: Math.max(1, JSONObj.inputs),\n outputChannelCount: [JSONObj.outputs],\n channelCountMode: \"explicit\",\n channelInterpretation: \"speakers\",\n processorOptions: options.processorOptions,\n ...options\n });\n\n this.fJSONDsp = JSONObj;\n this.fJSON = factory.json;\n this.fOutputHandler = null;\n this.fComputeHandler = null;\n this.fPlotHandler = null;\n this.fDescriptor = [];\n\n // Parse UI\n this.fInputsItems = [];\n this.fUICallback = (item: FaustUIItem) => {\n if (item.type === \"vslider\" || item.type === \"hslider\" || item.type === \"button\" || item.type === \"checkbox\" || item.type === \"nentry\") {\n // Keep inputs adresses\n this.fInputsItems.push(item.address);\n this.fDescriptor.push(item);\n if (!item.meta) return;\n item.meta.forEach((meta) => {\n const { midi, acc, gyr } = meta;\n if (acc) this.#hasAccInput = true;\n if (gyr) this.#hasGyrInput = true;\n });\n }\n }\n\n FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);\n\n // Patch it with additional functions\n this.port.onmessage = (e: MessageEvent) => {\n if (e.data.type === \"param\" && this.fOutputHandler) {\n this.fOutputHandler(e.data.path, e.data.value);\n } else if (e.data.type === \"plot\" && this.fPlotHandler) {\n this.fPlotHandler(e.data.value, e.data.index, e.data.events);\n }\n };\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the accelerometer.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response === \"granted\") {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } else if (response === \"denied\") {\n alert('You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.');\n throw new Error(\"Unable to access the gyroscope.\");\n }\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n setOutputParamHandler(handler: OutputParamHandler | null) {\n this.fOutputHandler = handler;\n }\n getOutputParamHandler() {\n return this.fOutputHandler;\n }\n\n setComputeHandler(handler: ComputeHandler | null) {\n this.fComputeHandler = handler;\n }\n getComputeHandler(): ComputeHandler | null {\n return this.fComputeHandler;\n }\n\n setPlotHandler(handler: PlotHandler | null) {\n this.fPlotHandler = handler;\n // Set PlotHandler on processor side\n if (this.fPlotHandler) {\n this.port.postMessage({ type: \"setPlotHandler\", data: true });\n } else {\n this.port.postMessage({ type: \"setPlotHandler\", data: false });\n }\n }\n getPlotHandler(): PlotHandler | null {\n return this.fPlotHandler;\n }\n setupWamEventHandler() {\n this.port.postMessage({ type: \"setupWamEventHandler\" });\n }\n\n getNumInputs() {\n return this.fJSONDsp.inputs;\n }\n getNumOutputs() {\n return this.fJSONDsp.outputs;\n }\n\n // Implemented in subclasses\n compute(inputs: Float32Array[], outputs: Float32Array[]) {\n return false;\n }\n\n metadata(handler: MetadataHandler) {\n if (this.fJSONDsp.meta) {\n this.fJSONDsp.meta.forEach(meta => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));\n }\n }\n\n midiMessage(data: number[] | Uint8Array): void {\n const cmd = data[0] >> 4;\n const channel = data[0] & 0xf;\n const data1 = data[1];\n const data2 = data[2];\n if (cmd === 11) this.ctrlChange(channel, data1, data2);\n else if (cmd === 14) this.pitchWheel(channel, data2 * 128.0 + data1);\n else this.port.postMessage({ type: \"midi\", data: data });\n }\n\n ctrlChange(channel: number, ctrl: number, value: number) {\n const e = { type: \"ctrlChange\", data: [channel, ctrl, value] };\n this.port.postMessage(e);\n }\n pitchWheel(channel: number, wheel: number) {\n const e = { type: \"pitchWheel\", data: [channel, wheel] };\n this.port.postMessage(e);\n }\n\n get hasAccInput() { return this.#hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n if (!accelerationIncludingGravity) return;\n const e = { type: \"acc\", data: accelerationIncludingGravity, invert: invert };\n this.port.postMessage(e);\n }\n\n get hasGyrInput() { return this.#hasGyrInput; }\n propagateGyr(event: Pick) {\n if (!event) return;\n const e = { type: \"gyr\", data: event };\n this.port.postMessage(e);\n }\n\n setParamValue(path: string, value: number) {\n const e = { type: \"param\", data: { path, value } };\n this.port.postMessage(e);\n // Set value on AudioParam (but this is not used on Processor side for now)\n const param = this.parameters.get(path);\n if (param) param.setValueAtTime(value, this.context.currentTime);\n\n }\n getParamValue(path: string) {\n // Get value of AudioParam\n const param = this.parameters.get(path);\n return (param) ? param.value : 0;\n }\n\n getParams() { return this.fInputsItems; }\n getMeta() { return this.fJSONDsp; }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.fJSONDsp.ui; }\n getDescriptors() { return this.fDescriptor; }\n\n start() {\n this.port.postMessage({ type: \"start\" });\n }\n\n stop() {\n this.port.postMessage({ type: \"stop\" });\n }\n\n destroy() {\n this.port.postMessage({ type: \"destroy\" });\n this.port.close();\n }\n}\n\n/**\n * Monophonic AudioWorkletNode\n */\nexport class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode implements IFaustMonoWebAudioDsp {\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustMonoAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n super(context, options.processorOptions.name, options.processorOptions.factory, options);\n }\n}\n\n/**\n * Polyphonic AudioWorkletNode\n */\nexport class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode implements IFaustPolyWebAudioDsp {\n\n private fJSONEffect: FaustDspMeta | null;\n\n onprocessorerror = (e: Event) => {\n // console.error(\"Error from \" + this.fJSONDsp.name + \" FaustPolyAudioWorkletNode\");\n throw e;\n }\n\n constructor(context: BaseAudioContext, options: Partial> & Pick, \"processorOptions\">) {\n\n super(\n context,\n options.processorOptions.name,\n options.processorOptions.voiceFactory,\n options\n );\n\n this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;\n\n if (this.fJSONEffect) {\n FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);\n }\n }\n\n // Public API\n keyOn(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOn\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n keyOff(channel: number, pitch: number, velocity: number) {\n const e = { type: \"keyOff\", data: [channel, pitch, velocity] };\n this.port.postMessage(e);\n }\n\n allNotesOff(hard: boolean) {\n const e = { type: \"ctrlChange\", data: [0, 123, 0] };\n this.port.postMessage(e);\n }\n\n getMeta() {\n const o = this.fJSONDsp;\n const e = this.fJSONEffect;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n", "import type { ComputeHandler, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, IFaustMonoWebAudioDsp, IFaustPolyWebAudioDsp, MetadataHandler, OutputParamHandler, PlotHandler } from \"./FaustWebAudioDsp\";\n\n/**\n * Base class for Monophonic and Polyphonic ScriptProcessorNode\n */\nexport class FaustScriptProcessorNode extends (globalThis.ScriptProcessorNode || null) {\n protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;\n\n // Needed for ScriptProcessorNode\n protected fInputs!: Float32Array[];\n protected fOutputs!: Float32Array[];\n\n init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp) {\n this.fDSPCode = instance;\n\n this.fInputs = new Array(this.fDSPCode.getNumInputs());\n this.fOutputs = new Array(this.fDSPCode.getNumOutputs());\n\n this.onaudioprocess = (e) => {\n\n // Read inputs\n for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {\n this.fInputs[chan] = e.inputBuffer.getChannelData(chan);\n }\n\n // Read outputs\n for (let chan = 0; chan < this.fDSPCode.getNumOutputs(); chan++) {\n this.fOutputs[chan] = e.outputBuffer.getChannelData(chan);\n }\n\n return this.fDSPCode.compute(this.fInputs, this.fOutputs);\n }\n\n this.start();\n }\n\n // Public API\n\n // Accelerometer and gyroscope handlers\n private handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {\n const isAndroid: boolean = /Android/i.test(navigator.userAgent);\n if (!accelerationIncludingGravity) return;\n const { x, y, z } = accelerationIncludingGravity;\n this.propagateAcc({ x, y, z }, isAndroid);\n };\n\n private handleDeviceOrientation = ({ alpha, beta, gamma }: DeviceOrientationEvent) => {\n this.propagateGyr({ alpha, beta, gamma });\n };\n\n /** Setup accelerometer and gyroscope handlers */\n async startSensors() {\n if (this.hasAccInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceMotionEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceMotionEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the accelerometer.\");\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the accelerometer handler.\");\n }\n }\n if (this.hasGyrInput) {\n if (window.DeviceMotionEvent) {\n if (typeof (window.DeviceOrientationEvent as any).requestPermission === \"function\") { // for iOS 13+\n try {\n const response = await (window.DeviceOrientationEvent as any).requestPermission();\n if (response !== \"granted\") throw new Error(\"Unable to access the gyroscope.\");\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n } catch (error) {\n console.error(error);\n }\n } else {\n window.addEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n } else {\n // Browser doesn't support DeviceMotionEvent\n console.log(\"Cannot set the gyroscope handler.\");\n }\n }\n }\n\n stopSensors() {\n if (this.hasAccInput) {\n window.removeEventListener(\"devicemotion\", this.handleDeviceMotion, true);\n }\n if (this.hasGyrInput) {\n window.removeEventListener(\"deviceorientation\", this.handleDeviceOrientation, true);\n }\n }\n\n compute(input: Float32Array[], output: Float32Array[]) { return this.fDSPCode.compute(input, output); }\n\n setOutputParamHandler(handler: OutputParamHandler) { this.fDSPCode.setOutputParamHandler(handler); }\n getOutputParamHandler() { return this.fDSPCode.getOutputParamHandler(); }\n\n setComputeHandler(handler: ComputeHandler) { this.fDSPCode.setComputeHandler(handler); }\n getComputeHandler() { return this.fDSPCode.getComputeHandler(); }\n\n setPlotHandler(handler: PlotHandler) { this.fDSPCode.setPlotHandler(handler); }\n getPlotHandler() { return this.fDSPCode.getPlotHandler(); }\n\n getNumInputs() { return this.fDSPCode.getNumInputs(); }\n getNumOutputs() { return this.fDSPCode.getNumOutputs(); }\n\n metadata(handler: MetadataHandler) { }\n\n midiMessage(data: number[] | Uint8Array) { this.fDSPCode.midiMessage(data); }\n\n ctrlChange(chan: number, ctrl: number, value: number) { this.fDSPCode.ctrlChange(chan, ctrl, value); }\n pitchWheel(chan: number, value: number) { this.fDSPCode.pitchWheel(chan, value); }\n\n setParamValue(path: string, value: number) { this.fDSPCode.setParamValue(path, value); }\n getParamValue(path: string) { return this.fDSPCode.getParamValue(path); }\n getParams() { return this.fDSPCode.getParams(); }\n\n getMeta() { return this.fDSPCode.getMeta(); }\n getJSON() { return this.fDSPCode.getJSON(); }\n getDescriptors() { return this.fDSPCode.getDescriptors(); }\n getUI() { return this.fDSPCode.getUI(); }\n\n start() { this.fDSPCode.start(); }\n stop() { this.fDSPCode.stop(); }\n\n destroy() { this.fDSPCode.destroy(); }\n\n get hasAccInput() { return this.fDSPCode.hasAccInput; }\n propagateAcc(accelerationIncludingGravity: NonNullable, invert: boolean = false) {\n this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);\n }\n\n get hasGyrInput() { return this.fDSPCode.hasGyrInput; }\n propagateGyr(event: Pick) {\n this.fDSPCode.propagateGyr(event);\n }\n}\n\nexport class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode implements IFaustMonoWebAudioDsp {\n}\n\nexport class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode implements IFaustPolyWebAudioDsp {\n keyOn(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOn(channel, pitch, velocity); }\n keyOff(channel: number, pitch: number, velocity: number) { this.fDSPCode.keyOff(channel, pitch, velocity); }\n allNotesOff(hard: boolean) { this.fDSPCode.allNotesOff(hard); }\n}\n", "import { FaustMonoAudioWorkletNode, FaustPolyAudioWorkletNode } from \"./FaustAudioWorkletNode\";\nimport getFaustAudioWorkletProcessor, { FaustData } from \"./FaustAudioWorkletProcessor\";\nimport getFaustFFTAudioWorkletProcessor, { FaustFFTData, FaustFFTOptionsData } from \"./FaustFFTAudioWorkletProcessor\";\nimport { FaustDspInstance } from \"./FaustDspInstance\";\nimport FaustWasmInstantiator from \"./FaustWasmInstantiator\";\nimport { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOfflineProcessor, IFaustPolyOfflineProcessor } from \"./FaustOfflineProcessor\";\nimport { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from \"./FaustScriptProcessorNode\";\nimport { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from \"./FaustWebAudioDsp\";\nimport SoundfileReader from \"./SoundfileReader\";\nimport FaustSensors from \"./FaustSensors\";\nimport type { IFaustCompiler } from \"./FaustCompiler\";\nimport type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from \"./types\";\n\n\nexport interface GeneratorSupportingSoundfiles {\n /**\n * Attach a map of id - audio data, call after `compile()` before `createNode()`\n * \n * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`\n */\n addSoundfiles(soundfileMap: Record): void;\n\n /**\n * Get a list of soundfiles needed, call after `compile()`\n */\n getSoundfileList(): string[];\n}\n\nexport interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param code - the DSP code\n * @param args - the compilation parameters\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{\n factory: FaustDspFactory | null;\n name?: string;\n meta?: FaustDspMeta;\n } | null>;\n\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n name?: string,\n factory?: LooseFaustDspFactory,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context - the WebAudio context\n * @param fftUtils - should be an anonymous class with static methods, without any import from outside\n * @param name - DSP name, can be used for processorName\n * @param factory - default is the compiled factory\n * @param fftOptions - initial FFT options\n * @param processorName - AudioWorklet Processor name\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name?: string,\n factory?: LooseFaustDspFactory,\n fftOptions?: Partial,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param factory - default is the compiled factory\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory?: LooseFaustDspFactory,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {\n /**\n * Compile a monophonic DSP factory from given code.\n * \n * @param compiler - the Faust compiler\n * @param name - the DSP name\n * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)\n * @param args - the compilation parameters\n * @param effectCode - optional effect DSP code\n * @returns the compiled factory or 'null' if failure\n */\n compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{\n voiceFactory: FaustDspFactory | null;\n effectFactory?: FaustDspFactory | null;\n } | null>;\n\n /**\n * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).\n *\n * @param context the WebAudio context\n * @param voices - the number of voices\n * @param name - AudioWorklet Processor name\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode\n * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames\n * @param processorOptions - Additional AudioWorklet Processor options\n * @returns the compiled WebAudio node or 'null' if failure\n */\n createNode(\n context: BaseAudioContext,\n voices: number,\n name?: string,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n sp?: boolean,\n bufferSize?: number,\n processorName?: string,\n processorOptions?: Record\n ): Promise;\n\n /**\n * Create a monophonic Offline processor.\n *\n * @param sampleRate - the sample rate in Hz\n * @param bufferSize - the buffer size in frames\n * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)\n * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)\n * @param context - if this exists, will be used to fetch soundfiles online\n * @returns the compiled processor or 'null' if failure\n */\n createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory?: LooseFaustDspFactory,\n mixerModule?: WebAssembly.Module,\n effectFactory?: LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ): Promise;\n\n /**\n * Get DSP JSON description with its UI and metadata as object.\n *\n * @return the DSP JSON description as object\n */\n getMeta(): FaustDspMeta;\n\n /**\n * Get DSP JSON description with its UI and metadata.\n *\n * @return the DSP JSON description\n */\n getJSON(): string;\n\n /**\n * Get DSP UI description.\n *\n * @return the DSP UI description\n */\n getUI(): FaustUIDescriptor;\n}\n\nexport class FaustMonoDspGenerator implements IFaustMonoDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n factory!: FaustDspFactory | null;\n\n constructor() {\n this.factory = null;\n }\n async compile(compiler: IFaustCompiler, name: string, code: string, args: string) {\n this.factory = await compiler.createMonoDSPFactory(name, code, args);\n if (this.factory) {\n this.name = name;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.factory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.factory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n return Object.keys(map);\n }\n\n async createNode(\n context: BaseAudioContext,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n sp = false as SP,\n bufferSize = 1024,\n processorName = factory?.shaKey || name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs()) as FaustMonoScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustMonoScriptProcessorNode.prototype);\n sp.init(monoDsp);\n return sp as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n\n return node as SP extends true ? FaustMonoScriptProcessorNode : FaustMonoAudioWorkletNode;\n }\n }\n\n async createFFTNode(\n context: BaseAudioContext,\n fftUtils: typeof FFTUtils,\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n fftOptions: Partial = {},\n processorName = factory?.shaKey ? `${factory.shaKey}_fft` : name,\n processorOptions: Record = {}\n ): Promise {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta: FaustDspMeta = JSON.parse(factory.json);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustMonoDspGenerator.gWorkletProcessors.has(context)) FaustMonoDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustMonoDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: meta,\n fftOptions\n } as FaustFFTData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}\nvar FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\nvar FFTUtils = ${fftUtils.toString()}\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FFTUtils\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustFFTAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustMonoDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });\n if (fftOptions.fftSize) {\n const param = node.parameters.get(\"fftSize\");\n if (param) param.value = fftOptions.fftSize;\n }\n if (fftOptions.fftOverlap) {\n const param = node.parameters.get(\"fftOverlap\");\n if (param) param.value = fftOptions.fftOverlap;\n }\n if (typeof fftOptions.defaultWindowFunction === \"number\") {\n const param = node.parameters.get(\"windowFunction\");\n if (param) param.value = fftOptions.defaultWindowFunction + 1;\n }\n if (typeof fftOptions.noIFFT === \"boolean\") {\n const param = node.parameters.get(\"noIFFT\");\n if (param) param.value = +fftOptions.noIFFT;\n }\n return node;\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n factory = this.factory as LooseFaustDspFactory,\n processorName = factory?.shaKey || name\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp: undefined,\n FaustWebAudioDspVoice: undefined,\n }\n // const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: meta,\n poly: false\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createMonoNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n factory = this.factory as LooseFaustDspFactory,\n context?: BaseAudioContext\n ) {\n if (!factory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const meta = JSON.parse(factory.json);\n const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);\n const sampleSize = meta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);\n const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);\n return new FaustMonoOfflineProcessor(monoDsp, bufferSize);\n }\n\n getMeta() { return JSON.parse(this.factory!.json); }\n getJSON() { return JSON.stringify(this.getMeta()); }\n getUI() { return this.getMeta().ui; }\n}\n\nexport class FaustPolyDspGenerator implements IFaustPolyDspGenerator {\n // Set of all created WorkletProcessors, each of them has to be unique\n private static gWorkletProcessors: Map> = new Map();\n\n name: string;\n voiceFactory!: FaustDspFactory | null;\n effectFactory!: FaustDspFactory | null;\n mixerBuffer!: Uint8Array;\n mixerModule!: WebAssembly.Module;\n\n constructor() {\n this.voiceFactory = null;\n this.effectFactory = null;\n }\n async compile(\n compiler: IFaustCompiler,\n name: string,\n dspCodeAux: string,\n args: string,\n // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile \n effectCodeAux = `dsp_code = environment{\n ${dspCodeAux}\n };\n process = dsp_code.effect;`\n ) {\n // Try to compile effect, possibly failing\n try {\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);\n // Since the effect is processing the same buffers for inputs and outputs (in place processing), \n // the voice and effect are adapted, possibly clearing buffers\n if (this.effectFactory) {\n const effectJSON = JSON.parse(this.effectFactory.json);\n const dspCode = `\\\n// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,\n// so that the effect can process the 2 channels of the voice\nadaptOut(1,1,1) = _;\nadaptOut(1,1,2) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2,1) = _ <: _,_;\nadaptOut(1,2,2) = _ <: _,_;\nadaptOut(2,1,1) = _,_;\nadaptOut(2,1,2) = _,_;\nadaptOut(2,2,1) = _,_;\nadaptOut(2,2,2) = _,_;\nadaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = dsp_code.process : adaptor(dsp_code.process);\n`;\n const effectCode = `\\\n// Inputs\nadaptIn(1,1,1) = _;\nadaptIn(1,1,2) = _,_ :> _; \nadaptIn(1,2,1) = _,_;\nadaptIn(1,2,2) = _,_;\nadaptIn(2,1,1) = _,_ :> _;\nadaptIn(2,1,2) = _,_ :> _;\nadaptIn(2,2,1) = _,_;\nadaptIn(2,2,2) = _,_;\n// Outputs\nadaptOut(1,1) = _ <: _,0; // The left channel only is kept\nadaptOut(1,2) = _,_;\nadaptOut(2,1) = _ <: _,0; // The left channel only is kept\nadaptOut(2,2) = _,_;\nadaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});\nadaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});\ndsp_code = environment{\n ${dspCodeAux}\n};\nprocess = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;\n`;\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);\n try {\n // Effect is processing same buffers for inputs and outputs, so has to use -inpl option\n this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + \" -inpl\");\n } catch (e) {\n console.warn(e);\n }\n }\n } catch (e) {\n console.warn(e);\n this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);\n }\n\n if (this.voiceFactory) {\n this.name = name;\n const voiceMeta = JSON.parse(this.voiceFactory.json);\n const isDouble = voiceMeta.compile_options.match(\"-double\");\n const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);\n this.mixerBuffer = mixerBuffer;\n this.mixerModule = mixerModule;\n return this;\n } else {\n return null;\n }\n }\n\n addSoundfiles(soundfileMap: Record) {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n for (const id in soundfileMap) {\n this.voiceFactory.soundfiles[id] = soundfileMap[id];\n }\n }\n getSoundfileList() {\n if (!this.voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n const meta = JSON.parse(this.voiceFactory.json);\n const map = SoundfileReader.findSoundfilesFromMeta(meta);\n if (!this.effectFactory) return Object.keys(map);\n const effectMeta = JSON.parse(this.effectFactory.json);\n const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);\n return Object.keys({ ...effectMap, ...map });\n }\n\n async createNode(\n context: BaseAudioContext,\n voices: number,\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n sp = false as SP,\n bufferSize = 1024,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`,\n processorOptions = {}\n ): Promise {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n if (sp) {\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);\n\n const sp = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs()) as FaustPolyScriptProcessorNode;\n Object.setPrototypeOf(sp, FaustPolyScriptProcessorNode.prototype);\n sp.init(polyDsp);\n return sp as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n } else {\n // Dynamically create AudioWorkletProcessor if code not yet created\n if (!FaustPolyDspGenerator.gWorkletProcessors.has(context)) FaustPolyDspGenerator.gWorkletProcessors.set(context, new Set());\n if (!FaustPolyDspGenerator.gWorkletProcessors.get(context)?.has(processorName)) {\n try {\n const processorCode = `\n// DSP name and JSON string for DSP are generated\nconst faustData = ${JSON.stringify({\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData)};\n// Implementation needed classes of functions\nvar ${FaustDspInstance.name} = ${FaustDspInstance.toString()}\nvar FaustDspInstance = ${FaustDspInstance.name};\nvar ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}\nvar FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};\nvar ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}\nvar FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};\nvar ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}\nvar FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};\nvar ${FaustWasmInstantiator.name} = ${FaustWasmInstantiator.toString()}\nvar FaustWasmInstantiator = ${FaustWasmInstantiator.name};\nvar ${Soundfile.name} = ${Soundfile.toString()}\nvar Soundfile = ${Soundfile.name};\nvar ${WasmAllocator.name} = ${WasmAllocator.toString()}\nvar WasmAllocator = ${WasmAllocator.name};\nvar ${FaustSensors.name} = ${FaustSensors.toString()}\nvar FaustSensors = ${FaustSensors.name};\n// Put them in dependencies\nconst dependencies = {\n FaustBaseWebAudioDsp,\n FaustPolyWebAudioDsp,\n FaustWasmInstantiator\n};\n// Generate the actual AudioWorkletProcessor code\n(${getFaustAudioWorkletProcessor.toString()})(dependencies, faustData);\n`;\n const url = URL.createObjectURL(new Blob([processorCode], { type: \"text/javascript\" }));\n await context.audioWorklet.addModule(url);\n // Keep the DSP name\n FaustPolyDspGenerator.gWorkletProcessors.get(context)?.add(processorName);\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n // Create the AWN\n const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || undefined, ...processorOptions } });\n\n return node as SP extends true ? FaustPolyScriptProcessorNode : FaustPolyAudioWorkletNode;\n }\n }\n\n async createAudioWorkletProcessor(\n name = this.name,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n processorName = ((voiceFactory?.shaKey || \"\") + (effectFactory?.shaKey || \"\")) || `${name}_poly`\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n // Dynamically create AudioWorkletProcessor if code not yet created\n try {\n const dependencies = {\n FaustBaseWebAudioDsp,\n FaustMonoWebAudioDsp: undefined,\n FaustWasmInstantiator,\n FaustPolyWebAudioDsp,\n FaustWebAudioDspVoice,\n };\n // DSP name and JSON string for DSP are generated\n const faustData = {\n processorName,\n dspName: name,\n dspMeta: voiceMeta,\n poly: true,\n effectMeta\n } as FaustData;\n // Generate the actual AudioWorkletProcessor code\n const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);\n return Processor;\n } catch (e) {\n // console.error(`=> exception raised while running createPolyNode: ${e}`);\n // console.error(`=> check that your page is served using https.${e}`);\n throw e;\n }\n }\n\n async createOfflineProcessor(\n sampleRate: number,\n bufferSize: number,\n voices: number,\n voiceFactory = this.voiceFactory as LooseFaustDspFactory,\n mixerModule = this.mixerModule,\n effectFactory = this.effectFactory as LooseFaustDspFactory | null,\n context?: BaseAudioContext\n ) {\n if (!voiceFactory) throw new Error(\"Code is not compiled, please define the factory or call `await this.compile()` first.\");\n\n const voiceMeta = JSON.parse(voiceFactory.json);\n const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;\n const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);\n const sampleSize = voiceMeta.compile_options.match(\"-double\") ? 8 : 4;\n if (context) {\n voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);\n if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);\n }\n const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };\n const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);\n return new FaustPolyOfflineProcessor(polyDsp, bufferSize);\n }\n\n getMeta() {\n const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;\n const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;\n const r = { ...o };\n if (e) {\n r.ui = [{\n type: \"tgroup\", label: \"Sequencer\", items: [\n { type: \"vgroup\", label: \"Instrument\", items: o.ui },\n { type: \"vgroup\", label: \"Effect\", items: e.ui }\n ]\n }];\n } else {\n r.ui = [{\n type: \"tgroup\", label: \"Polyphonic\", items: [\n { type: \"vgroup\", label: \"Voices\", items: o.ui }\n ]\n }];\n }\n return r as FaustDspMeta;\n }\n\n getJSON() {\n return JSON.stringify(this.getMeta());\n }\n\n getUI() {\n return this.getMeta().ui;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,IAAM,iCAAiC,OAAO,QAAgB,WAAW,OAAO,QAAQ,SAAS,MAAM,GAAG,WAAW,OAAO,QAAQ,SAAS,MAAM,MAAM;AARzJ;AASI,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,UAAU;AAC5B,QAAI,SAAS,OAAO,MAAM,MAAM,MAAM,GAAG,KAAK;AAC9C,aAAS,GAAG,MAAM;AAAA,kBACT,YAAO,MAAM,UAAU,MAAvB,mBAA2B,EAAE;AAAA;AAEtC,UAAM,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AACrF,mBAAe,MAAM;AAAA;AAAA,MAAgC;AAAA,OAAY;AACjE,iBAAa,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY;AACvD,iBAAa,IAAI,WAAW,OAAO,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC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AAK,cAAc,IAAI,IAAI;AACvE,UAAM,IAAI,EAAE,GAAG,EAAE;AACjB,QAAI,GAAG;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAa,OAAO;AAAA,UACvC,EAAE,MAAM,UAAU,OAAO,cAAc,OAAO,EAAE,GAAG;AAAA,UACnD,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL,OAAO;AACH,QAAE,KAAK,CAAC;AAAA,QACJ,MAAM;AAAA,QAAU,OAAO;AAAA,QAAc,OAAO;AAAA,UACxC,EAAE,MAAM,UAAU,OAAO,UAAU,OAAO,EAAE,GAAG;AAAA,QACnD;AAAA,MACJ,CAAC;AAAA,IACL;AACA,WAAO;AAAA,EACX;AAAA,EAEA,UAAU;AACN,WAAO,KAAK,UAAU,KAAK,QAAQ,CAAC;AAAA,EACxC;AAAA,EAEA,QAAQ;AACJ,WAAO,KAAK,QAAQ,EAAE;AAAA,EAC1B;AACJ;AAAA;AAhSa,uBAEM,qBAAyD,oBAAI,IAAI;AAF7E,IAAM,wBAAN;", + "names": ["FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "FaustPolyWebAudioDsp", "FaustBaseWebAudioDsp", "FaustWasmInstantiator", "FaustMonoWebAudioDsp", "RawSha256", "fromUtf8", "Sha256", "sha256", "item", "ctrl", "files", "sp"] +} diff --git a/docs/gamelan/sinusoide2/icon.png b/docs/gamelan/sinusoide2/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5e2bb2ab9bc16c9877e5ee78a84bccc98d92b7e0 GIT binary patch literal 5497 zcmbVQc{G&a_aA0VgTdH`q#3&rjgU2FObdkuV+m=-5~(a%qNp)u#=b;K_9Hq-n(f=(7m?ybOR{O%+1cR;4gaQCM%KsK$S_ zg)!T|w1H%rAB7LV0+5LS3>tud17J`9FKG}E@ZZJ%%bEX=@E_w4P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y|4;P)lU3R!QfFv1(`OI6P2QFb! z^l+!b;uy-T4p9!*$XP7jEl%cnniGZbAgvx%5jQQXL*+ERFZP}Et2vF=t=(AQsx&vx zvO4v*!z3%I6{S2NrK|wfRq(tZ@{6FFVv80Ae~^PkK_Q`H|QYPjh?wmLb9!lPU!AQF- zfh+ucAfOn(SB{*Q1cdjW>c}KRq&qblk~9teRvkhqO2(3j#4IwrGZ=#8nj{1^Ck}t2 zIUR?97labc^u*pCo2xU)3E+`5wgR2CktX)X9=DmeLS-vNdEiiACCwW{Ek?`M@emME zg41Dpg?9}~Dt2BNNa6$?JK8+YR^+*&9=%B;-LF9NsHHC%5RUDG>07et%G&j}zFp6b zB`JY`*0fF@M2d>eY0;?=VmAo-fPgVVNhD~(OreVuch=BF7h2;HNhgxyNp+B + + + + + + + + + Faust DSP + + + + + +
+
+
+
+ + + + \ No newline at end of file diff --git a/docs/gamelan/sinusoide2/index.js b/docs/gamelan/sinusoide2/index.js new file mode 100644 index 0000000..02fbaff --- /dev/null +++ b/docs/gamelan/sinusoide2/index.js @@ -0,0 +1,149 @@ +// Set to > 0 if the DSP is polyphonic +const FAUST_DSP_VOICES = 0; + +/** + * @typedef {import("./faustwasm").FaustAudioWorkletNode} FaustAudioWorkletNode + * @typedef {import("./faustwasm").FaustDspMeta} FaustDspMeta + * @typedef {import("./faustwasm").FaustUIDescriptor} FaustUIDescriptor + * @typedef {import("./faustwasm").FaustUIGroup} FaustUIGroup + * @typedef {import("./faustwasm").FaustUIItem} FaustUIItem + */ + +/** + * Registers the service worker. + */ +if ("serviceWorker" in navigator) { + window.addEventListener("load", () => { + navigator.serviceWorker.register("./service-worker.js") + .then(reg => console.log("Service Worker registered", reg)) + .catch(err => console.log("Service Worker registration failed", err)); + }); +} + +/** @type {HTMLDivElement} */ +const $divFaustUI = document.getElementById("div-faust-ui"); + +/** @type {typeof AudioContext} */ +const AudioCtx = window.AudioContext || window.webkitAudioContext; +const audioContext = new AudioCtx({ latencyHint: 0.00001 }); +audioContext.destination.channelInterpretation = "discrete"; +audioContext.suspend(); + +(async () => { + + const { createFaustNode } = await import("./create-node.js"); + // To test the ScriptProcessorNode mode + // const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES, true); + const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "osc", FAUST_DSP_VOICES); + if (!faustNode) throw new Error("Faust DSP not compiled"); + + // Create the Faust UI + const { createFaustUI } = await import("./create-node.js"); + await createFaustUI($divFaustUI, faustNode); + + // Connect the Faust node to the audio output + faustNode.connect(audioContext.destination); + + // Connect the Faust node to the audio input + if (faustNode.numberOfInputs > 0) { + const { connectToAudioInput } = await import("./create-node.js"); + await connectToAudioInput(audioContext, null, faustNode, null); + } + + // Function to start MIDI + function startMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = (event) => faustNode.midiMessage(event.data); + console.log(`Connected to input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + // Function to stop MIDI + function stopMIDI() { + // Check if the browser supports the Web MIDI API + if (navigator.requestMIDIAccess) { + navigator.requestMIDIAccess().then( + midiAccess => { + console.log("MIDI Access obtained."); + for (let input of midiAccess.inputs.values()) { + input.onmidimessage = null; + console.log(`Disconnected from input: ${input.name}`); + } + }, + () => console.error("Failed to access MIDI devices.") + ); + } else { + console.log("Web MIDI API is not supported in this browser."); + } + } + + let sensorHandlersBound = false; + let midiHandlersBound = false; + + // Function to resume AudioContext, activate MIDI and Sensors on user interaction + async function activateAudioMIDISensors() { + + // Resume the AudioContext + if (audioContext.state === 'suspended') { + await audioContext.resume(); + } + + // Activate sensor listeners + if (!sensorHandlersBound) { + await faustNode.startSensors(); + sensorHandlersBound = true; + } + + // Initialize the MIDI setup + if (!midiHandlersBound && FAUST_DSP_VOICES > 0) { + startMIDI(); + midiHandlersBound = true; + } + } + + // Function to suspend AudioContext, deactivate MIDI and Sensors on user interaction + async function deactivateAudioMIDISensors() { + + // Suspend the AudioContext + if (audioContext.state === 'running') { + await audioContext.suspend(); + } + + // Deactivate sensor listeners + if (sensorHandlersBound) { + faustNode.stopSensors(); + sensorHandlersBound = false; + } + + // Deactivate the MIDI setup + if (midiHandlersBound && FAUST_DSP_VOICES > 0) { + stopMIDI(); + midiHandlersBound = false; + } + } + + // Add event listeners for user interactions + + // Activate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('click', activateAudioMIDISensors); + window.addEventListener('touchstart', activateAudioMIDISensors); + + // Deactivate AudioContext, MIDI and Sensors on user interaction + window.addEventListener('visibilitychange', function () { + if (window.visibilityState === 'hidden') { + deactivateAudioMIDISensors(); + } + }); + +})(); diff --git a/docs/gamelan/sinusoide2/manifest.json b/docs/gamelan/sinusoide2/manifest.json new file mode 100644 index 0000000..93060bf --- /dev/null +++ b/docs/gamelan/sinusoide2/manifest.json @@ -0,0 +1,17 @@ +{ + "name": "Faust sinusoide2", + "short_name": "sinusoide2", + "start_url": "./index.html", + "description": "Progressive Web App for sinusoide2", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "orientation": "portrait", + "icons": [ + { + "src": "./icon.png", + "sizes": "390x390", + "type": "image/png" + } + ] +} diff --git a/docs/gamelan/sinusoide2/service-worker.js b/docs/gamelan/sinusoide2/service-worker.js new file mode 100644 index 0000000..6b168e6 --- /dev/null +++ b/docs/gamelan/sinusoide2/service-worker.js @@ -0,0 +1,73 @@ +/// + +// Set to > 0 if the DSP is polyphonic +const FAUST_DSP_VOICES = 0; +// Set to true if the DSP has an effect +const FAUST_DSP_HAS_EFFECT = false; + +const CACHE_NAME = "sinusoide2-static"; // Cache name without versioning + +const MONO_RESOURCES = [ + "./index.html", + "./index.js", + "./create-node.js", + "./faust-ui/index.js", + "./faust-ui/index.css", + "./faustwasm/index.js", + "./dsp-module.wasm", + "./dsp-meta.json" +]; + +const POLY_RESOURCES = [ + ...MONO_RESOURCES, + "./mixer-module.wasm", +]; + +const POLY_EFFECT_RESOURCES = [ + ...POLY_RESOURCES, + "./effect-module.wasm", + "./effect-meta.json", +]; + +/**@type {ServiceWorkerGlobalScope} */ +const serviceWorkerGlobalScope = self; + +/** + * Install the service worker and cache the resources + */ +serviceWorkerGlobalScope.addEventListener("install", (event) => { + console.log("Service worker installed"); + event.waitUntil((async () => { + const cache = await caches.open(CACHE_NAME); + const resources = (FAUST_DSP_VOICES && FAUST_DSP_HAS_EFFECT) ? POLY_EFFECT_RESOURCES : FAUST_DSP_VOICES ? POLY_RESOURCES : MONO_RESOURCES; + try { + return cache.addAll(resources); + } catch (error) { + console.error("Failed to cache resources during install:", error); + } + })()); +}); + +serviceWorkerGlobalScope.addEventListener("activate", () => console.log("Service worker activated")); + +serviceWorkerGlobalScope.addEventListener("fetch", (event) => { + event.respondWith((async () => { + const cache = await caches.open(CACHE_NAME); + const cachedResponse = await cache.match(event.request); + if (cachedResponse) { + return cachedResponse; + } else { + try { + const fetchResponse = await fetch(event.request); + // Ensure the response is valid before caching it + if (event.request.method === "GET" && fetchResponse && fetchResponse.status === 200 && fetchResponse.type === "basic") { + cache.put(event.request, fetchResponse.clone()); + } + return fetchResponse; + } catch (e) { + // Network access failure + console.log("Network access error", e); + } + } + })()); +}); diff --git a/docs/index.html b/docs/index.html index cc5e4e7..86bf2e3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -175,6 +175,6 @@ diff --git a/docs/js/jquery-1.10.2.min.js b/docs/js/jquery-1.10.2.min.js deleted file mode 100644 index da41706..0000000 --- a/docs/js/jquery-1.10.2.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license -//@ sourceMappingURL=jquery-1.10.2.min.map -*/ -(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="
",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
a",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="
t
",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t -}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle); -u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("