@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.
@@ -383,6 +383,12 @@ export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: numb
383
383
  }[]) => void;
384
384
  export type MetadataHandler = (key: string, value: string) => void;
385
385
  export type UIHandler = (item: FaustUIItem) => void;
386
+ export type SensorEventHandler = (val: number) => void;
387
+ export type SensorEventHandlers = {
388
+ x: SensorEventHandler[];
389
+ y: SensorEventHandler[];
390
+ z: SensorEventHandler[];
391
+ };
386
392
  /** Definition of the AudioBufferItem type */
387
393
  export interface AudioBufferItem {
388
394
  pathName: string;
@@ -488,10 +494,10 @@ export declare class Soundfile {
488
494
  getHEAPFloat64(): Float64Array;
489
495
  }
490
496
  /**
491
- * DSP implementation: mimic the C++ 'dsp' class:
497
+ * DSP implementation that mimic the C++ 'dsp' class:
492
498
  * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
493
499
  * - an output handler can be set to treat produced output controllers (like 'bargraph')
494
- * - regular controllers are handled using setParamValue/getParamValue
500
+ * - regular controllers are handled using setParamValue/getParamValue and getParams methods
495
501
  */
496
502
  export interface IFaustBaseWebAudioDsp {
497
503
  /**
@@ -603,12 +609,6 @@ export interface IFaustBaseWebAudioDsp {
603
609
  * @return the DSP JSON description as object
604
610
  */
605
611
  getMeta(): FaustDspMeta;
606
- /**
607
- * Get DSP JSON description with its UI and metadata.
608
- *
609
- * @return the DSP JSON description
610
- */
611
- getJSON(): string;
612
612
  /**
613
613
  * Get DSP UI description.
614
614
  *
@@ -621,6 +621,12 @@ export interface IFaustBaseWebAudioDsp {
621
621
  * @return the DSP UI items description
622
622
  */
623
623
  getDescriptors(): FaustUIInputItem[];
624
+ /**
625
+ * Get DSP JSON description with its UI and metadata.
626
+ *
627
+ * @return the DSP JSON description
628
+ */
629
+ getJSON(): string;
624
630
  /**
625
631
  * Start the DSP.
626
632
  */
@@ -633,6 +639,14 @@ export interface IFaustBaseWebAudioDsp {
633
639
  * Destroy the DSP.
634
640
  */
635
641
  destroy(): void;
642
+ /** Indicating if the DSP handles the accelerometer */
643
+ readonly hasAccInput: boolean;
644
+ /** Accelerometer handling */
645
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
646
+ /** Indicating if the DSP handles the gyroscope */
647
+ readonly hasGyrInput: boolean;
648
+ /** Gyroscope handling */
649
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
636
650
  }
637
651
  export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
638
652
  }
@@ -683,6 +697,8 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
683
697
  protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"];
684
698
  /** Keep the end of memory offset before soundfiles */
685
699
  protected fEndMemory: number;
700
+ protected fAcc: SensorEventHandlers;
701
+ protected fGyr: SensorEventHandlers;
686
702
  protected fAudioInputs: number;
687
703
  protected fAudioOutputs: number;
688
704
  protected fBufferSize: number;
@@ -714,6 +730,14 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
714
730
  static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
715
731
  /** Split the soundfile names and return an array of names */
716
732
  static splitSoundfileNames(input: string): string[];
733
+ get hasAccInput(): boolean;
734
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
735
+ get hasGyrInput(): boolean;
736
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
737
+ /** Build the accelerometer handler */
738
+ private setupAccHandler;
739
+ /** Build the gyroscope handler */
740
+ private setupGyrHandler;
717
741
  static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[];
718
742
  /**
719
743
  * Load a soundfile possibly containing several parts in the DSP struct.
@@ -1105,6 +1129,10 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
1105
1129
  start(): void;
1106
1130
  stop(): void;
1107
1131
  destroy(): void;
1132
+ get hasAccInput(): boolean;
1133
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
1134
+ get hasGyrInput(): boolean;
1135
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1108
1136
  /**
1109
1137
  * Render frames in an array.
1110
1138
  *
@@ -1246,6 +1274,7 @@ declare const FaustAudioWorkletNode_base: {
1246
1274
  * Base class for Monophonic and Polyphonic AudioWorkletNode
1247
1275
  */
1248
1276
  export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
1277
+ #private;
1249
1278
  protected fJSONDsp: FaustDspMeta;
1250
1279
  protected fJSON: string;
1251
1280
  protected fInputsItems: string[];
@@ -1255,6 +1284,8 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1255
1284
  protected fUICallback: UIHandler;
1256
1285
  protected fDescriptor: FaustUIInputItem[];
1257
1286
  constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1287
+ /** Setup accelerometer and gyroscope handlers */
1288
+ listenMotion(): Promise<void>;
1258
1289
  setOutputParamHandler(handler: OutputParamHandler | null): void;
1259
1290
  getOutputParamHandler(): OutputParamHandler | null;
1260
1291
  setComputeHandler(handler: ComputeHandler | null): void;
@@ -1268,6 +1299,10 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1268
1299
  midiMessage(data: number[] | Uint8Array): void;
1269
1300
  ctrlChange(channel: number, ctrl: number, value: number): void;
1270
1301
  pitchWheel(channel: number, wheel: number): void;
1302
+ get hasAccInput(): boolean;
1303
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
1304
+ get hasGyrInput(): boolean;
1305
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1271
1306
  setParamValue(path: string, value: number): void;
1272
1307
  getParamValue(path: string): number;
1273
1308
  getParams(): string[];
@@ -1312,6 +1347,8 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
1312
1347
  protected fInputs: Float32Array[];
1313
1348
  protected fOutputs: Float32Array[];
1314
1349
  init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
1350
+ /** Setup accelerometer and gyroscope handlers */
1351
+ listenMotion(): Promise<void>;
1315
1352
  compute(input: Float32Array[], output: Float32Array[]): boolean;
1316
1353
  setOutputParamHandler(handler: OutputParamHandler): void;
1317
1354
  getOutputParamHandler(): OutputParamHandler | null;
@@ -1335,6 +1372,10 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
1335
1372
  start(): void;
1336
1373
  stop(): void;
1337
1374
  destroy(): void;
1375
+ get hasAccInput(): boolean;
1376
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
1377
+ get hasGyrInput(): boolean;
1378
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1338
1379
  }
1339
1380
  export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
1340
1381
  }