@grame/faustwasm 0.2.1 → 0.2.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.
@@ -1400,9 +1400,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1400
1400
  * @param sampleRate - the sample rate in Hz
1401
1401
  * @param bufferSize - the buffer size in frames
1402
1402
  * @param factory - default is the compiled factory
1403
+ * @param context - if this exists, will be used to fetch soundfiles online
1403
1404
  * @returns the compiled processor or 'null' if failure
1404
1405
  */
1405
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<IFaustMonoOfflineProcessor | null>;
1406
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<IFaustMonoOfflineProcessor | null>;
1406
1407
  /**
1407
1408
  * Get DSP JSON description with its UI and metadata as object.
1408
1409
  *
@@ -1459,9 +1460,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1459
1460
  * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1460
1461
  * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1461
1462
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1463
+ * @param context - if this exists, will be used to fetch soundfiles online
1462
1464
  * @returns the compiled processor or 'null' if failure
1463
1465
  */
1464
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<IFaustPolyOfflineProcessor | null>;
1466
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<IFaustPolyOfflineProcessor | null>;
1465
1467
  /**
1466
1468
  * Get DSP JSON description with its UI and metadata as object.
1467
1469
  *
@@ -1496,7 +1498,7 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1496
1498
  prototype: AudioWorkletProcessor;
1497
1499
  parameterDescriptors: AudioParamDescriptor[];
1498
1500
  }>;
1499
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<FaustMonoOfflineProcessor>;
1501
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<FaustMonoOfflineProcessor>;
1500
1502
  getMeta(): any;
1501
1503
  getJSON(): string;
1502
1504
  getUI(): any;
@@ -1518,7 +1520,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1518
1520
  prototype: AudioWorkletProcessor;
1519
1521
  parameterDescriptors: AudioParamDescriptor[];
1520
1522
  }>;
1521
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<FaustPolyOfflineProcessor>;
1523
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<FaustPolyOfflineProcessor>;
1522
1524
  getMeta(): FaustDspMeta;
1523
1525
  getJSON(): string;
1524
1526
  getUI(): FaustUIDescriptor;
@@ -9718,12 +9718,14 @@ const dependencies = {
9718
9718
  throw e;
9719
9719
  }
9720
9720
  }
9721
- async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory) {
9721
+ async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory, context) {
9722
9722
  if (!factory)
9723
9723
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
9724
9724
  const meta = JSON.parse(factory.json);
9725
9725
  const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
9726
9726
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
9727
+ if (context)
9728
+ factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
9727
9729
  const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);
9728
9730
  return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
9729
9731
  }
@@ -9925,13 +9927,18 @@ const dependencies = {
9925
9927
  throw e;
9926
9928
  }
9927
9929
  }
9928
- async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory) {
9930
+ async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, context) {
9929
9931
  if (!voiceFactory)
9930
9932
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
9931
9933
  const voiceMeta = JSON.parse(voiceFactory.json);
9932
9934
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
9933
9935
  const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
9934
9936
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
9937
+ if (context) {
9938
+ voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
9939
+ if (effectFactory)
9940
+ effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
9941
+ }
9935
9942
  const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
9936
9943
  const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);
9937
9944
  return new FaustPolyOfflineProcessor(polyDsp, bufferSize);