@grame/faustwasm 0.1.0 → 0.1.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 +10 -4
- package/assets/standalone/faustwasm/index.js +18 -10
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +10 -4
- package/dist/cjs/index.js +18 -10
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +10 -4
- package/dist/cjs-bundle/index.js +18 -10
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +10 -4
- package/dist/esm/index.js +18 -10
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +10 -4
- package/dist/esm-bundle/index.js +18 -10
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustWebAudioDsp.ts +37 -19
- package/test/faustlive-wasm/faustwasm/index.d.ts +10 -4
- package/test/faustlive-wasm/faustwasm/index.js +18 -10
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
package/dist/cjs/index.d.ts
CHANGED
|
@@ -661,6 +661,7 @@ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode
|
|
|
661
661
|
export type SoundfileItem = {
|
|
662
662
|
name: string;
|
|
663
663
|
url: string;
|
|
664
|
+
index: number;
|
|
664
665
|
basePtr: number;
|
|
665
666
|
};
|
|
666
667
|
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
@@ -710,11 +711,15 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
710
711
|
static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
|
|
711
712
|
static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
|
|
712
713
|
static splitNames(input: string): string[];
|
|
714
|
+
private extractURLsFromJSON;
|
|
713
715
|
/**
|
|
714
|
-
*
|
|
716
|
+
* Load a soundfile possibly containing several parts in the DSP struct.
|
|
717
|
+
* Soundfile pointers are located at 'index' offset, to be read in the JSON file.
|
|
718
|
+
* The DSP struct is located at baseDSP in the wasm memory,
|
|
719
|
+
* either a monophonic DSP, or a voice in a polyphonic context.
|
|
715
720
|
*
|
|
716
721
|
* @param sfReader : the soundfile reader
|
|
717
|
-
* @param
|
|
722
|
+
* @param baseDSP : the base DSP in the wasm memory
|
|
718
723
|
* @param name : the name of the soundfile
|
|
719
724
|
* @param url : the url of the soundfile
|
|
720
725
|
*/
|
|
@@ -722,8 +727,9 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
722
727
|
/**
|
|
723
728
|
* Init soundfiles memory.
|
|
724
729
|
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
730
|
+
* @param allocator : the wasm memory allocator
|
|
731
|
+
* @param sfReader : the soundfile reader
|
|
732
|
+
* @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
|
|
727
733
|
*/
|
|
728
734
|
protected initSoundfileMemory(allocator: WasmAllocator, sfReader: SoundfileReader, baseDSP: number): Promise<void>;
|
|
729
735
|
protected updateOutputs(): void;
|
package/dist/cjs/index.js
CHANGED
|
@@ -2285,7 +2285,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2285
2285
|
}
|
|
2286
2286
|
});
|
|
2287
2287
|
} else if (item.type === "soundfile") {
|
|
2288
|
-
this.fSoundfiles.push({ name: item.label, url: item.url, basePtr: -1 });
|
|
2288
|
+
this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });
|
|
2289
2289
|
}
|
|
2290
2290
|
};
|
|
2291
2291
|
}
|
|
@@ -2314,9 +2314,20 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2314
2314
|
let trimmed = input.replace(/^\{|\}$/g, "");
|
|
2315
2315
|
return trimmed.split(";").map((str) => str.length <= 2 ? "" : str.substring(1, str.length - 1));
|
|
2316
2316
|
}
|
|
2317
|
-
|
|
2317
|
+
extractURLsFromJSON() {
|
|
2318
|
+
const soundfilesEntry = this.fJSONDsp.meta.find((entry) => entry.soundfiles !== void 0);
|
|
2319
|
+
if (soundfilesEntry) {
|
|
2320
|
+
return soundfilesEntry.soundfiles.split(";").filter((url) => url !== "");
|
|
2321
|
+
} else {
|
|
2322
|
+
return [];
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
async loadSoundfile(sfReader, baseDSP, name, url) {
|
|
2318
2326
|
console.log(`Soundfile ${name} paths: ${url}`);
|
|
2327
|
+
const sfReaderURLs = this.extractURLsFromJSON();
|
|
2328
|
+
console.log(`sfReaderURLs ${sfReaderURLs}`);
|
|
2319
2329
|
const sfDirectories = ["", ".", "http://127.0.0.1:8000"];
|
|
2330
|
+
sfDirectories.push(...sfReaderURLs);
|
|
2320
2331
|
console.log(`sfDirectories ${sfDirectories}`);
|
|
2321
2332
|
const sfPathNames = await sfReader.checkFiles(sfDirectories, FaustBaseWebAudioDsp.splitNames(url));
|
|
2322
2333
|
console.log(`Soundfile ${name} paths: ${sfPathNames}`);
|
|
@@ -2324,16 +2335,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2324
2335
|
if (item) {
|
|
2325
2336
|
if (item.basePtr !== -1) {
|
|
2326
2337
|
const HEAP32 = sfReader.getHEAP32();
|
|
2327
|
-
console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with
|
|
2328
|
-
|
|
2329
|
-
HEAP32[sfOffset >> 2] = item.basePtr;
|
|
2338
|
+
console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
|
|
2339
|
+
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
2330
2340
|
} else {
|
|
2331
2341
|
const soundfile = await sfReader.createSoundfile(sfPathNames, MAX_CHAN, this.fSampleSize === 8);
|
|
2332
2342
|
if (soundfile) {
|
|
2333
2343
|
const HEAP32 = soundfile.getHEAP32();
|
|
2334
2344
|
item.basePtr = soundfile.getPtr();
|
|
2335
|
-
console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with
|
|
2336
|
-
HEAP32[
|
|
2345
|
+
console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
|
|
2346
|
+
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
2337
2347
|
} else {
|
|
2338
2348
|
console.log(`Soundfile ${name} for ${url} cannot be created !}`);
|
|
2339
2349
|
}
|
|
@@ -2343,10 +2353,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2343
2353
|
}
|
|
2344
2354
|
}
|
|
2345
2355
|
async initSoundfileMemory(allocator, sfReader, baseDSP) {
|
|
2346
|
-
let sfOffset = baseDSP;
|
|
2347
2356
|
for (const { name, url } of this.fSoundfiles) {
|
|
2348
|
-
await this.loadSoundfile(sfReader,
|
|
2349
|
-
sfOffset += this.fPtrSize;
|
|
2357
|
+
await this.loadSoundfile(sfReader, baseDSP, name, url);
|
|
2350
2358
|
}
|
|
2351
2359
|
;
|
|
2352
2360
|
}
|