@grame/faustwasm 0.12.1 → 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.
- package/assets/standalone/faustwasm/index.d.ts +1 -1
- package/assets/standalone/faustwasm/index.js +6 -4
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +1 -1
- package/dist/cjs-bundle/index.js +6 -4
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +6 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +1 -1
- package/dist/esm-bundle/index.js +6 -4
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +2 -1
- package/src/FaustWebAudioDsp.ts +2 -2
- package/src/SoundfileReader.ts +3 -3
- package/src/types.ts +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
- package/test/faustlive-wasm/faustwasm/index.js +6 -4
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/organ/create-node.js +252 -0
- package/test/organ/dsp-meta.json +131 -0
- package/test/organ/dsp-module.wasm +0 -0
- package/test/organ/faust-pwa.js +344 -0
- package/test/organ/faust-ui/index.css +442 -0
- package/test/organ/faust-ui/index.css.map +1 -0
- package/test/organ/faust-ui/index.d.ts +1 -0
- package/test/organ/faust-ui/index.js +3756 -0
- package/test/organ/faust-ui/index.js.map +1 -0
- package/test/organ/faustwasm/index.d.ts +1705 -0
- package/test/organ/faustwasm/index.js +4773 -0
- package/test/organ/faustwasm/index.js.map +7 -0
- package/test/organ/icon.png +0 -0
- package/test/organ/index.html +76 -0
- package/test/organ/index.js +69 -0
- package/test/organ/manifest.json +17 -0
- package/test/organ/service-worker.js +165 -0
package/package.json
CHANGED
package/src/FaustDspGenerator.ts
CHANGED
|
@@ -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);
|
package/src/FaustWebAudioDsp.ts
CHANGED
|
@@ -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);
|
package/src/SoundfileReader.ts
CHANGED
|
@@ -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
|
|
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
|
|
113
|
+
soundfiles?: Record<string, AudioData$1 | null>;
|
|
114
114
|
}
|
|
115
115
|
export interface FaustDspMeta {
|
|
116
116
|
name: string;
|
|
@@ -2277,7 +2277,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2277
2277
|
for (const soundfileId of soundfileIdList) {
|
|
2278
2278
|
let chan = 0;
|
|
2279
2279
|
let len = 0;
|
|
2280
|
-
const audioData = soundfiles[soundfileId];
|
|
2280
|
+
const audioData = soundfiles == null ? void 0 : soundfiles[soundfileId];
|
|
2281
2281
|
if (audioData) {
|
|
2282
2282
|
chan = audioData.audioBuffer.length;
|
|
2283
2283
|
len = audioData.audioBuffer[0].length;
|
|
@@ -2293,7 +2293,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2293
2293
|
let offset = 0;
|
|
2294
2294
|
for (let part = 0; part < soundfileIdList.length; part++) {
|
|
2295
2295
|
const soundfileId = soundfileIdList[part];
|
|
2296
|
-
const audioData = soundfiles[soundfileId];
|
|
2296
|
+
const audioData = soundfiles == null ? void 0 : soundfiles[soundfileId];
|
|
2297
2297
|
if (audioData) {
|
|
2298
2298
|
soundfile.copyToOut(part, maxChan, offset, audioData);
|
|
2299
2299
|
offset += audioData.audioBuffer[0].length;
|
|
@@ -3693,7 +3693,7 @@ var SoundfileReader = class {
|
|
|
3693
3693
|
* @param audioCtx : the audio context
|
|
3694
3694
|
*/
|
|
3695
3695
|
static async loadSoundfile(filename, metaUrls, soundfiles, audioCtx) {
|
|
3696
|
-
if (soundfiles[filename]) return;
|
|
3696
|
+
if (soundfiles == null ? void 0 : soundfiles[filename]) return;
|
|
3697
3697
|
const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map((path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href)];
|
|
3698
3698
|
const checkResults = await Promise.all(urlsToCheck.map((url) => this.checkFileExists(url)));
|
|
3699
3699
|
const successIndex = checkResults.findIndex((r) => !!r);
|
|
@@ -3712,7 +3712,7 @@ var SoundfileReader = class {
|
|
|
3712
3712
|
const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);
|
|
3713
3713
|
const soundfiles = this.findSoundfilesFromMeta(dspMeta);
|
|
3714
3714
|
for (const id in soundfiles) {
|
|
3715
|
-
if (soundfilesIn[id]) {
|
|
3715
|
+
if (soundfilesIn == null ? void 0 : soundfilesIn[id]) {
|
|
3716
3716
|
soundfiles[id] = soundfilesIn[id];
|
|
3717
3717
|
continue;
|
|
3718
3718
|
}
|
|
@@ -4314,6 +4314,7 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
4314
4314
|
if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
4315
4315
|
const meta = JSON.parse(this.factory.json);
|
|
4316
4316
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
4317
|
+
if (!map) return [];
|
|
4317
4318
|
return Object.keys(map);
|
|
4318
4319
|
}
|
|
4319
4320
|
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
|
|
@@ -4584,6 +4585,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
4584
4585
|
if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
4585
4586
|
const meta = JSON.parse(this.voiceFactory.json);
|
|
4586
4587
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
4588
|
+
if (!map) return [];
|
|
4587
4589
|
if (!this.effectFactory) return Object.keys(map);
|
|
4588
4590
|
const effectMeta = JSON.parse(this.effectFactory.json);
|
|
4589
4591
|
const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
|