@grame/faustwasm 0.15.6 → 0.15.7
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 +0 -7
- package/assets/standalone/faustwasm/index.js +17 -31
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +0 -7
- package/dist/cjs/index.js +17 -31
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +0 -7
- package/dist/cjs-bundle/index.js +17 -31
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +0 -7
- package/dist/esm/index.js +17 -31
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +0 -7
- package/dist/esm-bundle/index.js +17 -31
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustOfflineProcessor.ts +1 -1
- package/src/FaustWebAudioDsp.ts +3 -1
- package/src/SoundfileReader.ts +17 -32
- package/src/faust2wavFiles.js +6 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +0 -7
- package/test/faustlive-wasm/faustwasm/index.js +17 -31
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
package/package.json
CHANGED
package/src/FaustWebAudioDsp.ts
CHANGED
|
@@ -1040,7 +1040,9 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
1040
1040
|
.split(';')
|
|
1041
1041
|
.map((str) =>
|
|
1042
1042
|
str.length <= 2 ? '' : str.substring(1, str.length - 1)
|
|
1043
|
-
)
|
|
1043
|
+
)
|
|
1044
|
+
.map((str) => str.trim())
|
|
1045
|
+
.filter((str) => str.length > 0);
|
|
1044
1046
|
}
|
|
1045
1047
|
|
|
1046
1048
|
get hasAccInput() {
|
package/src/SoundfileReader.ts
CHANGED
|
@@ -64,32 +64,13 @@ class SoundfileReader {
|
|
|
64
64
|
if (item.type === 'soundfile') {
|
|
65
65
|
const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
|
|
66
66
|
// soundfiles.map[item.label] = urls;
|
|
67
|
-
urls.
|
|
67
|
+
urls.filter((url) => url.trim().length > 0)
|
|
68
|
+
.forEach((url) => (soundfiles[url] = null));
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
|
|
71
72
|
return soundfiles;
|
|
72
73
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Check if the file exists.
|
|
75
|
-
*
|
|
76
|
-
* @param url : the url of the file to check
|
|
77
|
-
* @returns : true if the file exists, otherwise false
|
|
78
|
-
*/
|
|
79
|
-
private static async checkFileExists(url: string): Promise<boolean> {
|
|
80
|
-
try {
|
|
81
|
-
console.log(`"checkFileExists" url: ${url}`);
|
|
82
|
-
// Fetch in "HEAD" mode does not properly work with the service-worker.js cache, so use "GET" mode for now
|
|
83
|
-
//const response = await fetch(url, { method: "HEAD" });
|
|
84
|
-
const response = await fetch(url);
|
|
85
|
-
console.log(`"checkFileExists" response.ok: ${response.ok}`);
|
|
86
|
-
return response.ok; // Will be true if the status code is 200-299
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('Fetch error:', error);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
74
|
/**
|
|
94
75
|
* Fetch the soundfile.
|
|
95
76
|
*
|
|
@@ -136,17 +117,21 @@ class SoundfileReader {
|
|
|
136
117
|
.href
|
|
137
118
|
)
|
|
138
119
|
];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
120
|
+
// Try each candidate once to avoid double downloads (no preflight GET).
|
|
121
|
+
let lastError: unknown = null;
|
|
122
|
+
for (const url of urlsToCheck) {
|
|
123
|
+
try {
|
|
124
|
+
soundfiles![filename] = await this.fetchSoundfile(
|
|
125
|
+
url,
|
|
126
|
+
audioCtx
|
|
127
|
+
);
|
|
128
|
+
return;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
lastError = error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Failed to load sound file ${filename}, all check failed. Last error: ${String(lastError)}`
|
|
150
135
|
);
|
|
151
136
|
}
|
|
152
137
|
|
package/src/faust2wavFiles.js
CHANGED
|
@@ -52,7 +52,12 @@ const faust2wavFiles = async (
|
|
|
52
52
|
let input = undefined;
|
|
53
53
|
if (inputWav) {
|
|
54
54
|
console.log(`Reading input wav file ${inputWav}.`);
|
|
55
|
-
const
|
|
55
|
+
const inputBufferView = fs.readFileSync(inputWav);
|
|
56
|
+
// Slice to the exact Buffer view to avoid extra bytes from the backing ArrayBuffer.
|
|
57
|
+
const inputBuffer = inputBufferView.buffer.slice(
|
|
58
|
+
inputBufferView.byteOffset,
|
|
59
|
+
inputBufferView.byteOffset + inputBufferView.byteLength
|
|
60
|
+
);
|
|
56
61
|
console.log(`Decoding...`);
|
|
57
62
|
input = WavDecoder.decode(inputBuffer).channelData;
|
|
58
63
|
}
|
|
@@ -1378,13 +1378,6 @@ export declare class SoundfileReader {
|
|
|
1378
1378
|
* @returns : the URLs
|
|
1379
1379
|
*/
|
|
1380
1380
|
static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
|
|
1381
|
-
/**
|
|
1382
|
-
* Check if the file exists.
|
|
1383
|
-
*
|
|
1384
|
-
* @param url : the url of the file to check
|
|
1385
|
-
* @returns : true if the file exists, otherwise false
|
|
1386
|
-
*/
|
|
1387
|
-
private static checkFileExists;
|
|
1388
1381
|
/**
|
|
1389
1382
|
* Fetch the soundfile.
|
|
1390
1383
|
*
|
|
@@ -2712,7 +2712,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2712
2712
|
const trimmed = input.replace(/^\{|\}$/g, "");
|
|
2713
2713
|
return trimmed.split(";").map(
|
|
2714
2714
|
(str) => str.length <= 2 ? "" : str.substring(1, str.length - 1)
|
|
2715
|
-
);
|
|
2715
|
+
).map((str) => str.trim()).filter((str) => str.length > 0);
|
|
2716
2716
|
}
|
|
2717
2717
|
get hasAccInput() {
|
|
2718
2718
|
return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
|
|
@@ -3973,7 +3973,7 @@ var FaustOfflineProcessor = class {
|
|
|
3973
3973
|
outputs[i].set(output, l);
|
|
3974
3974
|
}
|
|
3975
3975
|
}
|
|
3976
|
-
l +=
|
|
3976
|
+
l += sliceLength;
|
|
3977
3977
|
onUpdate == null ? void 0 : onUpdate(l);
|
|
3978
3978
|
}
|
|
3979
3979
|
this.fDSPCode.stop();
|
|
@@ -4522,29 +4522,12 @@ var SoundfileReader = class {
|
|
|
4522
4522
|
const callback = (item) => {
|
|
4523
4523
|
if (item.type === "soundfile") {
|
|
4524
4524
|
const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
|
|
4525
|
-
urls.forEach((url) => soundfiles[url] = null);
|
|
4525
|
+
urls.filter((url) => url.trim().length > 0).forEach((url) => soundfiles[url] = null);
|
|
4526
4526
|
}
|
|
4527
4527
|
};
|
|
4528
4528
|
FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
|
|
4529
4529
|
return soundfiles;
|
|
4530
4530
|
}
|
|
4531
|
-
/**
|
|
4532
|
-
* Check if the file exists.
|
|
4533
|
-
*
|
|
4534
|
-
* @param url : the url of the file to check
|
|
4535
|
-
* @returns : true if the file exists, otherwise false
|
|
4536
|
-
*/
|
|
4537
|
-
static async checkFileExists(url) {
|
|
4538
|
-
try {
|
|
4539
|
-
console.log(`"checkFileExists" url: ${url}`);
|
|
4540
|
-
const response = await fetch(url);
|
|
4541
|
-
console.log(`"checkFileExists" response.ok: ${response.ok}`);
|
|
4542
|
-
return response.ok;
|
|
4543
|
-
} catch (error) {
|
|
4544
|
-
console.error("Fetch error:", error);
|
|
4545
|
-
return false;
|
|
4546
|
-
}
|
|
4547
|
-
}
|
|
4548
4531
|
/**
|
|
4549
4532
|
* Fetch the soundfile.
|
|
4550
4533
|
*
|
|
@@ -4579,17 +4562,20 @@ var SoundfileReader = class {
|
|
|
4579
4562
|
(path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href
|
|
4580
4563
|
)
|
|
4581
4564
|
];
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4565
|
+
let lastError = null;
|
|
4566
|
+
for (const url of urlsToCheck) {
|
|
4567
|
+
try {
|
|
4568
|
+
soundfiles[filename] = await this.fetchSoundfile(
|
|
4569
|
+
url,
|
|
4570
|
+
audioCtx
|
|
4571
|
+
);
|
|
4572
|
+
return;
|
|
4573
|
+
} catch (error) {
|
|
4574
|
+
lastError = error;
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
throw new Error(
|
|
4578
|
+
`Failed to load sound file ${filename}, all check failed. Last error: ${String(lastError)}`
|
|
4593
4579
|
);
|
|
4594
4580
|
}
|
|
4595
4581
|
/**
|