@grame/faustwasm 0.2.2 → 0.3.0
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 +2 -0
- package/assets/standalone/faustwasm/index.d.ts +49 -8
- package/assets/standalone/faustwasm/index.js +538 -15
- package/assets/standalone/faustwasm/index.js.map +3 -3
- package/assets/standalone/index.js +17 -11
- package/dist/cjs/index.d.ts +49 -8
- package/dist/cjs/index.js +537 -15
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs-bundle/index.d.ts +49 -8
- package/dist/cjs-bundle/index.js +540 -18
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.d.ts +49 -8
- package/dist/esm/index.js +538 -15
- package/dist/esm/index.js.map +3 -3
- package/dist/esm-bundle/index.d.ts +49 -8
- package/dist/esm-bundle/index.js +540 -18
- package/dist/esm-bundle/index.js.map +3 -3
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +73 -0
- package/src/FaustAudioWorkletProcessor.ts +33 -4
- package/src/FaustDspGenerator.ts +14 -2
- package/src/FaustOfflineProcessor.ts +10 -0
- package/src/FaustScriptProcessorNode.ts +61 -1
- package/src/FaustSensors.ts +370 -0
- package/src/FaustWebAudioDsp.ts +122 -23
- package/test/faustlive-wasm/faustwasm/index.d.ts +49 -8
- package/test/faustlive-wasm/faustwasm/index.js +538 -15
- package/test/faustlive-wasm/faustwasm/index.js.map +3 -3
- package/test/faustlive-wasm/index.js +2 -0
- package/test/mono.dsp +1 -0
- package/test/osc.dsp +4 -2
package/README.md
CHANGED
|
@@ -283,6 +283,8 @@ This level takes a Faust Wasm instance to build an audio node. [AudioWorklet](ht
|
|
|
283
283
|
|
|
284
284
|
**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.
|
|
285
285
|
|
|
286
|
+
The audio node API documentation can be [accessed here](https://github.com/search?q=repo%3Agrame-cncm%2Ffaustwasm%20IFaustBaseWebAudioDsp&type=code).
|
|
287
|
+
|
|
286
288
|
Note that ScriptProcessor is marked as [deprecated](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) but it's the only audio architecture available in older Safari versions. Both monophonic (generators, effects...) or polyphonic (instruments) nodes can be created. It is described in `FaustScriptProcessorNode.ts` file.
|
|
287
289
|
|
|
288
290
|
Created audio nodes have a `start` and `stop` methods. When started (which is done by default), they are processing audio buffers. You may have to explicitly stop them to save CPU (and start then again when needed), if for instance several nodes are created at init time before actual use.
|
|
@@ -376,6 +376,12 @@ export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: numb
|
|
|
376
376
|
}[]) => void;
|
|
377
377
|
export type MetadataHandler = (key: string, value: string) => void;
|
|
378
378
|
export type UIHandler = (item: FaustUIItem) => void;
|
|
379
|
+
export type SensorEventHandler = (val: number) => void;
|
|
380
|
+
export type SensorEventHandlers = {
|
|
381
|
+
x: SensorEventHandler[];
|
|
382
|
+
y: SensorEventHandler[];
|
|
383
|
+
z: SensorEventHandler[];
|
|
384
|
+
};
|
|
379
385
|
/** Definition of the AudioBufferItem type */
|
|
380
386
|
export interface AudioBufferItem {
|
|
381
387
|
pathName: string;
|
|
@@ -481,10 +487,10 @@ export declare class Soundfile {
|
|
|
481
487
|
getHEAPFloat64(): Float64Array;
|
|
482
488
|
}
|
|
483
489
|
/**
|
|
484
|
-
* DSP implementation
|
|
490
|
+
* DSP implementation that mimic the C++ 'dsp' class:
|
|
485
491
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
486
492
|
* - an output handler can be set to treat produced output controllers (like 'bargraph')
|
|
487
|
-
* - regular controllers are handled using setParamValue/getParamValue
|
|
493
|
+
* - regular controllers are handled using setParamValue/getParamValue and getParams methods
|
|
488
494
|
*/
|
|
489
495
|
export interface IFaustBaseWebAudioDsp {
|
|
490
496
|
/**
|
|
@@ -596,12 +602,6 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
596
602
|
* @return the DSP JSON description as object
|
|
597
603
|
*/
|
|
598
604
|
getMeta(): FaustDspMeta;
|
|
599
|
-
/**
|
|
600
|
-
* Get DSP JSON description with its UI and metadata.
|
|
601
|
-
*
|
|
602
|
-
* @return the DSP JSON description
|
|
603
|
-
*/
|
|
604
|
-
getJSON(): string;
|
|
605
605
|
/**
|
|
606
606
|
* Get DSP UI description.
|
|
607
607
|
*
|
|
@@ -614,6 +614,12 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
614
614
|
* @return the DSP UI items description
|
|
615
615
|
*/
|
|
616
616
|
getDescriptors(): FaustUIInputItem[];
|
|
617
|
+
/**
|
|
618
|
+
* Get DSP JSON description with its UI and metadata.
|
|
619
|
+
*
|
|
620
|
+
* @return the DSP JSON description
|
|
621
|
+
*/
|
|
622
|
+
getJSON(): string;
|
|
617
623
|
/**
|
|
618
624
|
* Start the DSP.
|
|
619
625
|
*/
|
|
@@ -626,6 +632,14 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
626
632
|
* Destroy the DSP.
|
|
627
633
|
*/
|
|
628
634
|
destroy(): void;
|
|
635
|
+
/** Indicating if the DSP handles the accelerometer */
|
|
636
|
+
readonly hasAccInput: boolean;
|
|
637
|
+
/** Accelerometer handling */
|
|
638
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
639
|
+
/** Indicating if the DSP handles the gyroscope */
|
|
640
|
+
readonly hasGyrInput: boolean;
|
|
641
|
+
/** Gyroscope handling */
|
|
642
|
+
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
629
643
|
}
|
|
630
644
|
export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
631
645
|
}
|
|
@@ -676,6 +690,8 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
676
690
|
protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"];
|
|
677
691
|
/** Keep the end of memory offset before soundfiles */
|
|
678
692
|
protected fEndMemory: number;
|
|
693
|
+
protected fAcc: SensorEventHandlers;
|
|
694
|
+
protected fGyr: SensorEventHandlers;
|
|
679
695
|
protected fAudioInputs: number;
|
|
680
696
|
protected fAudioOutputs: number;
|
|
681
697
|
protected fBufferSize: number;
|
|
@@ -707,6 +723,14 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
707
723
|
static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
|
|
708
724
|
/** Split the soundfile names and return an array of names */
|
|
709
725
|
static splitSoundfileNames(input: string): string[];
|
|
726
|
+
get hasAccInput(): boolean;
|
|
727
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
728
|
+
get hasGyrInput(): boolean;
|
|
729
|
+
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
730
|
+
/** Build the accelerometer handler */
|
|
731
|
+
private setupAccHandler;
|
|
732
|
+
/** Build the gyroscope handler */
|
|
733
|
+
private setupGyrHandler;
|
|
710
734
|
static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[];
|
|
711
735
|
/**
|
|
712
736
|
* Load a soundfile possibly containing several parts in the DSP struct.
|
|
@@ -1098,6 +1122,10 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
|
1098
1122
|
start(): void;
|
|
1099
1123
|
stop(): void;
|
|
1100
1124
|
destroy(): void;
|
|
1125
|
+
get hasAccInput(): boolean;
|
|
1126
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
1127
|
+
get hasGyrInput(): boolean;
|
|
1128
|
+
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1101
1129
|
/**
|
|
1102
1130
|
* Render frames in an array.
|
|
1103
1131
|
*
|
|
@@ -1239,6 +1267,7 @@ declare const FaustAudioWorkletNode_base: {
|
|
|
1239
1267
|
* Base class for Monophonic and Polyphonic AudioWorkletNode
|
|
1240
1268
|
*/
|
|
1241
1269
|
export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
|
|
1270
|
+
#private;
|
|
1242
1271
|
protected fJSONDsp: FaustDspMeta;
|
|
1243
1272
|
protected fJSON: string;
|
|
1244
1273
|
protected fInputsItems: string[];
|
|
@@ -1248,6 +1277,8 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1248
1277
|
protected fUICallback: UIHandler;
|
|
1249
1278
|
protected fDescriptor: FaustUIInputItem[];
|
|
1250
1279
|
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
|
|
1280
|
+
/** Setup accelerometer and gyroscope handlers */
|
|
1281
|
+
listenMotion(): Promise<void>;
|
|
1251
1282
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1252
1283
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1253
1284
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
@@ -1261,6 +1292,10 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1261
1292
|
midiMessage(data: number[] | Uint8Array): void;
|
|
1262
1293
|
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
1263
1294
|
pitchWheel(channel: number, wheel: number): void;
|
|
1295
|
+
get hasAccInput(): boolean;
|
|
1296
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
1297
|
+
get hasGyrInput(): boolean;
|
|
1298
|
+
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1264
1299
|
setParamValue(path: string, value: number): void;
|
|
1265
1300
|
getParamValue(path: string): number;
|
|
1266
1301
|
getParams(): string[];
|
|
@@ -1305,6 +1340,8 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1305
1340
|
protected fInputs: Float32Array[];
|
|
1306
1341
|
protected fOutputs: Float32Array[];
|
|
1307
1342
|
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
|
|
1343
|
+
/** Setup accelerometer and gyroscope handlers */
|
|
1344
|
+
listenMotion(): Promise<void>;
|
|
1308
1345
|
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
1309
1346
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1310
1347
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
@@ -1328,6 +1365,10 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1328
1365
|
start(): void;
|
|
1329
1366
|
stop(): void;
|
|
1330
1367
|
destroy(): void;
|
|
1368
|
+
get hasAccInput(): boolean;
|
|
1369
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
1370
|
+
get hasGyrInput(): boolean;
|
|
1371
|
+
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1331
1372
|
}
|
|
1332
1373
|
export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
|
|
1333
1374
|
}
|