@grame/faustwasm 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/assets/standalone/faustwasm/index.js +18 -19
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.js +17 -18
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.js +1287 -3016
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.js +18 -19
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.js +1287 -3016
- package/dist/esm-bundle/index.js.map +3 -3
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +3 -4
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +13 -13
- package/src/FaustDspInstance.ts +1 -3
- package/src/FaustWasmInstantiator.ts +1 -1
- package/src/exports.ts +24 -24
- package/test/faustlive-wasm/faustwasm/index.js +18 -19
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/t1.cjs +46 -0
- package/test/t1.js +46 -0
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# FaustWasm
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The FaustWasm library presents a convenient, high-level API that wraps around [Faust](https://faust.grame.fr) compiler. This library's interface is primarily designed for [TypeScript](https://www.typescriptlang.org/) usage, although it also provides API descriptions and documentation for pure JavaScript. The WebAssembly version of the Faust Compiler, compatible with both [Node.js](https://nodejs.org) and web browsers, has been compiled using [Emscripten](https://emscripten.org/) 3.1.31.
|
|
4
|
+
|
|
5
|
+
The library offers functionality for compiling Faust DSP code into WebAssembly, enabling its utilization as WebAudio nodes within a standard WebAudio node graph. Moreover, it supports offline rendering scenarios. Furthermore, supplementary tools can be employed for generating SVGs from Faust DSP programs.
|
|
4
6
|
|
|
5
7
|
## Usage
|
|
6
8
|
|
|
@@ -217,11 +219,11 @@ It provides *classic* Faust compilation services, which output is a raw WebAssem
|
|
|
217
219
|
|
|
218
220
|
### Faust Wasm Instance <a name="wasm"></a>
|
|
219
221
|
|
|
220
|
-
This level takes a WebAssembly module produced by the Faust compiler or a precompiled module loaded from a file, and builds an instance of this module with the proper Wasm memory layout, ready to run
|
|
222
|
+
This level takes a WebAssembly module produced by the Faust compiler or a precompiled module loaded from a file, and builds an instance of this module with the proper Wasm memory layout, ready to run. It is described in `FaustDspGenerator.ts`, `FaustWasmInstantiator.ts`, `FaustWebAudioDsp.ts` and `FaustDspInstance.ts` files.
|
|
221
223
|
|
|
222
224
|
### Faust Audio Nodes Instances and Offline Processor <a name="audio"></a>
|
|
223
225
|
|
|
224
|
-
This level takes a Faust Wasm instance to build an audio node. [AudioWorklet](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) and [ScriptProcessor](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) nodes are supported.
|
|
226
|
+
This level takes a Faust Wasm instance to build an audio node. [AudioWorklet](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) and [ScriptProcessor](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) nodes are supported. It is described in `FaustAudioWorkletNode.ts` and `FaustAudioWorkletProcessor.ts` files.
|
|
225
227
|
|
|
226
228
|
**Warning**: AudioWorklet is a recent technology and may not be supported by all the browsers. Check the [compatibility](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) chart.
|
|
227
229
|
|
|
@@ -1723,7 +1723,6 @@ var FaustDspInstance = class {
|
|
|
1723
1723
|
this.fExports.setParamValue($dsp, index, value);
|
|
1724
1724
|
}
|
|
1725
1725
|
};
|
|
1726
|
-
var FaustDspInstance_default = FaustDspInstance;
|
|
1727
1726
|
|
|
1728
1727
|
// src/FaustWasmInstantiator.ts
|
|
1729
1728
|
var FaustWasmInstantiator = class {
|
|
@@ -1813,7 +1812,7 @@ var FaustWasmInstantiator = class {
|
|
|
1813
1812
|
}
|
|
1814
1813
|
static createMonoDSPInstanceAux(instance, json) {
|
|
1815
1814
|
const functions = instance.exports;
|
|
1816
|
-
const api = new
|
|
1815
|
+
const api = new FaustDspInstance(functions);
|
|
1817
1816
|
const memory = instance.exports.memory;
|
|
1818
1817
|
return { memory, api, json };
|
|
1819
1818
|
}
|
|
@@ -1876,12 +1875,12 @@ var FaustWasmInstantiator = class {
|
|
|
1876
1875
|
const memory = this.createMemoryAux(voices, voiceFactory, effectFactory);
|
|
1877
1876
|
const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));
|
|
1878
1877
|
const voiceFunctions = voiceInstance.exports;
|
|
1879
|
-
const voiceAPI = new
|
|
1878
|
+
const voiceAPI = new FaustDspInstance(voiceFunctions);
|
|
1880
1879
|
const mixerAPI = this.createMixerAux(mixerModule, memory);
|
|
1881
1880
|
if (effectFactory) {
|
|
1882
1881
|
const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));
|
|
1883
1882
|
const effectFunctions = effectInstance.exports;
|
|
1884
|
-
const effectAPI = new
|
|
1883
|
+
const effectAPI = new FaustDspInstance(effectFunctions);
|
|
1885
1884
|
return {
|
|
1886
1885
|
memory,
|
|
1887
1886
|
voices,
|
|
@@ -1905,12 +1904,12 @@ var FaustWasmInstantiator = class {
|
|
|
1905
1904
|
const memory = this.createMemoryAux(voices, voiceFactory, effectFactory);
|
|
1906
1905
|
const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));
|
|
1907
1906
|
const voiceFunctions = voiceInstance.exports;
|
|
1908
|
-
const voiceAPI = new
|
|
1907
|
+
const voiceAPI = new FaustDspInstance(voiceFunctions);
|
|
1909
1908
|
const mixerAPI = this.createMixerAux(mixerModule, memory);
|
|
1910
1909
|
if (effectFactory) {
|
|
1911
1910
|
const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));
|
|
1912
1911
|
const effectFunctions = effectInstance.exports;
|
|
1913
|
-
const effectAPI = new
|
|
1912
|
+
const effectAPI = new FaustDspInstance(effectFunctions);
|
|
1914
1913
|
return {
|
|
1915
1914
|
memory,
|
|
1916
1915
|
voices,
|
|
@@ -3499,15 +3498,15 @@ const faustData = ${JSON.stringify({
|
|
|
3499
3498
|
poly: false
|
|
3500
3499
|
})};
|
|
3501
3500
|
// Implementation needed classes of functions
|
|
3502
|
-
const ${
|
|
3501
|
+
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3503
3502
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3504
3503
|
const ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}
|
|
3505
3504
|
const ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3506
3505
|
// Put them in dependencies
|
|
3507
3506
|
const dependencies = {
|
|
3508
|
-
${FaustBaseWebAudioDsp.name},
|
|
3509
|
-
${FaustMonoWebAudioDsp.name},
|
|
3510
|
-
${FaustWasmInstantiator_default.name}
|
|
3507
|
+
FaustBaseWebAudioDsp: ${FaustBaseWebAudioDsp.name},
|
|
3508
|
+
FaustMonoWebAudioDsp: ${FaustMonoWebAudioDsp.name},
|
|
3509
|
+
FaustWasmInstantiator: ${FaustWasmInstantiator_default.name}
|
|
3511
3510
|
};
|
|
3512
3511
|
// Generate the actual AudioWorkletProcessor code
|
|
3513
3512
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
@@ -3542,16 +3541,16 @@ const faustData = ${JSON.stringify({
|
|
|
3542
3541
|
fftOptions
|
|
3543
3542
|
})};
|
|
3544
3543
|
// Implementation needed classes of functions
|
|
3545
|
-
const ${
|
|
3544
|
+
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3546
3545
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3547
3546
|
const ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}
|
|
3548
3547
|
const ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3549
3548
|
const FFTUtils = ${fftUtils.toString()}
|
|
3550
3549
|
// Put them in dependencies
|
|
3551
3550
|
const dependencies = {
|
|
3552
|
-
${FaustBaseWebAudioDsp.name},
|
|
3553
|
-
${FaustMonoWebAudioDsp.name},
|
|
3554
|
-
${FaustWasmInstantiator_default.name},
|
|
3551
|
+
FaustBaseWebAudioDsp: ${FaustBaseWebAudioDsp.name},
|
|
3552
|
+
FaustMonoWebAudioDsp: ${FaustMonoWebAudioDsp.name},
|
|
3553
|
+
FaustWasmInstantiator: ${FaustWasmInstantiator_default.name},
|
|
3555
3554
|
FFTUtils
|
|
3556
3555
|
};
|
|
3557
3556
|
// Generate the actual AudioWorkletProcessor code
|
|
@@ -3678,16 +3677,16 @@ const faustData = ${JSON.stringify({
|
|
|
3678
3677
|
effectMeta
|
|
3679
3678
|
})};
|
|
3680
3679
|
// Implementation needed classes of functions
|
|
3681
|
-
const ${
|
|
3680
|
+
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3682
3681
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3683
3682
|
const ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}
|
|
3684
3683
|
const ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}
|
|
3685
3684
|
const ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3686
3685
|
// Put them in dependencies
|
|
3687
3686
|
const dependencies = {
|
|
3688
|
-
${FaustBaseWebAudioDsp.name},
|
|
3689
|
-
${FaustPolyWebAudioDsp.name},
|
|
3690
|
-
${FaustWasmInstantiator_default.name}
|
|
3687
|
+
FaustBaseWebAudioDsp: ${FaustBaseWebAudioDsp.name},
|
|
3688
|
+
FaustPolyWebAudioDsp: ${FaustPolyWebAudioDsp.name},
|
|
3689
|
+
FaustWasmInstantiator: ${FaustWasmInstantiator_default.name}
|
|
3691
3690
|
};
|
|
3692
3691
|
// Generate the actual AudioWorkletProcessor code
|
|
3693
3692
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
@@ -3747,7 +3746,7 @@ export {
|
|
|
3747
3746
|
FaustAudioWorkletNode,
|
|
3748
3747
|
FaustBaseWebAudioDsp,
|
|
3749
3748
|
FaustCompiler_default as FaustCompiler,
|
|
3750
|
-
|
|
3749
|
+
FaustDspInstance,
|
|
3751
3750
|
FaustMonoAudioWorkletNode,
|
|
3752
3751
|
FaustMonoDspGenerator,
|
|
3753
3752
|
FaustMonoOfflineProcessor,
|