@grame/faustwasm 0.12.2 → 0.13.1
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/.prettierrc +5 -0
- package/README.md +21 -3
- package/assets/standalone/faustwasm/index.d.ts +38 -16
- package/assets/standalone/faustwasm/index.js +1593 -404
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +38 -16
- package/dist/cjs/index.js +1592 -404
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +38 -16
- package/dist/cjs-bundle/index.js +1595 -406
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +38 -16
- package/dist/esm/index.js +1593 -404
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +38 -16
- package/dist/esm-bundle/index.js +1595 -406
- package/dist/esm-bundle/index.js.map +2 -2
- package/eslint.config.js +11 -0
- package/package.json +57 -51
- package/sound.cpp +163 -0
- package/sound.dsp +4 -0
- package/sound.json +1 -0
- package/sound.wasm +0 -0
- package/src/FaustAudioWorkletCommunicator.ts +150 -143
- package/src/FaustAudioWorkletNode.ts +173 -75
- package/src/FaustAudioWorkletProcessor.ts +218 -90
- package/src/FaustCmajor.ts +9 -3
- package/src/FaustCompiler.ts +112 -35
- package/src/FaustDspGenerator.ts +589 -117
- package/src/FaustDspInstance.ts +58 -24
- package/src/FaustFFTAudioWorkletProcessor.ts +822 -612
- package/src/FaustOfflineProcessor.ts +187 -56
- package/src/FaustScriptProcessorNode.ts +156 -49
- package/src/FaustSensors.ts +426 -96
- package/src/FaustSvgDiagrams.ts +18 -5
- package/src/FaustWasmInstantiator.ts +224 -70
- package/src/FaustWebAudioDsp.ts +1060 -349
- package/src/LibFaust.ts +13 -4
- package/src/SoundfileReader.ts +175 -131
- package/src/WavDecoder.ts +42 -20
- package/src/WavEncoder.ts +35 -21
- package/src/copyWebStandaloneAssets.d.ts +20 -5
- package/src/copyWebStandaloneAssets.js +203 -75
- package/src/exports-bundle.ts +5 -5
- package/src/exports.ts +24 -24
- package/src/faust2CmajorFiles.d.ts +7 -3
- package/src/faust2cmajorFiles.js +10 -8
- package/src/faust2svgFiles.d.ts +7 -3
- package/src/faust2svgFiles.js +9 -7
- package/src/faust2wasmFiles.d.ts +10 -5
- package/src/faust2wasmFiles.js +34 -17
- package/src/faust2wavFiles.d.ts +12 -3
- package/src/faust2wavFiles.js +25 -12
- package/src/index-bundle-iife.ts +2 -2
- package/src/index-bundle.ts +1 -1
- package/src/index.ts +1 -1
- package/src/instantiateFaustModule.ts +43 -36
- package/src/instantiateFaustModuleFromFile.ts +30 -14
- package/src/types.ts +101 -25
- package/test/faustlive-wasm/faustwasm/index.d.ts +38 -16
- package/test/faustlive-wasm/faustwasm/index.js +1593 -404
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/create-faust-node.html +53 -0
- package/test/web/create-faust-node.js +181 -0
- package/test/organ/create-node.js +0 -252
- package/test/organ/dsp-meta.json +0 -131
- package/test/organ/dsp-module.wasm +0 -0
- package/test/organ/faust-pwa.js +0 -344
- package/test/organ/faust-ui/index.css +0 -442
- package/test/organ/faust-ui/index.css.map +0 -1
- package/test/organ/faust-ui/index.d.ts +0 -1
- package/test/organ/faust-ui/index.js +0 -3756
- package/test/organ/faust-ui/index.js.map +0 -1
- package/test/organ/faustwasm/index.d.ts +0 -1705
- package/test/organ/faustwasm/index.js +0 -4773
- package/test/organ/faustwasm/index.js.map +0 -7
- package/test/organ/icon.png +0 -0
- package/test/organ/index.html +0 -76
- package/test/organ/index.js +0 -69
- package/test/organ/manifest.json +0 -17
- package/test/organ/service-worker.js +0 -165
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -37,6 +37,20 @@ Build the files:
|
|
|
37
37
|
npm run build
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
The source code uses [Prettier code formatter](https://prettier.io) to properly format all TS and JS files. Use:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run format
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
to apply format rules on `src`, and:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run lint
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
to check format rules on `src`.
|
|
53
|
+
|
|
40
54
|
### Versioning
|
|
41
55
|
|
|
42
56
|
You'll have to raise the package version number in `package.json` before `npm run build` to properly work.
|
|
@@ -319,7 +333,13 @@ An offline processor to render a DSP in a non real-time context and get the comp
|
|
|
319
333
|
|
|
320
334
|
#### High-level API <a name="high"></a>
|
|
321
335
|
|
|
322
|
-
|
|
336
|
+
The high-level API provides convenient functions to compile a Faust DSP program and create its corresponding audio node, either monophonic or polyphonic.
|
|
337
|
+
- using the appropriate `FaustMonoDspGenerator` or `FaustPolyDspGenerator` class, `createNode` explicitly builds a mono or polyphonic node.
|
|
338
|
+
- `createFaustNode` automatically selects mono or polyphonic mode by inspecting the `[nvoices:N] `field in the DSP metadata.
|
|
339
|
+
|
|
340
|
+
For offline rendering, `createOfflineProcessor` is available and supports both mono and polyphonic processing. FFT processing nodes can be created using `createFFTNode`.
|
|
341
|
+
|
|
342
|
+
This API is implemented in FaustDspGenerator.ts.
|
|
323
343
|
|
|
324
344
|
#### How to use with typescript <a name="tsuse"></a>
|
|
325
345
|
|
|
@@ -348,5 +368,3 @@ Html pages embedding the Faust compiler must be served using https, unless using
|
|
|
348
368
|
|
|
349
369
|
|
|
350
370
|
|
|
351
|
-
|
|
352
|
-
|
|
@@ -91,8 +91,7 @@ export interface LibFaustWasm {
|
|
|
91
91
|
*/
|
|
92
92
|
getInfos(what: FaustInfoType): string;
|
|
93
93
|
}
|
|
94
|
-
export
|
|
95
|
-
}
|
|
94
|
+
export type FaustDspFactory = Required<LooseFaustDspFactory>;
|
|
96
95
|
/**
|
|
97
96
|
* The Factory structure.
|
|
98
97
|
*/
|
|
@@ -404,7 +403,7 @@ export declare class FaustWasmInstantiator {
|
|
|
404
403
|
private static createMemoryMono;
|
|
405
404
|
private static createMemoryPoly;
|
|
406
405
|
private static createMixerAux;
|
|
407
|
-
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<
|
|
406
|
+
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<Required<LooseFaustDspFactory>>;
|
|
408
407
|
static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
|
|
409
408
|
static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise<FaustMonoDspInstance>;
|
|
410
409
|
static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance;
|
|
@@ -673,10 +672,10 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
673
672
|
*/
|
|
674
673
|
getUI(): FaustUIDescriptor;
|
|
675
674
|
/**
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
675
|
+
* Get DSP UI items description.
|
|
676
|
+
*
|
|
677
|
+
* @return the DSP UI items description
|
|
678
|
+
*/
|
|
680
679
|
getDescriptors(): FaustUIInputItem[];
|
|
681
680
|
/**
|
|
682
681
|
* Get DSP JSON description with its UI and metadata.
|
|
@@ -685,8 +684,8 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
685
684
|
*/
|
|
686
685
|
getJSON(): string;
|
|
687
686
|
/**
|
|
688
|
-
|
|
689
|
-
|
|
687
|
+
* Start accelerometer and gyroscope handlers.
|
|
688
|
+
*/
|
|
690
689
|
startSensors(): void;
|
|
691
690
|
/**
|
|
692
691
|
* Stop accelerometer and gyroscope handlers.
|
|
@@ -720,8 +719,7 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
720
719
|
*/
|
|
721
720
|
destroy(): void;
|
|
722
721
|
}
|
|
723
|
-
export
|
|
724
|
-
}
|
|
722
|
+
export type IFaustMonoWebAudioDsp = IFaustBaseWebAudioDsp;
|
|
725
723
|
export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
|
|
726
724
|
}
|
|
727
725
|
export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
@@ -849,7 +847,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
849
847
|
*
|
|
850
848
|
* @param allocator : the wasm memory allocator
|
|
851
849
|
* @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
|
|
852
|
-
|
|
850
|
+
*/
|
|
853
851
|
protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void;
|
|
854
852
|
protected updateOutputs(): void;
|
|
855
853
|
metadata(handler: MetadataHandler): void;
|
|
@@ -1164,18 +1162,18 @@ export declare class FaustCompiler implements IFaustCompiler {
|
|
|
1164
1162
|
code: string;
|
|
1165
1163
|
json: any;
|
|
1166
1164
|
poly: boolean;
|
|
1167
|
-
}>): Promise<Map<string,
|
|
1165
|
+
}>): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
|
|
1168
1166
|
/**
|
|
1169
1167
|
* Import a stringified DSP factories table
|
|
1170
1168
|
*/
|
|
1171
|
-
static importDSPFactories(tableStr: string): Promise<Map<string,
|
|
1169
|
+
static importDSPFactories(tableStr: string): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
|
|
1172
1170
|
constructor(libFaust: ILibFaust);
|
|
1173
1171
|
private intVec2intArray;
|
|
1174
1172
|
private createDSPFactory;
|
|
1175
1173
|
version(): string;
|
|
1176
1174
|
getErrorMessage(): string;
|
|
1177
|
-
createMonoDSPFactory(name: string, code: string, args: string): Promise<
|
|
1178
|
-
createPolyDSPFactory(name: string, code: string, args: string): Promise<
|
|
1175
|
+
createMonoDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
|
|
1176
|
+
createPolyDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
|
|
1179
1177
|
deleteDSPFactory(factory: FaustDspFactory): void;
|
|
1180
1178
|
expandDSP(code: string, args: string): string;
|
|
1181
1179
|
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
@@ -1524,6 +1522,20 @@ export interface GeneratorSupportingSoundfiles {
|
|
|
1524
1522
|
*/
|
|
1525
1523
|
getSoundfileList(): string[];
|
|
1526
1524
|
}
|
|
1525
|
+
export interface IFaustDspGenerator {
|
|
1526
|
+
/**
|
|
1527
|
+
* Create a monophonic or polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1528
|
+
* Analyze the code to decide whether to create a monophonic or polyphonic node.
|
|
1529
|
+
*
|
|
1530
|
+
* @param context - the WebAudio context
|
|
1531
|
+
* @param name - DSP name, can be used for processorName
|
|
1532
|
+
* @param code - the DSP code
|
|
1533
|
+
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1534
|
+
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1535
|
+
* @returns the compiled monophonic or polyphonic WebAudio node or 'null' if failure
|
|
1536
|
+
*/
|
|
1537
|
+
createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
|
|
1538
|
+
}
|
|
1527
1539
|
export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
1528
1540
|
/**
|
|
1529
1541
|
* Compile a monophonic DSP factory from given code.
|
|
@@ -1697,6 +1709,16 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1697
1709
|
getJSON(): string;
|
|
1698
1710
|
getUI(): FaustUIDescriptor;
|
|
1699
1711
|
}
|
|
1712
|
+
export declare class FaustDspGenerator implements IFaustDspGenerator {
|
|
1713
|
+
private static compilerPromise;
|
|
1714
|
+
private extractMidiAndNvoices;
|
|
1715
|
+
/**
|
|
1716
|
+
* Compile DSP code, inspect metadata for [nvoices:] (and optionally [midi:on]), and build either a mono
|
|
1717
|
+
* or poly WebAudio node (ScriptProcessor or AudioWorklet depending on `sp`). Compilation uses a shared,
|
|
1718
|
+
* lazily-created libfaust instance to avoid repeatedly instantiating the WASM compiler.
|
|
1719
|
+
*/
|
|
1720
|
+
createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
|
|
1721
|
+
}
|
|
1700
1722
|
|
|
1701
1723
|
export {
|
|
1702
1724
|
AudioData$1 as AudioData,
|