@grame/faustwasm 0.16.6 → 0.16.8
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.js +52 -29
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.js +52 -29
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.js +54 -31
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.js +52 -29
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.js +54 -31
- package/dist/esm-bundle/index.js.map +2 -2
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustAudioWorkletProcessor.ts +59 -12
- package/src/FaustDspGenerator.ts +30 -11
- package/src/FaustFFTAudioWorkletProcessor.ts +23 -7
- package/test/faustlive-wasm/faustwasm/index.js +52 -29
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/faustwasm-soundfile-wav-samplerate.patch +0 -77
- package/waw400 +0 -0
- package/waw400.dsp +0 -7
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
diff --git a/src/SoundfileReader.ts b/src/SoundfileReader.ts
|
|
2
|
-
index 0cc287f..43290e7 100644
|
|
3
|
-
--- a/src/SoundfileReader.ts
|
|
4
|
-
+++ b/src/SoundfileReader.ts
|
|
5
|
-
@@ -1,4 +1,5 @@
|
|
6
|
-
import { FaustBaseWebAudioDsp } from './FaustWebAudioDsp';
|
|
7
|
-
+import WavDecoder from './WavDecoder';
|
|
8
|
-
import type {
|
|
9
|
-
AudioData,
|
|
10
|
-
FaustDspMeta,
|
|
11
|
-
@@ -21,7 +22,8 @@ class SoundfileReader {
|
|
12
|
-
const origin = loc?.origin;
|
|
13
|
-
const parent = href ? this.getParentUrl(href) : null;
|
|
14
|
-
return [href, parent, origin].filter(
|
|
15
|
-
- (value): value is string => typeof value === 'string' && value.length > 0
|
|
16
|
-
+ (value): value is string =>
|
|
17
|
-
+ typeof value === 'string' && value.length > 0
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@@ -50,6 +52,30 @@ class SoundfileReader {
|
|
22
|
-
} as AudioData;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
+ private static isWaveFile(buffer: ArrayBuffer) {
|
|
26
|
-
+ if (buffer.byteLength < 12) return false;
|
|
27
|
-
+ const reader = new DataView(buffer);
|
|
28
|
-
+ const riff =
|
|
29
|
-
+ reader.getUint8(0) === 0x52 &&
|
|
30
|
-
+ reader.getUint8(1) === 0x49 &&
|
|
31
|
-
+ reader.getUint8(2) === 0x46 &&
|
|
32
|
-
+ reader.getUint8(3) === 0x46;
|
|
33
|
-
+ const wave =
|
|
34
|
-
+ reader.getUint8(8) === 0x57 &&
|
|
35
|
-
+ reader.getUint8(9) === 0x41 &&
|
|
36
|
-
+ reader.getUint8(10) === 0x56 &&
|
|
37
|
-
+ reader.getUint8(11) === 0x45;
|
|
38
|
-
+ return riff && wave;
|
|
39
|
-
+ }
|
|
40
|
-
+
|
|
41
|
-
+ private static decodeWaveFile(buffer: ArrayBuffer): AudioData {
|
|
42
|
-
+ const decoded = WavDecoder.decode(buffer);
|
|
43
|
-
+ return {
|
|
44
|
-
+ sampleRate: decoded.sampleRate,
|
|
45
|
-
+ audioBuffer: decoded.channelData
|
|
46
|
-
+ };
|
|
47
|
-
+ }
|
|
48
|
-
+
|
|
49
|
-
/**
|
|
50
|
-
* Extract the URLs from the metadata.
|
|
51
|
-
*
|
|
52
|
-
@@ -64,8 +90,9 @@ class SoundfileReader {
|
|
53
|
-
if (item.type === 'soundfile') {
|
|
54
|
-
const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
|
|
55
|
-
// soundfiles.map[item.label] = urls;
|
|
56
|
-
- urls.filter((url) => url.trim().length > 0)
|
|
57
|
-
- .forEach((url) => (soundfiles[url] = null));
|
|
58
|
-
+ urls.filter((url) => url.trim().length > 0).forEach(
|
|
59
|
-
+ (url) => (soundfiles[url] = null)
|
|
60
|
-
+ );
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
|
|
64
|
-
@@ -90,6 +117,13 @@ class SoundfileReader {
|
|
65
|
-
);
|
|
66
|
-
// Decode the audio data
|
|
67
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
68
|
-
+ if (this.isWaveFile(arrayBuffer)) {
|
|
69
|
-
+ try {
|
|
70
|
-
+ return this.decodeWaveFile(arrayBuffer);
|
|
71
|
-
+ } catch (error) {
|
|
72
|
-
+ console.error(error);
|
|
73
|
-
+ }
|
|
74
|
-
+ }
|
|
75
|
-
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
|
76
|
-
return this.toAudioData(audioBuffer);
|
|
77
|
-
}
|
package/waw400
DELETED
|
Binary file
|