@grame/faustwasm 0.4.5 → 0.4.8
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/COPYING.txt +520 -0
- package/README.md +4 -4
- package/assets/standalone/create-node.js +78 -0
- package/assets/standalone/faust-ui/index.css +8 -0
- package/assets/standalone/faust-ui/index.css.map +1 -1
- package/assets/standalone/faust-ui/index.js +56 -30
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +18 -10
- package/assets/standalone/faustwasm/index.js +81 -56
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-template.html +17 -0
- package/assets/standalone/index-template.js +48 -0
- package/assets/standalone/index.html +4 -3
- package/assets/standalone/index.js +14 -71
- package/assets/standalone/manifest.json +5 -6
- package/assets/standalone/service-worker.js +51 -27
- package/dist/cjs/index.d.ts +18 -10
- package/dist/cjs/index.js +81 -56
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +18 -10
- package/dist/cjs-bundle/index.js +81 -56
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +18 -10
- package/dist/esm/index.js +81 -56
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +18 -10
- package/dist/esm-bundle/index.js +81 -56
- package/dist/esm-bundle/index.js.map +2 -2
- package/fileutils.js +19 -21
- package/package.json +4 -2
- package/scripts/faust2wasm.js +10 -5
- package/src/FaustAudioWorkletNode.ts +18 -38
- package/src/FaustAudioWorkletProcessor.ts +28 -1
- package/src/FaustDspGenerator.ts +18 -9
- package/src/FaustFFTAudioWorkletProcessor.ts +27 -0
- package/src/FaustScriptProcessorNode.ts +5 -14
- package/src/copyWebStandaloneAssets.d.ts +2 -2
- package/src/copyWebStandaloneAssets.js +30 -19
- package/src/faust2wasmFiles.js +5 -5
- package/test/faustlive-wasm/faust-ui/index.css +8 -0
- package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
- package/test/faustlive-wasm/faust-ui/index.js +56 -30
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +18 -10
- package/test/faustlive-wasm/faustwasm/index.js +81 -56
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-poly.js +0 -234
- package/assets/standalone/service-worker-poly.js +0 -98
- package/assets/standalone/template-poly.html +0 -60
- package/assets/standalone/template.html +0 -50
- package/assets/standalone/template.js +0 -63
- package/assets/standalone/types.d.ts +0 -9
|
@@ -887,6 +887,8 @@ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOption
|
|
|
887
887
|
export interface FaustAudioWorkletProcessorOptions {
|
|
888
888
|
name: string;
|
|
889
889
|
sampleSize: number;
|
|
890
|
+
moduleId?: string;
|
|
891
|
+
instanceId?: string;
|
|
890
892
|
}
|
|
891
893
|
export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
892
894
|
factory: LooseFaustDspFactory;
|
|
@@ -931,6 +933,8 @@ export interface FaustFFTAudioWorkletProcessorOptions {
|
|
|
931
933
|
name: string;
|
|
932
934
|
sampleSize: number;
|
|
933
935
|
factory: LooseFaustDspFactory;
|
|
936
|
+
moduleId?: string;
|
|
937
|
+
instanceId?: string;
|
|
934
938
|
}
|
|
935
939
|
export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
|
|
936
940
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
@@ -1266,7 +1270,7 @@ export declare class SoundfileReader {
|
|
|
1266
1270
|
static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
|
|
1267
1271
|
}
|
|
1268
1272
|
declare const FaustAudioWorkletNode_base: {
|
|
1269
|
-
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions
|
|
1273
|
+
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1270
1274
|
prototype: AudioWorkletNode;
|
|
1271
1275
|
};
|
|
1272
1276
|
/**
|
|
@@ -1282,7 +1286,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1282
1286
|
protected fPlotHandler: PlotHandler | null;
|
|
1283
1287
|
protected fUICallback: UIHandler;
|
|
1284
1288
|
protected fDescriptor: FaustUIInputItem[];
|
|
1285
|
-
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options
|
|
1289
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
|
|
1286
1290
|
/** Setup accelerometer and gyroscope handlers */
|
|
1287
1291
|
listenSensors(): Promise<void>;
|
|
1288
1292
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
@@ -1291,6 +1295,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1291
1295
|
getComputeHandler(): ComputeHandler | null;
|
|
1292
1296
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
1293
1297
|
getPlotHandler(): PlotHandler | null;
|
|
1298
|
+
setupWamEventHandler(): void;
|
|
1294
1299
|
getNumInputs(): number;
|
|
1295
1300
|
getNumOutputs(): number;
|
|
1296
1301
|
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
@@ -1318,7 +1323,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1318
1323
|
*/
|
|
1319
1324
|
export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
|
|
1320
1325
|
onprocessorerror: (e: Event) => never;
|
|
1321
|
-
constructor(context: BaseAudioContext,
|
|
1326
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
|
|
1322
1327
|
}
|
|
1323
1328
|
/**
|
|
1324
1329
|
* Polyphonic AudioWorkletNode
|
|
@@ -1326,7 +1331,7 @@ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<fal
|
|
|
1326
1331
|
export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
|
|
1327
1332
|
private fJSONEffect;
|
|
1328
1333
|
onprocessorerror: (e: Event) => never;
|
|
1329
|
-
constructor(context: BaseAudioContext,
|
|
1334
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
|
|
1330
1335
|
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1331
1336
|
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1332
1337
|
allNotesOff(hard: boolean): void;
|
|
@@ -1419,9 +1424,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1419
1424
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1420
1425
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1421
1426
|
* @param processorName - AudioWorklet Processor name
|
|
1427
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1422
1428
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1423
1429
|
*/
|
|
1424
|
-
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
|
|
1430
|
+
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
|
|
1425
1431
|
/**
|
|
1426
1432
|
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1427
1433
|
*
|
|
@@ -1431,9 +1437,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1431
1437
|
* @param factory - default is the compiled factory
|
|
1432
1438
|
* @param fftOptions - initial FFT options
|
|
1433
1439
|
* @param processorName - AudioWorklet Processor name
|
|
1440
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1434
1441
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1435
1442
|
*/
|
|
1436
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1443
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1437
1444
|
/**
|
|
1438
1445
|
* Create a monophonic Offline processor.
|
|
1439
1446
|
*
|
|
@@ -1489,9 +1496,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1489
1496
|
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1490
1497
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1491
1498
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1499
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1492
1500
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1493
1501
|
*/
|
|
1494
|
-
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustPolyWebAudioNode | null>;
|
|
1502
|
+
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustPolyWebAudioNode | null>;
|
|
1495
1503
|
/**
|
|
1496
1504
|
* Create a monophonic Offline processor.
|
|
1497
1505
|
*
|
|
@@ -1531,8 +1539,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1531
1539
|
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1532
1540
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1533
1541
|
getSoundfileList(): string[];
|
|
1534
|
-
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1535
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1542
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1543
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1536
1544
|
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
1537
1545
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1538
1546
|
prototype: AudioWorkletProcessor;
|
|
@@ -1554,7 +1562,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1554
1562
|
compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
|
|
1555
1563
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1556
1564
|
getSoundfileList(): string[];
|
|
1557
|
-
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1565
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1558
1566
|
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1559
1567
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1560
1568
|
prototype: AudioWorkletProcessor;
|
|
@@ -111,6 +111,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
111
111
|
parameterDescriptors.forEach((pd) => {
|
|
112
112
|
this.paramValuesCache[pd.name] = pd.defaultValue || 0;
|
|
113
113
|
});
|
|
114
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
115
|
+
if (!moduleId || !instanceId)
|
|
116
|
+
return;
|
|
117
|
+
this.wamInfo = { moduleId, instanceId };
|
|
114
118
|
}
|
|
115
119
|
static get parameterDescriptors() {
|
|
116
120
|
const params = [];
|
|
@@ -124,6 +128,23 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
124
128
|
FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
|
|
125
129
|
return params;
|
|
126
130
|
}
|
|
131
|
+
setupWamEventHandler() {
|
|
132
|
+
var _a;
|
|
133
|
+
if (!this.wamInfo)
|
|
134
|
+
return;
|
|
135
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
136
|
+
const { webAudioModules } = globalThis;
|
|
137
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
138
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
139
|
+
if (!paramMgrProcessor)
|
|
140
|
+
return;
|
|
141
|
+
if (paramMgrProcessor.handleEvent)
|
|
142
|
+
return;
|
|
143
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
144
|
+
if (event.type === "wam-midi")
|
|
145
|
+
this.midiMessage(event.data.bytes);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
127
148
|
process(inputs, outputs, parameters) {
|
|
128
149
|
for (const path in parameters) {
|
|
129
150
|
const [paramValue] = parameters[path];
|
|
@@ -169,6 +190,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
169
190
|
}
|
|
170
191
|
break;
|
|
171
192
|
}
|
|
193
|
+
case "setupWamEventHandler": {
|
|
194
|
+
this.setupWamEventHandler();
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
172
197
|
case "start": {
|
|
173
198
|
this.fDSPCode.start();
|
|
174
199
|
break;
|
|
@@ -378,6 +403,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
378
403
|
this.sampleSize = sampleSize;
|
|
379
404
|
this.soundfiles = factory.soundfiles;
|
|
380
405
|
this.initFFT();
|
|
406
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
407
|
+
if (!moduleId || !instanceId)
|
|
408
|
+
return;
|
|
409
|
+
this.wamInfo = { moduleId, instanceId };
|
|
381
410
|
}
|
|
382
411
|
get fftProcessorBufferSize() {
|
|
383
412
|
return this.fftSize / 2 + 1;
|
|
@@ -423,6 +452,23 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
423
452
|
}
|
|
424
453
|
];
|
|
425
454
|
}
|
|
455
|
+
setupWamEventHandler() {
|
|
456
|
+
var _a;
|
|
457
|
+
if (!this.wamInfo)
|
|
458
|
+
return;
|
|
459
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
460
|
+
const { webAudioModules } = globalThis;
|
|
461
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
462
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
463
|
+
if (!paramMgrProcessor)
|
|
464
|
+
return;
|
|
465
|
+
if (paramMgrProcessor.handleEvent)
|
|
466
|
+
return;
|
|
467
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
468
|
+
if (event.type === "wam-midi")
|
|
469
|
+
this.midiMessage(event.data.bytes);
|
|
470
|
+
};
|
|
471
|
+
}
|
|
426
472
|
processFFT() {
|
|
427
473
|
let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;
|
|
428
474
|
while (samplesForFFT >= this.fftSize) {
|
|
@@ -560,6 +606,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
560
606
|
(_a = this.fDSPCode) == null ? void 0 : _a.setPlotHandler(this.fPlotHandler);
|
|
561
607
|
break;
|
|
562
608
|
}
|
|
609
|
+
case "setupWamEventHandler": {
|
|
610
|
+
this.setupWamEventHandler();
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
563
613
|
case "start": {
|
|
564
614
|
(_b = this.fDSPCode) == null ? void 0 : _b.start();
|
|
565
615
|
break;
|
|
@@ -3619,7 +3669,7 @@ var SoundfileReader_default = SoundfileReader;
|
|
|
3619
3669
|
// src/FaustAudioWorkletNode.ts
|
|
3620
3670
|
var _hasAccInput, _hasGyrInput;
|
|
3621
3671
|
var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
|
|
3622
|
-
constructor(context, name, factory, options
|
|
3672
|
+
constructor(context, name, factory, options = {}) {
|
|
3623
3673
|
const JSONObj = JSON.parse(factory.json);
|
|
3624
3674
|
super(context, name, {
|
|
3625
3675
|
numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,
|
|
@@ -3628,8 +3678,8 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3628
3678
|
outputChannelCount: [JSONObj.outputs],
|
|
3629
3679
|
channelCountMode: "explicit",
|
|
3630
3680
|
channelInterpretation: "speakers",
|
|
3631
|
-
processorOptions: options,
|
|
3632
|
-
...
|
|
3681
|
+
processorOptions: options.processorOptions,
|
|
3682
|
+
...options
|
|
3633
3683
|
});
|
|
3634
3684
|
__privateAdd(this, _hasAccInput, false);
|
|
3635
3685
|
__privateAdd(this, _hasGyrInput, false);
|
|
@@ -3669,22 +3719,12 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3669
3719
|
async listenSensors() {
|
|
3670
3720
|
if (this.hasAccInput) {
|
|
3671
3721
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
this.propagateAcc({ x, y, z }, true);
|
|
3679
|
-
};
|
|
3680
|
-
} else {
|
|
3681
|
-
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
3682
|
-
if (!accelerationIncludingGravity)
|
|
3683
|
-
return;
|
|
3684
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
3685
|
-
this.propagateAcc({ x, y, z });
|
|
3686
|
-
};
|
|
3687
|
-
}
|
|
3722
|
+
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
3723
|
+
if (!accelerationIncludingGravity)
|
|
3724
|
+
return;
|
|
3725
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
3726
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
3727
|
+
};
|
|
3688
3728
|
if (window.DeviceMotionEvent) {
|
|
3689
3729
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
3690
3730
|
try {
|
|
@@ -3747,6 +3787,9 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3747
3787
|
getPlotHandler() {
|
|
3748
3788
|
return this.fPlotHandler;
|
|
3749
3789
|
}
|
|
3790
|
+
setupWamEventHandler() {
|
|
3791
|
+
this.port.postMessage({ type: "setupWamEventHandler" });
|
|
3792
|
+
}
|
|
3750
3793
|
getNumInputs() {
|
|
3751
3794
|
return this.fJSONDsp.inputs;
|
|
3752
3795
|
}
|
|
@@ -3840,33 +3883,25 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3840
3883
|
_hasAccInput = new WeakMap();
|
|
3841
3884
|
_hasGyrInput = new WeakMap();
|
|
3842
3885
|
var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
3843
|
-
constructor(context,
|
|
3844
|
-
super(context, name, factory,
|
|
3886
|
+
constructor(context, options) {
|
|
3887
|
+
super(context, options.processorOptions.name, options.processorOptions.factory, options);
|
|
3845
3888
|
this.onprocessorerror = (e) => {
|
|
3846
3889
|
throw e;
|
|
3847
3890
|
};
|
|
3848
3891
|
}
|
|
3849
3892
|
};
|
|
3850
3893
|
var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
3851
|
-
constructor(context,
|
|
3894
|
+
constructor(context, options) {
|
|
3852
3895
|
super(
|
|
3853
3896
|
context,
|
|
3854
|
-
name,
|
|
3855
|
-
voiceFactory,
|
|
3856
|
-
|
|
3857
|
-
name,
|
|
3858
|
-
voiceFactory,
|
|
3859
|
-
mixerModule,
|
|
3860
|
-
voices,
|
|
3861
|
-
sampleSize,
|
|
3862
|
-
effectFactory
|
|
3863
|
-
},
|
|
3864
|
-
nodeOptions
|
|
3897
|
+
options.processorOptions.name,
|
|
3898
|
+
options.processorOptions.voiceFactory,
|
|
3899
|
+
options
|
|
3865
3900
|
);
|
|
3866
3901
|
this.onprocessorerror = (e) => {
|
|
3867
3902
|
throw e;
|
|
3868
3903
|
};
|
|
3869
|
-
this.fJSONEffect = effectFactory ? JSON.parse(effectFactory.json) : null;
|
|
3904
|
+
this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;
|
|
3870
3905
|
if (this.fJSONEffect) {
|
|
3871
3906
|
FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
|
|
3872
3907
|
}
|
|
@@ -3938,22 +3973,12 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
3938
3973
|
async listenSensors() {
|
|
3939
3974
|
if (this.hasAccInput) {
|
|
3940
3975
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
this.propagateAcc({ x, y, z }, true);
|
|
3948
|
-
};
|
|
3949
|
-
} else {
|
|
3950
|
-
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
3951
|
-
if (!accelerationIncludingGravity)
|
|
3952
|
-
return;
|
|
3953
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
3954
|
-
this.propagateAcc({ x, y, z });
|
|
3955
|
-
};
|
|
3956
|
-
}
|
|
3976
|
+
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
3977
|
+
if (!accelerationIncludingGravity)
|
|
3978
|
+
return;
|
|
3979
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
3980
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
3981
|
+
};
|
|
3957
3982
|
if (window.DeviceMotionEvent) {
|
|
3958
3983
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
3959
3984
|
try {
|
|
@@ -4116,7 +4141,7 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
4116
4141
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
4117
4142
|
return Object.keys(map);
|
|
4118
4143
|
}
|
|
4119
|
-
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
|
|
4144
|
+
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
|
|
4120
4145
|
var _a, _b;
|
|
4121
4146
|
if (!factory)
|
|
4122
4147
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4174,11 +4199,11 @@ const dependencies = {
|
|
|
4174
4199
|
throw e;
|
|
4175
4200
|
}
|
|
4176
4201
|
}
|
|
4177
|
-
const node = new FaustMonoAudioWorkletNode(context, processorName, factory, sampleSize);
|
|
4202
|
+
const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
|
|
4178
4203
|
return node;
|
|
4179
4204
|
}
|
|
4180
4205
|
}
|
|
4181
|
-
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name) {
|
|
4206
|
+
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
|
|
4182
4207
|
var _a, _b;
|
|
4183
4208
|
if (!factory)
|
|
4184
4209
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4230,7 +4255,7 @@ const dependencies = {
|
|
|
4230
4255
|
throw e;
|
|
4231
4256
|
}
|
|
4232
4257
|
}
|
|
4233
|
-
const node = new FaustMonoAudioWorkletNode(context,
|
|
4258
|
+
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 } });
|
|
4234
4259
|
if (fftOptions.fftSize) {
|
|
4235
4260
|
const param = node.parameters.get("fftSize");
|
|
4236
4261
|
if (param)
|
|
@@ -4392,7 +4417,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
4392
4417
|
const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
|
|
4393
4418
|
return Object.keys({ ...effectMap, ...map });
|
|
4394
4419
|
}
|
|
4395
|
-
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
|
|
4420
|
+
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 = {}) {
|
|
4396
4421
|
var _a, _b;
|
|
4397
4422
|
if (!voiceFactory)
|
|
4398
4423
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4457,7 +4482,7 @@ const dependencies = {
|
|
|
4457
4482
|
throw e;
|
|
4458
4483
|
}
|
|
4459
4484
|
}
|
|
4460
|
-
const node = new FaustPolyAudioWorkletNode(context, processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory || void 0);
|
|
4485
|
+
const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || void 0, ...processorOptions } });
|
|
4461
4486
|
return node;
|
|
4462
4487
|
}
|
|
4463
4488
|
}
|