@grame/faustwasm 0.9.2 → 0.9.3

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -140,8 +140,8 @@ const getFaustAudioWorkletProcessor = <Poly extends boolean = false>(dependencie
140
140
  for (const path in parameters) {
141
141
  const [paramValue] = parameters[path];
142
142
  if (paramValue !== this.paramValuesCache[path]) {
143
- this.fDSPCode.setParamValue(path, paramValue);
144
- this.paramValuesCache[path] = paramValue;
143
+ // Set value and update the cache
144
+ this.setParamValue(path, paramValue);
145
145
  }
146
146
  }
147
147
  if (this.fCommunicator.getNewAccDataAvailable()) {
@@ -53,7 +53,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
53
53
  FaustAudioWorkletProcessorCommunicator,
54
54
  FFTUtils
55
55
  } = dependencies;
56
-
56
+
57
57
  const {
58
58
  processorName,
59
59
  dspName,
@@ -154,7 +154,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
154
154
  private window: Float32Array;
155
155
  /** Generated from the current window's rolling sum square */
156
156
  private windowSumSquare: Float32Array;
157
-
157
+
158
158
  /** FFT constructor */
159
159
  private FFT: typeof InterfaceFFT;
160
160
  /** Real FFT interface */
@@ -185,7 +185,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
185
185
  this.port.addEventListener("message", this.handleMessageAux);
186
186
  this.port.start();
187
187
  this.communicator = new FaustAudioWorkletProcessorCommunicator(this.port);
188
-
188
+
189
189
  const { parameterDescriptors } = (this.constructor as typeof AudioWorkletProcessor);
190
190
  parameterDescriptors.forEach((pd) => {
191
191
  this.paramValuesCache[pd.name] = pd.defaultValue || 0;
@@ -251,7 +251,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
251
251
  setupWamEventHandler() {
252
252
  if (!this.wamInfo) return;
253
253
  const { moduleId, instanceId } = this.wamInfo;
254
- const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);
254
+ const { webAudioModules } = (globalThis as unknown as WamAudioWorkletGlobalScope);
255
255
  const ModuleScope = webAudioModules.getModuleScope(moduleId) as WamParamMgrSDKBaseModuleScope;
256
256
  const paramMgrProcessor = ModuleScope?.paramMgrProcessors?.[instanceId];
257
257
  if (!paramMgrProcessor) return;
@@ -349,21 +349,21 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
349
349
  const inputChannels = input?.length || 0;
350
350
  const outputChannels = output?.length || 0;
351
351
  // if (input.length === 0) return true;
352
-
352
+
353
353
  const bufferSize = input?.length ? Math.max(...input.map(c => c.length)) || 128 : 128;
354
-
354
+
355
355
  // Reset FFT and related buffers if necessary (checks in the resetFFT method)
356
356
  this.noIFFT = !!parameters.noIFFT[0];
357
357
  this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);
358
-
358
+
359
359
  if (!this.fDSPCode) return true;
360
-
360
+
361
361
  for (const path in parameters) {
362
362
  if (!!fftParamKeywords.find(k => `/${path}`.endsWith(k))) continue;
363
363
  const [paramValue] = parameters[path];
364
364
  if (paramValue !== this.paramValuesCache[path]) {
365
- this.fDSPCode.setParamValue(path, paramValue);
366
- this.paramValuesCache[path] = paramValue;
365
+ // Set value and update the cache
366
+ this.setParamValue(path, paramValue);
367
367
  }
368
368
  }
369
369
  if (this.communicator.getNewAccDataAvailable()) {
@@ -395,10 +395,10 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
395
395
  this.$inputWrite += bufferSize;
396
396
  this.$inputWrite %= this.fftBufferSize;
397
397
  }
398
-
398
+
399
399
  // Do FFT if necessary
400
400
  this.processFFT();
401
-
401
+
402
402
  // Read from fftOutput buffer for audio output, applying windowSumSquare to reverse the doubled windowing effect
403
403
  for (let i = 0; i < output.length; i++) {
404
404
  setTypedArray(output[i], this.fftOutput[i], 0, this.$outputRead);
@@ -497,7 +497,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
497
497
  const fftHopSize = ~~Math.max(1, fftSize / fftOverlap);
498
498
  const latency = fftSize - Math.min(fftHopSize, bufferSize);
499
499
  let windowFunction: TWindowFunction | null = null;
500
-
500
+
501
501
  // set the window function from the injected list
502
502
  if (windowFunctionIn !== 0) {
503
503
  windowFunction = typeof windowFunctions === "object" ? windowFunctions[~~windowFunctionIn - 1] || null : null;
@@ -525,7 +525,7 @@ const getFaustFFTAudioWorkletProcessor = (dependencies: FaustFFTAudioWorkletProc
525
525
  this.noIFFTBuffer = new Float32Array(this.fftSize);
526
526
  this.createFFTProcessor();
527
527
  }
528
-
528
+
529
529
  // Calculate a window from the window function, prepare the windowSumSquare buffer
530
530
  if (fftSizeChanged || fftOverlapChanged || windowFunction !== this.windowFunction) {
531
531
  this.windowFunction = windowFunction;
@@ -150,8 +150,7 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
150
150
  for (const path in parameters) {
151
151
  const [paramValue] = parameters[path];
152
152
  if (paramValue !== this.paramValuesCache[path]) {
153
- this.fDSPCode.setParamValue(path, paramValue);
154
- this.paramValuesCache[path] = paramValue;
153
+ this.setParamValue(path, paramValue);
155
154
  }
156
155
  }
157
156
  if (this.fCommunicator.getNewAccDataAvailable()) {
@@ -625,8 +624,7 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
625
624
  continue;
626
625
  const [paramValue] = parameters[path];
627
626
  if (paramValue !== this.paramValuesCache[path]) {
628
- this.fDSPCode.setParamValue(path, paramValue);
629
- this.paramValuesCache[path] = paramValue;
627
+ this.setParamValue(path, paramValue);
630
628
  }
631
629
  }
632
630
  if (this.communicator.getNewAccDataAvailable()) {