@grame/faustwasm 0.11.0 → 0.11.2

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.
@@ -425,17 +425,6 @@ export type SensorEventHandlers = {
425
425
  y: SensorEventHandler[];
426
426
  z: SensorEventHandler[];
427
427
  };
428
- /**
429
- * Interface for MIDI output handler, used in Faust WebAudio nodes
430
- * to handle MIDI events like control changes, pitch wheel changes,
431
- * key on and key off events.
432
- */
433
- export interface MidiOutputHandler {
434
- ctrlChange(chan: number, ctrl: number, value: number): void;
435
- pitchWheel(chan: number, value: number): void;
436
- keyOn(channel: number, pitch: number, velocity: number): void;
437
- keyOff(channel: number, pitch: number, velocity: number): void;
438
- }
439
428
  /** Definition of the AudioBufferItem type */
440
429
  export interface AudioBufferItem {
441
430
  pathName: string;
@@ -578,18 +567,6 @@ export interface IFaustBaseWebAudioDsp {
578
567
  * @return the current output handler
579
568
  */
580
569
  getComputeHandler(): ComputeHandler | null;
581
- /**
582
- * Set the MIDI output handler, to be called in the 'compute' method with MIDI messages.
583
- * @param handler - the MIDI output handler
584
- * @return void
585
- */
586
- setMidiOutputHandler(handler: MidiOutputHandler | null): void;
587
- /**
588
- * Get the MIDI output handler.
589
- *
590
- * @return the current MIDI output handler
591
- */
592
- getMidiOutputHandler(): MidiOutputHandler | null;
593
570
  /**
594
571
  * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).
595
572
  *
@@ -776,7 +753,6 @@ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode
776
753
  export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
777
754
  protected fOutputHandler: OutputParamHandler | null;
778
755
  protected fComputeHandler: ComputeHandler | null;
779
- protected fMidiOutputHandler: MidiOutputHandler | null;
780
756
  protected fPlotHandler: PlotHandler | null;
781
757
  protected fCachedEvents: {
782
758
  type: string;
@@ -883,8 +859,6 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
883
859
  callOutputParamHandler(path: string, value: number): void;
884
860
  setComputeHandler(handler: ComputeHandler | null): void;
885
861
  getComputeHandler(): ComputeHandler | null;
886
- setMidiOutputHandler(handler: MidiOutputHandler | null): void;
887
- getMidiOutputHandler(): MidiOutputHandler | null;
888
862
  setPlotHandler(handler: PlotHandler | null): void;
889
863
  getPlotHandler(): PlotHandler | null;
890
864
  getNumInputs(): number;
@@ -1239,8 +1213,6 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
1239
1213
  callOutputParamHandler(path: string, value: number): void;
1240
1214
  setComputeHandler(handler: ComputeHandler): void;
1241
1215
  getComputeHandler(): ComputeHandler | null;
1242
- setMidiOutputHandler(handler: MidiOutputHandler | null): void;
1243
- getMidiOutputHandler(): MidiOutputHandler | null;
1244
1216
  setPlotHandler(handler: PlotHandler): void;
1245
1217
  getPlotHandler(): PlotHandler | null;
1246
1218
  getNumInputs(): number;
@@ -1327,7 +1299,7 @@ export interface WavEncoderOptions {
1327
1299
  * Code from https://github.com/mohayonao/wav-encoder
1328
1300
  */
1329
1301
  export declare class WavEncoder {
1330
- static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer;
1302
+ static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer | SharedArrayBuffer;
1331
1303
  private static writeHeader;
1332
1304
  private static writeData;
1333
1305
  }
@@ -1420,7 +1392,6 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1420
1392
  protected fInputsItems: string[];
1421
1393
  protected fOutputHandler: OutputParamHandler | null;
1422
1394
  protected fComputeHandler: ComputeHandler | null;
1423
- protected fMidiOutputHandler: MidiOutputHandler | null;
1424
1395
  protected fPlotHandler: PlotHandler | null;
1425
1396
  protected fUICallback: UIHandler;
1426
1397
  protected fDescriptor: FaustUIInputItem[];
@@ -1437,8 +1408,6 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1437
1408
  callOutputParamHandler(path: string, value: number): void;
1438
1409
  setComputeHandler(handler: ComputeHandler | null): void;
1439
1410
  getComputeHandler(): ComputeHandler | null;
1440
- setMidiOutputHandler(handler: MidiOutputHandler | null): void;
1441
- getMidiOutputHandler(): MidiOutputHandler | null;
1442
1411
  setPlotHandler(handler: PlotHandler | null): void;
1443
1412
  getPlotHandler(): PlotHandler | null;
1444
1413
  setupWamEventHandler(): void;
@@ -1513,8 +1482,6 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
1513
1482
  getComputeHandler(): ComputeHandler | null;
1514
1483
  setPlotHandler(handler: PlotHandler): void;
1515
1484
  getPlotHandler(): PlotHandler | null;
1516
- setMidiOutputHandler(handler: MidiOutputHandler | null): void;
1517
- getMidiOutputHandler(): MidiOutputHandler | null;
1518
1485
  getNumInputs(): number;
1519
1486
  getNumOutputs(): number;
1520
1487
  metadata(handler: MetadataHandler): void;
package/dist/cjs/index.js CHANGED
@@ -65,7 +65,7 @@ export default ${(_a = jsCode.match(jsCodeHead)) == null ? void 0 : _a[1]};
65
65
  jsFileMod
66
66
  )).default;
