@grame/faustwasm 0.12.0 → 0.12.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.
Files changed (40) hide show
  1. package/assets/standalone/faustwasm/index.d.ts +1 -1
  2. package/assets/standalone/faustwasm/index.js +201 -335
  3. package/assets/standalone/faustwasm/index.js.map +2 -2
  4. package/dist/cjs/index.d.ts +1 -1
  5. package/dist/cjs/index.js +203 -338
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/cjs-bundle/index.d.ts +1 -1
  8. package/dist/cjs-bundle/index.js +385 -687
  9. package/dist/cjs-bundle/index.js.map +2 -2
  10. package/dist/esm/index.d.ts +1 -1
  11. package/dist/esm/index.js +201 -335
  12. package/dist/esm/index.js.map +2 -2
  13. package/dist/esm-bundle/index.d.ts +1 -1
  14. package/dist/esm-bundle/index.js +385 -687
  15. package/dist/esm-bundle/index.js.map +2 -2
  16. package/package.json +2 -3
  17. package/src/FaustDspGenerator.ts +2 -1
  18. package/src/FaustWebAudioDsp.ts +2 -2
  19. package/src/SoundfileReader.ts +3 -3
  20. package/src/types.ts +1 -1
  21. package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
  22. package/test/faustlive-wasm/faustwasm/index.js +201 -335
  23. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  24. package/test/organ/create-node.js +252 -0
  25. package/test/organ/dsp-meta.json +131 -0
  26. package/test/organ/dsp-module.wasm +0 -0
  27. package/test/organ/faust-pwa.js +344 -0
  28. package/test/organ/faust-ui/index.css +442 -0
  29. package/test/organ/faust-ui/index.css.map +1 -0
  30. package/test/organ/faust-ui/index.d.ts +1 -0
  31. package/test/organ/faust-ui/index.js +3756 -0
  32. package/test/organ/faust-ui/index.js.map +1 -0
  33. package/test/organ/faustwasm/index.d.ts +1705 -0
  34. package/test/organ/faustwasm/index.js +4773 -0
  35. package/test/organ/faustwasm/index.js.map +7 -0
  36. package/test/organ/icon.png +0 -0
  37. package/test/organ/index.html +76 -0
  38. package/test/organ/index.js +69 -0
  39. package/test/organ/manifest.json +17 -0
  40. package/test/organ/service-worker.js +165 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -41,11 +41,10 @@
41
41
  "@aws-crypto/sha256-js": "^5.2.0",
42
42
  "@shren/faust-ui": "^1.1.16",
43
43
  "@types/node": "^20.12.7",
44
- "@types/webmidi": "^2.0.10",
45
44
  "@webaudiomodules/api": "^2.0.0-alpha.6",
46
45
  "@webaudiomodules/sdk-parammgr": "^0.0.13",
47
46
  "dts-bundle-generator": "^9.5.1",
48
- "esbuild": "^0.20.2",
47
+ "esbuild": "^0.25.12",
49
48
  "typescript": "^5.4.5"
50
49
  },
51
50
  "dependencies": {
@@ -12,7 +12,6 @@ import type { IFaustCompiler } from "./FaustCompiler";
12
12
  import type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from "./types";
13
13
  import { FaustAudioWorkletCommunicator, FaustAudioWorkletProcessorCommunicator } from "./FaustAudioWorkletCommunicator";
14
14
 
15
-
16
15
  export interface GeneratorSupportingSoundfiles {
17
16
  /**
18
17
  * Attach a map of id - audio data, call after `compile()` before `createNode()`
@@ -241,6 +240,7 @@ export class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
241
240
  if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
242
241
  const meta = JSON.parse(this.factory.json);
243
242
  const map = SoundfileReader.findSoundfilesFromMeta(meta);
243
+ if (!map) return [];
244
244
  return Object.keys(map);
245
245
  }
246
246
 
@@ -577,6 +577,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
577
577
  if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
578
578
  const meta = JSON.parse(this.voiceFactory.json);
579
579
  const map = SoundfileReader.findSoundfilesFromMeta(meta);
580
+ if (!map) return [];
580
581
  if (!this.effectFactory) return Object.keys(map);
581
582
  const effectMeta = JSON.parse(this.effectFactory.json);
582
583
  const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);
@@ -891,7 +891,7 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
891
891
  for (const soundfileId of soundfileIdList) {
892
892
  let chan = 0;
893
893
  let len = 0;
894
- const audioData = soundfiles[soundfileId];
894
+ const audioData = soundfiles?.[soundfileId];
895
895
  if (audioData) {
896
896
  chan = audioData.audioBuffer.length;
897
897
  len = audioData.audioBuffer[0].length;
@@ -916,7 +916,7 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
916
916
  // Read all files
917
917
  for (let part = 0; part < soundfileIdList.length; part++) {
918
918
  const soundfileId = soundfileIdList[part];
919
- const audioData = soundfiles[soundfileId];
919
+ const audioData = soundfiles?.[soundfileId];
920
920
  if (audioData) {
921
921
  //soundfile.displayMemory("BEFORE copyToOut");
922
922
  soundfile.copyToOut(part, maxChan, offset, audioData);
@@ -94,12 +94,12 @@ class SoundfileReader {
94
94
  * @param audioCtx : the audio context
95
95
  */
96
96
  private static async loadSoundfile(filename: string, metaUrls: string[], soundfiles: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<void> {
97
- if (soundfiles[filename]) return;
97
+ if (soundfiles?.[filename]) return;
98
98
  const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map(path => new URL(filename, path.endsWith("/") ? path : `${path}/`).href)];
99
99
  const checkResults = await Promise.all(urlsToCheck.map(url => this.checkFileExists(url)));
100
100
  const successIndex = checkResults.findIndex(r => !!r);
101
101
  if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);
102
- soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);
102
+ soundfiles![filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);
103
103
  }
104
104
 
105
105
  /**
@@ -114,7 +114,7 @@ class SoundfileReader {
114
114
  const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);
115
115
  const soundfiles = this.findSoundfilesFromMeta(dspMeta);
116
116
  for (const id in soundfiles) {
117
- if (soundfilesIn[id]) {
117
+ if (soundfilesIn?.[id]) {
118
118
  soundfiles[id] = soundfilesIn[id];
119
119
  continue;
120
120
  }
package/src/types.ts CHANGED
@@ -123,7 +123,7 @@ export interface LooseFaustDspFactory {
123
123
  /** a unique identifier */
124
124
  shaKey?: string;
125
125
  /** a map of transferable audio buffers for the `soundfile` function */
126
- soundfiles: Record<string, (AudioData | null)>;
126
+ soundfiles?: Record<string, AudioData | null>;
127
127
  }
128
128
 
129
129
  export interface FaustDspMeta {
@@ -110,7 +110,7 @@ export interface LooseFaustDspFactory {
110
110
  /** a unique identifier */
111
111
  shaKey?: string;
112
112
  /** a map of transferable audio buffers for the `soundfile` function */
113
- soundfiles: Record<string, (AudioData$1 | null)>;
113
+ soundfiles?: Record<string, AudioData$1 | null>;
114
114
  }
115
115
  export interface FaustDspMeta {
116
116
  name: string;