@grame/faustwasm 0.16.2 → 0.16.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.
- package/assets/standalone/faustwasm/index.d.ts +2 -0
- package/assets/standalone/faustwasm/index.js +24 -1
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +24 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +2 -0
- package/dist/cjs-bundle/index.js +24 -1
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +24 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +2 -0
- package/dist/esm-bundle/index.js +24 -1
- package/dist/esm-bundle/index.js.map +2 -2
- package/faustwasm-soundfile-wav-samplerate.patch +77 -0
- package/package.json +1 -1
- package/src/SoundfileReader.ts +37 -3
- package/test/faustlive-wasm/faustwasm/index.d.ts +2 -0
- package/test/faustlive-wasm/faustwasm/index.js +24 -1
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/waw400 +0 -0
- package/waw400.dsp +7 -0
package/dist/cjs-bundle/index.js
CHANGED
|
@@ -10453,6 +10453,20 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10453
10453
|
audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))
|
|
10454
10454
|
};
|
|
10455
10455
|
}
|
|
10456
|
+
static isWaveFile(buffer) {
|
|
10457
|
+
if (buffer.byteLength < 12) return false;
|
|
10458
|
+
const reader = new DataView(buffer);
|
|
10459
|
+
const riff = reader.getUint8(0) === 82 && reader.getUint8(1) === 73 && reader.getUint8(2) === 70 && reader.getUint8(3) === 70;
|
|
10460
|
+
const wave = reader.getUint8(8) === 87 && reader.getUint8(9) === 65 && reader.getUint8(10) === 86 && reader.getUint8(11) === 69;
|
|
10461
|
+
return riff && wave;
|
|
10462
|
+
}
|
|
10463
|
+
static decodeWaveFile(buffer) {
|
|
10464
|
+
const decoded = WavDecoder_default.decode(buffer);
|
|
10465
|
+
return {
|
|
10466
|
+
sampleRate: decoded.sampleRate,
|
|
10467
|
+
audioBuffer: decoded.channelData
|
|
10468
|
+
};
|
|
10469
|
+
}
|
|
10456
10470
|
/**
|
|
10457
10471
|
* Extract the URLs from the metadata.
|
|
10458
10472
|
*
|
|
@@ -10464,7 +10478,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10464
10478
|
const callback = (item) => {
|
|
10465
10479
|
if (item.type === "soundfile") {
|
|
10466
10480
|
const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
|
|
10467
|
-
urls.filter((url) => url.trim().length > 0).forEach(
|
|
10481
|
+
urls.filter((url) => url.trim().length > 0).forEach(
|
|
10482
|
+
(url) => soundfiles[url] = null
|
|
10483
|
+
);
|
|
10468
10484
|
}
|
|
10469
10485
|
};
|
|
10470
10486
|
FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
|
|
@@ -10485,6 +10501,13 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10485
10501
|
`Failed to load sound file from ${url}: ${response.statusText}`
|
|
10486
10502
|
);
|
|
10487
10503
|
const arrayBuffer = await response.arrayBuffer();
|
|
10504
|
+
if (this.isWaveFile(arrayBuffer)) {
|
|
10505
|
+
try {
|
|
10506
|
+
return this.decodeWaveFile(arrayBuffer);
|
|
10507
|
+
} catch (error) {
|
|
10508
|
+
console.error(error);
|
|
10509
|
+
}
|
|
10510
|
+
}
|
|
10488
10511
|
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
|
10489
10512
|
return this.toAudioData(audioBuffer);
|
|
10490
10513
|
}
|