67
67
  dataBinary = await (await fetch(dataFile)).arrayBuffer();
68
- wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());
68
+ wasmBinary = await (await fetch(wasmFile)).arrayBuffer();
69
69
  } else {
70
70
  const { promises: fs } = await import("fs");
71
71
  const { pathToFileURL } = await import("url");
@@ -91,8 +91,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
91
91
  pathToFileURL(jsFileMod).href
92
92
  )).default;
93
93
  await fs.unlink(jsFileMod);
94
- dataBinary = (await fs.readFile(dataFile)).buffer;
95
- wasmBinary = (await fs.readFile(wasmFile)).buffer;
94
+ dataBinary = new Uint8Array(await fs.readFile(dataFile)).buffer;
95
+ wasmBinary = new Uint8Array(await fs.readFile(wasmFile)).buffer;
96
96
  }
97
97
  const faustModule = await FaustModule({
98
98
  wasmBinary,
@@ -1213,7 +1213,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1213
1213
  }
1214
1214
 
1215
1215
  // src/FaustCompiler.ts
1216
- var ab2str = (buf) => String.fromCharCode.apply(null, buf);
1216
+ var ab2str = (buf) => String.fromCharCode.apply(null, Array.from(buf));
1217
1217
  var str2ab = (str) => {
1218
1218
  const buf = new ArrayBuffer(str.length);
1219
1219
  const bufView = new Uint8Array(buf);
@@ -1351,7 +1351,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1351
1351
  const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
1352
1352
  const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
1353
1353
  this[bufferKey] = mixerBuffer;
1354
- const mixerModule = await WebAssembly.compile(mixerBuffer);
1354
+ const mixerModule = await WebAssembly.compile(new Uint8Array(mixerBuffer));
1355
1355
  this[moduleKey] = mixerModule;
1356
1356
  return { mixerBuffer, mixerModule };
1357
1357
  }
@@ -1363,7 +1363,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1363
1363
  const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
1364
1364
  const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
1365
1365
  this[bufferKey] = mixerBuffer;
1366
- const mixerModule = new WebAssembly.Module(mixerBuffer);
1366
+ const mixerModule = new WebAssembly.Module(new Uint8Array(mixerBuffer));
1367
1367
  this[moduleKey] = mixerModule;
1368
1368
  return { mixerBuffer, mixerModule };
1369
1369
  }
