@grame/faustwasm 0.2.0 → 0.2.1
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 +19 -3
- package/assets/standalone/faustwasm/index.js +33 -1
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +19 -3
- package/dist/cjs/index.js +33 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +19 -3
- package/dist/cjs-bundle/index.js +33 -1
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +19 -3
- package/dist/esm/index.js +33 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +19 -3
- package/dist/esm-bundle/index.js +33 -1
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +47 -3
- package/src/SoundfileReader.ts +2 -2
- package/test/faustlive-wasm/faustwasm/index.d.ts +19 -3
- package/test/faustlive-wasm/faustwasm/index.js +33 -1
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/soundfile.html +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1196,7 +1196,7 @@ export declare class SoundfileReader {
|
|
|
1196
1196
|
* @param dspMeta : the metadata
|
|
1197
1197
|
* @returns : the URLs
|
|
1198
1198
|
*/
|
|
1199
|
-
|
|
1199
|
+
static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
|
|
1200
1200
|
/**
|
|
1201
1201
|
* Check if the file exists.
|
|
1202
1202
|
*
|
|
@@ -1336,7 +1336,19 @@ export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNo
|
|
|
1336
1336
|
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1337
1337
|
allNotesOff(hard: boolean): void;
|
|
1338
1338
|
}
|
|
1339
|
-
export interface
|
|
1339
|
+
export interface GeneratorSupportingSoundfiles {
|
|
1340
|
+
/**
|
|
1341
|
+
* Attach a map of id - audio data, call after `compile()` before `createNode()`
|
|
1342
|
+
*
|
|
1343
|
+
* @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`
|
|
1344
|
+
*/
|
|
1345
|
+
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1346
|
+
/**
|
|
1347
|
+
* Get a list of soundfiles needed, call after `compile()`
|
|
1348
|
+
*/
|
|
1349
|
+
getSoundfileList(): string[];
|
|
1350
|
+
}
|
|
1351
|
+
export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
1340
1352
|
/**
|
|
1341
1353
|
* Compile a monophonic DSP factory from given code.
|
|
1342
1354
|
*
|
|
@@ -1403,7 +1415,7 @@ export interface IFaustMonoDspGenerator {
|
|
|
1403
1415
|
*/
|
|
1404
1416
|
getUI(): FaustUIDescriptor;
|
|
1405
1417
|
}
|
|
1406
|
-
export interface IFaustPolyDspGenerator {
|
|
1418
|
+
export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
|
|
1407
1419
|
/**
|
|
1408
1420
|
* Compile a monophonic DSP factory from given code.
|
|
1409
1421
|
*
|
|
@@ -1468,6 +1480,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1468
1480
|
factory: FaustDspFactory | null;
|
|
1469
1481
|
constructor();
|
|
1470
1482
|
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1483
|
+
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1484
|
+
getSoundfileList(): string[];
|
|
1471
1485
|
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1472
1486
|
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1473
1487
|
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
@@ -1489,6 +1503,8 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1489
1503
|
mixerModule: WebAssembly.Module;
|
|
1490
1504
|
constructor();
|
|
1491
1505
|
compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
|
|
1506
|
+
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1507
|
+
getSoundfileList(): string[];
|
|
1492
1508
|
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1493
1509
|
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1494
1510
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
package/dist/cjs/index.js
CHANGED
|
@@ -3142,7 +3142,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3142
3142
|
// src/SoundfileReader.ts
|
|
3143
3143
|
var SoundfileReader = class {
|
|
3144
3144
|
static get fallbackPaths() {
|
|
3145
|
-
return [location.href, location.origin
|
|
3145
|
+
return [location.href, location.origin];
|
|
3146
3146
|
}
|
|
3147
3147
|
/**
|
|
3148
3148
|
* Convert an audio buffer to audio data.
|
|
@@ -3575,6 +3575,20 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3575
3575
|
return null;
|
|
3576
3576
|
}
|
|
3577
3577
|
}
|
|
3578
|
+
addSoundfiles(soundfileMap) {
|
|
3579
|
+
if (!this.factory)
|
|
3580
|
+
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3581
|
+
for (const id in soundfileMap) {
|
|
3582
|
+
this.factory.soundfiles[id] = soundfileMap[id];
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
getSoundfileList() {
|
|
3586
|
+
if (!this.factory)
|
|
3587
|
+
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3588
|
+
const meta = JSON.parse(this.factory.json);
|
|
3589
|
+
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
3590
|
+
return Object.keys(map);
|
|
3591
|
+
}
|
|
3578
3592
|
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
|
|
3579
3593
|
var _a, _b;
|
|
3580
3594
|
if (!factory)
|
|
@@ -3827,6 +3841,24 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
3827
3841
|
return null;
|
|
3828
3842
|
}
|
|
3829
3843
|
}
|
|
3844
|
+
addSoundfiles(soundfileMap) {
|
|
3845
|
+
if (!this.voiceFactory)
|
|
3846
|
+
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3847
|
+
for (const id in soundfileMap) {
|
|
3848
|
+
this.voiceFactory.soundfiles[id] = soundfileMap[id];
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
getSoundfileList() {
|
|
3852
|
+
if (!this.voiceFactory)
|
|
3853
|
+
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3854
|
+
const meta = JSON.parse(this.voiceFactory.json);
|
|
3855
|
+
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
3856
|
+
if (!this.effectFactory)
|
|
3857
|
+
return Object.keys(map);
|
|
3858
|
+
const effectMeta = JSON.parse(this.effectFactory.json);
|
|
3859
|
+
const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
|
|
3860
|
+
return Object.keys({ ...effectMap, ...map });
|
|
3861
|
+
}
|
|
3830
3862
|
async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`) {
|
|
3831
3863
|
var _a, _b;
|
|
3832
3864
|
if (!voiceFactory)
|