@grame/faustwasm 0.0.26 → 0.0.28
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 +6 -6
- package/assets/standalone/faustwasm/index.d.ts +17 -17
- package/assets/standalone/faustwasm/index.js +29 -12
- package/assets/standalone/faustwasm/index.js.map +3 -3
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +29 -12
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs-bundle/index.d.ts +17 -17
- package/dist/cjs-bundle/index.js +66 -41
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +29 -12
- package/dist/esm/index.js.map +3 -3
- package/dist/esm-bundle/index.d.ts +17 -17
- package/dist/esm-bundle/index.js +70 -41
- package/dist/esm-bundle/index.js.map +3 -3
- package/package.json +4 -2
- package/test/faustlive-wasm/faustwasm/index.d.ts +17 -17
- package/test/faustlive-wasm/faustwasm/index.js +29 -12
- package/test/faustlive-wasm/faustwasm/index.js.map +3 -3
package/README.md
CHANGED
|
@@ -72,12 +72,12 @@ node scripts/faust2sndfile.js test/rev.dsp test/out/p-dj-rev.wav -c 192000 -sr 4
|
|
|
72
72
|
### Use the JavaScript Module
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
npm i -D @
|
|
75
|
+
npm i -D @grame/faustwasm
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
In JavaScript:
|
|
79
79
|
```JavaScript
|
|
80
|
-
const FaustWasm = require("@
|
|
80
|
+
const FaustWasm = require("@grame/faustwasm");
|
|
81
81
|
const path = require("path");
|
|
82
82
|
const fs = require("fs");
|
|
83
83
|
|
|
@@ -91,7 +91,7 @@ const {
|
|
|
91
91
|
} = FaustWasm;
|
|
92
92
|
|
|
93
93
|
(async () => {
|
|
94
|
-
const faustModulePath = path.join(__dirname, "../node_modules/@
|
|
94
|
+
const faustModulePath = path.join(__dirname, "../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
|
|
95
95
|
|
|
96
96
|
// initialize the libfaust wasm
|
|
97
97
|
const faustModule = await instantiateFaustModuleFromFile(faustModulePath);
|
|
@@ -136,10 +136,10 @@ process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
|
|
|
136
136
|
FaustMonoDspGenerator,
|
|
137
137
|
FaustCompiler,
|
|
138
138
|
FaustSvgDiagrams
|
|
139
|
-
} = await import("../node_modules/@
|
|
139
|
+
} = await import("../node_modules/@grame/faustwasm/dist/esm/index.js");
|
|
140
140
|
|
|
141
141
|
// initialize the libfaust wasm
|
|
142
|
-
const faustModule = await instantiateFaustModuleFromFile("../node_modules/@
|
|
142
|
+
const faustModule = await instantiateFaustModuleFromFile("../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
|
|
143
143
|
|
|
144
144
|
// Get the Faust compiler
|
|
145
145
|
const libFaust = new LibFaust(faustModule);
|
|
@@ -239,7 +239,7 @@ A high-level API is available to compile a DSP program and create the audio node
|
|
|
239
239
|
|
|
240
240
|
Simply include the following to get access to types and functions:
|
|
241
241
|
~~~~~~~~~~~~~~~
|
|
242
|
-
///<reference types="@grame/
|
|
242
|
+
///<reference types="@grame/faustwasm"/>
|
|
243
243
|
~~~~~~~~~~~~~~~
|
|
244
244
|
|
|
245
245
|
## Dynamic and Static Instances <a name="ds"></a>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/// <reference types="emscripten" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export type FaustModuleFactory = EmscriptenModuleFactory<FaustModule>;
|
|
7
7
|
export interface FaustModule extends EmscriptenModule {
|
|
8
8
|
ccall: typeof ccall;
|
|
9
9
|
cwrap: typeof cwrap;
|
|
@@ -22,7 +22,7 @@ export interface FaustModule extends EmscriptenModule {
|
|
|
22
22
|
FS: typeof FS;
|
|
23
23
|
libFaustWasm: new () => LibFaustWasm;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export type FaustInfoType = "help" | "version" | "libdir" | "includedir" | "archdir" | "dspdir" | "pathslist";
|
|
26
26
|
export interface IntVector {
|
|
27
27
|
size(): number;
|
|
28
28
|
get(i: number): number;
|
|
@@ -125,8 +125,8 @@ export interface FaustDspMeta {
|
|
|
125
125
|
}[];
|
|
126
126
|
ui: FaustUIDescriptor;
|
|
127
127
|
}
|
|
128
|
-
export
|
|
129
|
-
export
|
|
128
|
+
export type FaustUIDescriptor = FaustUIGroup[];
|
|
129
|
+
export type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup;
|
|
130
130
|
export interface FaustUIInputItem {
|
|
131
131
|
type: FaustUIInputType;
|
|
132
132
|
label: string;
|
|
@@ -156,15 +156,15 @@ export interface FaustUIMeta {
|
|
|
156
156
|
hidden?: string;
|
|
157
157
|
[key: string]: string | undefined;
|
|
158
158
|
}
|
|
159
|
-
export
|
|
160
|
-
export
|
|
161
|
-
export
|
|
159
|
+
export type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup";
|
|
160
|
+
export type FaustUIOutputType = "hbargraph" | "vbargraph";
|
|
161
|
+
export type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry";
|
|
162
162
|
export interface FaustUIGroup {
|
|
163
163
|
type: FaustUIGroupType;
|
|
164
164
|
label: string;
|
|
165
165
|
items: FaustUIItem[];
|
|
166
166
|
}
|
|
167
|
-
export
|
|
167
|
+
export type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType;
|
|
168
168
|
export interface AudioParamDescriptor {
|
|
169
169
|
automationRate?: AutomationRate;
|
|
170
170
|
defaultValue?: number;
|
|
@@ -198,12 +198,12 @@ export interface InterfaceFFT {
|
|
|
198
198
|
export declare const InterfaceFFT: {
|
|
199
199
|
new (size: number): InterfaceFFT;
|
|
200
200
|
};
|
|
201
|
-
export
|
|
202
|
-
export
|
|
201
|
+
export type TWindowFunction = (index: number, length: number, ...args: any[]) => number;
|
|
202
|
+
export type Writeable<T> = {
|
|
203
203
|
-readonly [P in keyof T]: T[P];
|
|
204
204
|
};
|
|
205
|
-
export
|
|
206
|
-
export
|
|
205
|
+
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
206
|
+
export type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array;
|
|
207
207
|
export declare const FFTUtils: {
|
|
208
208
|
/** Inject window functions as array, no need to add rectangular (no windowing) */
|
|
209
209
|
windowFunctions?: TWindowFunction[];
|
|
@@ -359,14 +359,14 @@ export declare class FaustWasmInstantiator {
|
|
|
359
359
|
static createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise<FaustPolyDspInstance>;
|
|
360
360
|
static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
|
|
361
361
|
}
|
|
362
|
-
export
|
|
363
|
-
export
|
|
364
|
-
export
|
|
362
|
+
export type OutputParamHandler = (path: string, value: number) => void;
|
|
363
|
+
export type ComputeHandler = (buffer_size: number) => void;
|
|
364
|
+
export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
|
|
365
365
|
type: string;
|
|
366
366
|
data: any;
|
|
367
367
|
}[]) => void;
|
|
368
|
-
export
|
|
369
|
-
export
|
|
368
|
+
export type MetadataHandler = (key: string, value: string) => void;
|
|
369
|
+
export type UIHandler = (item: FaustUIItem) => void;
|
|
370
370
|
/**
|
|
371
371
|
* DSP implementation: mimic the C++ 'dsp' class:
|
|
372
372
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
@@ -15,7 +15,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
20
|
+
mod
|
|
21
|
+
));
|
|
19
22
|
|
|
20
23
|
// node_modules/tslib/tslib.js
|
|
21
24
|
var require_tslib = __commonJS({
|
|
@@ -846,8 +849,8 @@ var require_jsSha256 = __commonJS({
|
|
|
846
849
|
return this.hash.digest();
|
|
847
850
|
};
|
|
848
851
|
Sha2563.prototype.digest = function() {
|
|
849
|
-
return
|
|
850
|
-
return
|
|
852
|
+
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
853
|
+
return tslib_1.__generator(this, function(_a) {
|
|
851
854
|
return [2, this.digestSync()];
|
|
852
855
|
});
|
|
853
856
|
});
|
|
@@ -875,7 +878,7 @@ var require_build2 = __commonJS({
|
|
|
875
878
|
"use strict";
|
|
876
879
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
877
880
|
var tslib_1 = require_tslib();
|
|
878
|
-
|
|
881
|
+
tslib_1.__exportStar(require_jsSha256(), exports);
|
|
879
882
|
}
|
|
880
883
|
});
|
|
881
884
|
|
|
@@ -1802,7 +1805,9 @@ var FaustWasmInstantiator = class {
|
|
|
1802
1805
|
return n;
|
|
1803
1806
|
};
|
|
1804
1807
|
const effectSize = effectMeta ? effectMeta.size : 0;
|
|
1805
|
-
let memorySize = pow2limit(
|
|
1808
|
+
let memorySize = pow2limit(
|
|
1809
|
+
effectSize + dspMeta.size * voices + (dspMeta.inputs + dspMeta.outputs * 2) * (ptrSize + bufferSize * sampleSize)
|
|
1810
|
+
) / 65536;
|
|
1806
1811
|
memorySize = Math.max(2, memorySize);
|
|
1807
1812
|
return new WebAssembly.Memory({ initial: memorySize, maximum: memorySize });
|
|
1808
1813
|
}
|
|
@@ -2316,7 +2321,13 @@ var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2316
2321
|
this.initMemory();
|
|
2317
2322
|
this.fVoiceTable = [];
|
|
2318
2323
|
for (let voice = 0; voice < this.fInstance.voices; voice++) {
|
|
2319
|
-
this.fVoiceTable.push(new FaustWebAudioDspVoice(
|
|
2324
|
+
this.fVoiceTable.push(new FaustWebAudioDspVoice(
|
|
2325
|
+
this.fJSONDsp.size * voice,
|
|
2326
|
+
this.fInstance.voiceAPI,
|
|
2327
|
+
this.fInputsItems,
|
|
2328
|
+
this.fPathTable,
|
|
2329
|
+
sampleRate
|
|
2330
|
+
));
|
|
2320
2331
|
}
|
|
2321
2332
|
if (this.fInstance.effectAPI)
|
|
2322
2333
|
this.fInstance.effectAPI.init(this.fEffect, sampleRate);
|
|
@@ -3283,14 +3294,20 @@ var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
|
3283
3294
|
};
|
|
3284
3295
|
var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
3285
3296
|
constructor(context, name, voiceFactory, mixerModule, voices, sampleSize, effectFactory, nodeOptions = {}) {
|
|
3286
|
-
super(
|
|
3297
|
+
super(
|
|
3298
|
+
context,
|
|
3287
3299
|
name,
|
|
3288
3300
|
voiceFactory,
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3301
|
+
{
|
|
3302
|
+
name,
|
|
3303
|
+
voiceFactory,
|
|
3304
|
+
mixerModule,
|
|
3305
|
+
voices,
|
|
3306
|
+
sampleSize,
|
|
3307
|
+
effectFactory
|
|
3308
|
+
},
|
|
3309
|
+
nodeOptions
|
|
3310
|
+
);
|
|
3294
3311
|
this.onprocessorerror = (e) => {
|
|
3295
3312
|
throw e;
|
|
3296
3313
|
};
|