@@ -1555,7 +1555,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1555
1555
  try {
1556
1556
  let mixerBuffer = null;
1557
1557
  if (fs) {
1558
- mixerBuffer = fs.readFile(mixerPath, { encoding: "binary" });
1558
+ mixerBuffer = new Uint8Array(fs.readFile(mixerPath, { encoding: "binary" }));
1559
1559
  } else {
1560
1560
  const mixerFile = await fetch(mixerPath);
1561
1561
  mixerBuffer = await mixerFile.arrayBuffer();
@@ -2137,7 +2137,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2137
2137
  constructor(sampleSize, bufferSize, soundfiles) {
2138
2138
  this.fOutputHandler = null;
2139
2139
  this.fComputeHandler = null;
2140
- this.fMidiOutputHandler = null;
2141
2140
  // To handle MIDI events plot
2142
2141
  this.fPlotHandler = null;
2143
2142
  this.fCachedEvents = [];
@@ -2439,7 +2438,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2439
2438
  if (this.fOutputHandler) {
2440
2439
  this.fOutputHandler(path, value);
2441
2440
  } else {
2442
- console.warn("No OutputParamHandler set for this FaustAudioWorkletNode.");
2441
+ console.warn("No OutputParamHandler set for this Faust node.");
2443
2442
  }
2444
2443
  }
2445
2444
  setComputeHandler(handler) {
@@ -2448,12 +2447,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2448
2447
  getComputeHandler() {
2449
2448
  return this.fComputeHandler;
2450
2449
  }
2451
- setMidiOutputHandler(handler) {
2452
- this.fMidiOutputHandler = handler;
2453
- }
2454
- getMidiOutputHandler() {
2455
- return this.fMidiOutputHandler;
2456
- }
2457
2450
  setPlotHandler(handler) {
2458
2451
  this.fPlotHandler = handler;
2459
2452
  }
@@ -2592,7 +2585,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2592
2585
  this.fDestroyed = true;
2593
2586
  this.fOutputHandler = null;
2594
2587
  this.fComputeHandler = null;
2595
- this.fMidiOutputHandler = null;
2596
2588
  this.fPlotHandler = null;
2597
2589
  }
2598
2590
  };
@@ -3158,12 +3150,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3158
3150
  getComputeHandler() {
3159
3151
  return this.fDSPCode.getComputeHandler();
3160
3152
  }
3161
- setMidiOutputHandler(handler) {
3162
- this.fDSPCode.setMidiOutputHandler(handler);
3163
- }
3164
- getMidiOutputHandler() {
3165
- return this.fDSPCode.getMidiOutputHandler();
3166
- }
3167
3153
  setPlotHandler(handler) {
3168
3154
  this.fDSPCode.setPlotHandler(handler);
3169
3155
  }
@@ -4006,7 +3992,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4006
3992
  processorOptions: options.processorOptions,
4007
3993
  ...options
4008
3994
  });
4009
- this.fMidiOutputHandler = null;
4010
3995
  __privateAdd(this, _hasAccInput, false);
4011
3996
  __privateAdd(this, _hasGyrInput, false);
4012
3997
  this.handleMessageAux = (e) => {
@@ -4090,7 +4075,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4090
4075
  if (this.fOutputHandler) {
4091
4076
  this.fOutputHandler(path, value);
4092
4077
  } else {
4093
- console.warn("No OutputParamHandler set for this FaustAudioWorkletNode.");
4078
+ console.warn("No OutputParamHandler set for this Faust node.");
4094
4079
  }
4095
4080
  }
4096
4081
  setComputeHandler(handler) {
@@ -4099,12 +4084,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4099
4084
  getComputeHandler() {
4100
4085
  return this.fComputeHandler;
4101
4086
  }
4102
- setMidiOutputHandler(handler) {
4103
- this.fMidiOutputHandler = handler;
4104
- }
4105
- getMidiOutputHandler() {
4106
- return this.fMidiOutputHandler;
4107
- }
4108
4087
  setPlotHandler(handler) {
4109
4088
  this.fPlotHandler = handler;
4110
4089
  if (this.fPlotHandler) {
@@ -4375,12 +4354,6 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4375
4354
  getPlotHandler() {
4376
4355
  return this.fDSPCode.getPlotHandler();
4377
4356
  }
4378
- setMidiOutputHandler(handler) {
4379
- this.fDSPCode.setMidiOutputHandler(handler);
4380
- }
4381
- getMidiOutputHandler() {
4382
- return this.fDSPCode.getMidiOutputHandler();
4383
- }
4384
4357
  getNumInputs() {
4385
4358
  return this.fDSPCode.getNumInputs();
4386
4359
  }