@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
|
@@ -894,6 +894,8 @@ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOption
|
|
|
894
894
|
export interface FaustAudioWorkletProcessorOptions {
|
|
895
895
|
name: string;
|
|
896
896
|
sampleSize: number;
|
|
897
|
+
moduleId?: string;
|
|
898
|
+
instanceId?: string;
|
|
897
899
|
}
|
|
898
900
|
export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
899
901
|
factory: LooseFaustDspFactory;
|
|
@@ -938,6 +940,8 @@ export interface FaustFFTAudioWorkletProcessorOptions {
|
|
|
938
940
|
name: string;
|
|
939
941
|
sampleSize: number;
|
|
940
942
|
factory: LooseFaustDspFactory;
|
|
943
|
+
moduleId?: string;
|
|
944
|
+
instanceId?: string;
|
|
941
945
|
}
|
|
942
946
|
export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
|
|
943
947
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
@@ -1273,7 +1277,7 @@ export declare class SoundfileReader {
|
|
|
1273
1277
|
static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
|
|
1274
1278
|
}
|
|
1275
1279
|
declare const FaustAudioWorkletNode_base: {
|
|
1276
|
-
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions
|
|
1280
|
+
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1277
1281
|
prototype: AudioWorkletNode;
|
|
1278
1282
|
};
|
|
1279
1283
|
/**
|
|
@@ -1289,7 +1293,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1289
1293
|
protected fPlotHandler: PlotHandler | null;
|
|
1290
1294
|
protected fUICallback: UIHandler;
|
|
1291
1295
|
protected fDescriptor: FaustUIInputItem[];
|
|
1292
|
-
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options
|
|
1296
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
|
|
1293
1297
|
/** Setup accelerometer and gyroscope handlers */
|
|
1294
1298
|
listenSensors(): Promise<void>;
|
|
1295
1299
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
@@ -1298,6 +1302,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1298
1302
|
getComputeHandler(): ComputeHandler | null;
|
|
1299
1303
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
1300
1304
|
getPlotHandler(): PlotHandler | null;
|
|
1305
|
+
setupWamEventHandler(): void;
|
|
1301
1306
|
getNumInputs(): number;
|
|
1302
1307
|
getNumOutputs(): number;
|
|
1303
1308
|
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
@@ -1325,7 +1330,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1325
1330
|
*/
|
|
1326
1331
|
export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
|
|
1327
1332
|
onprocessorerror: (e: Event) => never;
|
|
1328
|
-
constructor(context: BaseAudioContext,
|
|
1333
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
|
|
1329
1334
|
}
|
|
1330
1335
|
/**
|
|
1331
1336
|
* Polyphonic AudioWorkletNode
|
|
@@ -1333,7 +1338,7 @@ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<fal
|
|
|
1333
1338
|
export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
|
|
1334
1339
|
private fJSONEffect;
|
|
1335
1340
|
onprocessorerror: (e: Event) => never;
|
|
1336
|
-
constructor(context: BaseAudioContext,
|
|
1341
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
|
|
1337
1342
|
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1338
1343
|
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1339
1344
|
allNotesOff(hard: boolean): void;
|
|
@@ -1426,9 +1431,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1426
1431
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1427
1432
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1428
1433
|
* @param processorName - AudioWorklet Processor name
|
|
1434
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1429
1435
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1430
1436
|
*/
|
|
1431
|
-
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
|
|
1437
|
+
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
|
|
1432
1438
|
/**
|
|
1433
1439
|
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1434
1440
|
*
|
|
@@ -1438,9 +1444,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1438
1444
|
* @param factory - default is the compiled factory
|
|
1439
1445
|
* @param fftOptions - initial FFT options
|
|
1440
1446
|
* @param processorName - AudioWorklet Processor name
|
|
1447
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1441
1448
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1442
1449
|
*/
|
|
1443
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1450
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1444
1451
|
/**
|
|
1445
1452
|
* Create a monophonic Offline processor.
|
|
1446
1453
|
*
|
|
@@ -1496,9 +1503,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1496
1503
|
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1497
1504
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1498
1505
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1506
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1499
1507
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1500
1508
|
*/
|
|
1501
|
-
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustPolyWebAudioNode | null>;
|
|
1509
|
+
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>;
|
|
1502
1510
|
/**
|
|
1503
1511
|
* Create a monophonic Offline processor.
|
|
1504
1512
|
*
|
|
@@ -1538,8 +1546,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1538
1546
|
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1539
1547
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1540
1548
|
getSoundfileList(): string[];
|
|
1541
|
-
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>;
|
|
1542
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1549
|
+
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>;
|
|
1550
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1543
1551
|
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
1544
1552
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1545
1553
|
prototype: AudioWorkletProcessor;
|
|
@@ -1561,7 +1569,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1561
1569
|
compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
|
|
1562
1570
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1563
1571
|
getSoundfileList(): string[];
|
|
1564
|
-
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>;
|
|
1572
|
+
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>;
|
|
1565
1573
|
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1566
1574
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1567
1575
|
prototype: AudioWorkletProcessor;
|
package/dist/esm-bundle/index.js
CHANGED
|
@@ -6113,6 +6113,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6113
6113
|
parameterDescriptors.forEach((pd) => {
|
|
6114
6114
|
this.paramValuesCache[pd.name] = pd.defaultValue || 0;
|
|
6115
6115
|
});
|
|
6116
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
6117
|
+
if (!moduleId || !instanceId)
|
|
6118
|
+
return;
|
|
6119
|
+
this.wamInfo = { moduleId, instanceId };
|
|
6116
6120
|
}
|
|
6117
6121
|
static get parameterDescriptors() {
|
|
6118
6122
|
const params = [];
|
|
@@ -6126,6 +6130,23 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6126
6130
|
FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
|
|
6127
6131
|
return params;
|
|
6128
6132
|
}
|
|
6133
|
+
setupWamEventHandler() {
|
|
6134
|
+
var _a;
|
|
6135
|
+
if (!this.wamInfo)
|
|
6136
|
+
return;
|
|
6137
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
6138
|
+
const { webAudioModules } = globalThis;
|
|
6139
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
6140
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
6141
|
+
if (!paramMgrProcessor)
|
|
6142
|
+
return;
|
|
6143
|
+
if (paramMgrProcessor.handleEvent)
|
|
6144
|
+
return;
|
|
6145
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
6146
|
+
if (event.type === "wam-midi")
|
|
6147
|
+
this.midiMessage(event.data.bytes);
|
|
6148
|
+
};
|
|
6149
|
+
}
|
|
6129
6150
|
process(inputs, outputs, parameters) {
|
|
6130
6151
|
for (const path in parameters) {
|
|
6131
6152
|
const [paramValue] = parameters[path];
|
|
@@ -6171,6 +6192,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6171
6192
|
}
|
|
6172
6193
|
break;
|
|
6173
6194
|
}
|
|
6195
|
+
case "setupWamEventHandler": {
|
|
6196
|
+
this.setupWamEventHandler();
|
|
6197
|
+
break;
|
|
6198
|
+
}
|
|
6174
6199
|
case "start": {
|
|
6175
6200
|
this.fDSPCode.start();
|
|
6176
6201
|
break;
|
|
@@ -6380,6 +6405,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6380
6405
|
this.sampleSize = sampleSize;
|
|
6381
6406
|
this.soundfiles = factory.soundfiles;
|
|
6382
6407
|
this.initFFT();
|
|
6408
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
6409
|
+
if (!moduleId || !instanceId)
|
|
6410
|
+
return;
|
|
6411
|
+
this.wamInfo = { moduleId, instanceId };
|
|
6383
6412
|
}
|
|
6384
6413
|
get fftProcessorBufferSize() {
|
|
6385
6414
|
return this.fftSize / 2 + 1;
|
|
@@ -6425,6 +6454,23 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6425
6454
|
}
|
|
6426
6455
|
];
|
|
6427
6456
|
}
|
|
6457
|
+
setupWamEventHandler() {
|
|
6458
|
+
var _a;
|
|
6459
|
+
if (!this.wamInfo)
|
|
6460
|
+
return;
|
|
6461
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
6462
|
+
const { webAudioModules } = globalThis;
|
|
6463
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
6464
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
6465
|
+
if (!paramMgrProcessor)
|
|
6466
|
+
return;
|
|
6467
|
+
if (paramMgrProcessor.handleEvent)
|
|
6468
|
+
return;
|
|
6469
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
6470
|
+
if (event.type === "wam-midi")
|
|
6471
|
+
this.midiMessage(event.data.bytes);
|
|
6472
|
+
};
|
|
6473
|
+
}
|
|
6428
6474
|
processFFT() {
|
|
6429
6475
|
let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;
|
|
6430
6476
|
while (samplesForFFT >= this.fftSize) {
|
|
@@ -6562,6 +6608,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6562
6608
|
(_a = this.fDSPCode) == null ? void 0 : _a.setPlotHandler(this.fPlotHandler);
|
|
6563
6609
|
break;
|
|
6564
6610
|
}
|
|
6611
|
+
case "setupWamEventHandler": {
|
|
6612
|
+
this.setupWamEventHandler();
|
|
6613
|
+
break;
|
|
6614
|
+
}
|
|
6565
6615
|
case "start": {
|
|
6566
6616
|
(_b = this.fDSPCode) == null ? void 0 : _b.start();
|
|
6567
6617
|
break;
|
|
@@ -9621,7 +9671,7 @@ var SoundfileReader_default = SoundfileReader;
|
|
|
9621
9671
|
// src/FaustAudioWorkletNode.ts
|
|
9622
9672
|
var _hasAccInput, _hasGyrInput;
|
|
9623
9673
|
var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
|
|
9624
|
-
constructor(context, name, factory, options
|
|
9674
|
+
constructor(context, name, factory, options = {}) {
|
|
9625
9675
|
const JSONObj = JSON.parse(factory.json);
|
|
9626
9676
|
super(context, name, {
|
|
9627
9677
|
numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,
|
|
@@ -9630,8 +9680,8 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9630
9680
|
outputChannelCount: [JSONObj.outputs],
|
|
9631
9681
|
channelCountMode: "explicit",
|
|
9632
9682
|
channelInterpretation: "speakers",
|
|
9633
|
-
processorOptions: options,
|
|
9634
|
-
...
|
|
9683
|
+
processorOptions: options.processorOptions,
|
|
9684
|
+
...options
|
|
9635
9685
|
});
|
|
9636
9686
|
__privateAdd(this, _hasAccInput, false);
|
|
9637
9687
|
__privateAdd(this, _hasGyrInput, false);
|
|
@@ -9671,22 +9721,12 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9671
9721
|
async listenSensors() {
|
|
9672
9722
|
if (this.hasAccInput) {
|
|
9673
9723
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
this.propagateAcc({ x, y, z }, true);
|
|
9681
|
-
};
|
|
9682
|
-
} else {
|
|
9683
|
-
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9684
|
-
if (!accelerationIncludingGravity)
|
|
9685
|
-
return;
|
|
9686
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
9687
|
-
this.propagateAcc({ x, y, z });
|
|
9688
|
-
};
|
|
9689
|
-
}
|
|
9724
|
+
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9725
|
+
if (!accelerationIncludingGravity)
|
|
9726
|
+
return;
|
|
9727
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9728
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9729
|
+
};
|
|
9690
9730
|
if (window.DeviceMotionEvent) {
|
|
9691
9731
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9692
9732
|
try {
|
|
@@ -9749,6 +9789,9 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9749
9789
|
getPlotHandler() {
|
|
9750
9790
|
return this.fPlotHandler;
|
|
9751
9791
|
}
|
|
9792
|
+
setupWamEventHandler() {
|
|
9793
|
+
this.port.postMessage({ type: "setupWamEventHandler" });
|
|
9794
|
+
}
|
|
9752
9795
|
getNumInputs() {
|
|
9753
9796
|
return this.fJSONDsp.inputs;
|
|
9754
9797
|
}
|
|
@@ -9842,33 +9885,25 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9842
9885
|
_hasAccInput = new WeakMap();
|
|
9843
9886
|
_hasGyrInput = new WeakMap();
|
|
9844
9887
|
var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
9845
|
-
constructor(context,
|
|
9846
|
-
super(context, name, factory,
|
|
9888
|
+
constructor(context, options) {
|
|
9889
|
+
super(context, options.processorOptions.name, options.processorOptions.factory, options);
|
|
9847
9890
|
this.onprocessorerror = (e) => {
|
|
9848
9891
|
throw e;
|
|
9849
9892
|
};
|
|
9850
9893
|
}
|
|
9851
9894
|
};
|
|
9852
9895
|
var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
9853
|
-
constructor(context,
|
|
9896
|
+
constructor(context, options) {
|
|
9854
9897
|
super(
|
|
9855
9898
|
context,
|
|
9856
|
-
name,
|
|
9857
|
-
voiceFactory,
|
|
9858
|
-
|
|
9859
|
-
name,
|
|
9860
|
-
voiceFactory,
|
|
9861
|
-
mixerModule,
|
|
9862
|
-
voices,
|
|
9863
|
-
sampleSize,
|
|
9864
|
-
effectFactory
|
|
9865
|
-
},
|
|
9866
|
-
nodeOptions
|
|
9899
|
+
options.processorOptions.name,
|
|
9900
|
+
options.processorOptions.voiceFactory,
|
|
9901
|
+
options
|
|
9867
9902
|
);
|
|
9868
9903
|
this.onprocessorerror = (e) => {
|
|
9869
9904
|
throw e;
|
|
9870
9905
|
};
|
|
9871
|
-
this.fJSONEffect = effectFactory ? JSON.parse(effectFactory.json) : null;
|
|
9906
|
+
this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;
|
|
9872
9907
|
if (this.fJSONEffect) {
|
|
9873
9908
|
FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
|
|
9874
9909
|
}
|
|
@@ -9940,22 +9975,12 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9940
9975
|
async listenSensors() {
|
|
9941
9976
|
if (this.hasAccInput) {
|
|
9942
9977
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
this.propagateAcc({ x, y, z }, true);
|
|
9950
|
-
};
|
|
9951
|
-
} else {
|
|
9952
|
-
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9953
|
-
if (!accelerationIncludingGravity)
|
|
9954
|
-
return;
|
|
9955
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
9956
|
-
this.propagateAcc({ x, y, z });
|
|
9957
|
-
};
|
|
9958
|
-
}
|
|
9978
|
+
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9979
|
+
if (!accelerationIncludingGravity)
|
|
9980
|
+
return;
|
|
9981
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9982
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9983
|
+
};
|
|
9959
9984
|
if (window.DeviceMotionEvent) {
|
|
9960
9985
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9961
9986
|
try {
|
|
@@ -10118,7 +10143,7 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
10118
10143
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
10119
10144
|
return Object.keys(map);
|
|
10120
10145
|
}
|
|
10121
|
-
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
|
|
10146
|
+
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
|
|
10122
10147
|
var _a, _b;
|
|
10123
10148
|
if (!factory)
|
|
10124
10149
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -10176,11 +10201,11 @@ const dependencies = {
|
|
|
10176
10201
|
throw e;
|
|
10177
10202
|
}
|
|
10178
10203
|
}
|
|
10179
|
-
const node = new FaustMonoAudioWorkletNode(context, processorName, factory, sampleSize);
|
|
10204
|
+
const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
|
|
10180
10205
|
return node;
|
|
10181
10206
|
}
|
|
10182
10207
|
}
|
|
10183
|
-
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name) {
|
|
10208
|
+
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
|
|
10184
10209
|
var _a, _b;
|
|
10185
10210
|
if (!factory)
|
|
10186
10211
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -10232,7 +10257,7 @@ const dependencies = {
|
|
|
10232
10257
|
throw e;
|
|
10233
10258
|
}
|
|
10234
10259
|
}
|
|
10235
|
-
const node = new FaustMonoAudioWorkletNode(context,
|
|
10260
|
+
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 } });
|
|
10236
10261
|
if (fftOptions.fftSize) {
|
|
10237
10262
|
const param = node.parameters.get("fftSize");
|
|
10238
10263
|
if (param)
|
|
@@ -10394,7 +10419,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
10394
10419
|
const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
|
|
10395
10420
|
return Object.keys({ ...effectMap, ...map });
|
|
10396
10421
|
}
|
|
10397
|
-
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
|
|
10422
|
+
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 = {}) {
|
|
10398
10423
|
var _a, _b;
|
|
10399
10424
|
if (!voiceFactory)
|
|
10400
10425
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -10459,7 +10484,7 @@ const dependencies = {
|
|
|
10459
10484
|
throw e;
|
|
10460
10485
|
}
|
|
10461
10486
|
}
|
|
10462
|
-
const node = new FaustPolyAudioWorkletNode(context, processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory || void 0);
|
|
10487
|
+
const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || void 0, ...processorOptions } });
|
|
10463
10488
|
return node;
|
|
10464
10489
|
}
|
|
10465
10490
|
}
|