@grame/faustwasm 0.2.0 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -7,10 +7,24 @@ import { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOffline
7
7
  import { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from "./FaustScriptProcessorNode";
8
8
  import { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode, Soundfile, WasmAllocator } from "./FaustWebAudioDsp";
9
9
  import type { IFaustCompiler } from "./FaustCompiler";
10
- import type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory } from "./types";
10
+ import type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory, AudioData } from "./types";
11
11
  import SoundfileReader from "./SoundfileReader";
12
12
 
13
- export interface IFaustMonoDspGenerator {
13
+ export interface GeneratorSupportingSoundfiles {
14
+ /**
15
+ * Attach a map of id - audio data, call after `compile()` before `createNode()`
16
+ *
17
+ * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`
18
+ */
19
+ addSoundfiles(soundfileMap: Record<string, AudioData>): void;
20
+
21
+ /**
22
+ * Get a list of soundfiles needed, call after `compile()`
23
+ */
24
+ getSoundfileList(): string[];
25
+ }
26
+
27
+ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
14
28
  /**
15
29
  * Compile a monophonic DSP factory from given code.
16
30
  *
@@ -26,6 +40,7 @@ export interface IFaustMonoDspGenerator {
26
40
  meta?: FaustDspMeta;
27
41
  } | null>;
28
42
 
43
+
29
44
  /**
30
45
  * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
31
46
  *
@@ -72,12 +87,14 @@ export interface IFaustMonoDspGenerator {
72
87
  * @param sampleRate - the sample rate in Hz
73
88
  * @param bufferSize - the buffer size in frames
74
89
  * @param factory - default is the compiled factory
90
+ * @param context - if this exists, will be used to fetch soundfiles online
75
91
  * @returns the compiled processor or 'null' if failure
76
92
  */
77
93
  createOfflineProcessor(
78
94
  sampleRate: number,
79
95
  bufferSize: number,
80
- factory?: LooseFaustDspFactory
96
+ factory?: LooseFaustDspFactory,
97
+ context?: BaseAudioContext
81
98
  ): Promise<IFaustMonoOfflineProcessor | null>;
82
99
 
83
100
  /**
@@ -102,7 +119,7 @@ export interface IFaustMonoDspGenerator {
102
119
  getUI(): FaustUIDescriptor;
103
120
  }
104
121
 
105
- export interface IFaustPolyDspGenerator {
122
+ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
106
123
  /**
107
124
  * Compile a monophonic DSP factory from given code.
108
125
  *
@@ -151,6 +168,7 @@ export interface IFaustPolyDspGenerator {
151
168
  * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
152
169
  * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
153
170
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
171
+ * @param context - if this exists, will be used to fetch soundfiles online
154
172
  * @returns the compiled processor or 'null' if failure
155
173
  */
156
174
  createOfflineProcessor(
@@ -160,7 +178,7 @@ export interface IFaustPolyDspGenerator {
160
178
  voiceFactory?: LooseFaustDspFactory,
161
179
  mixerModule?: WebAssembly.Module,
162
180
  effectFactory?: LooseFaustDspFactory | null,
163
- processorName?: string
181
+ context?: BaseAudioContext
164
182
  ): Promise<IFaustPolyOfflineProcessor | null>;
165
183
 
166
184
  /**
@@ -205,6 +223,19 @@ export class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
205
223
  }
206
224
  }
207
225
 
226
+ addSoundfiles(soundfileMap: Record<string, AudioData>) {
227
+ if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
228
+ for (const id in soundfileMap) {
229
+ this.factory.soundfiles[id] = soundfileMap[id];
230
+ }
231
+ }
232
+ getSoundfileList() {
233
+ if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
234
+ const meta = JSON.parse(this.factory.json);
235
+ const map = SoundfileReader.findSoundfilesFromMeta(meta);
236
+ return Object.keys(map);
237
+ }
238
+
208
239
  async createNode<SP extends boolean = false>(
209
240
  context: BaseAudioContext,
210
241
  name = this.name,
@@ -394,13 +425,15 @@ const dependencies = {
394
425
  async createOfflineProcessor(
395
426
  sampleRate: number,
396
427
  bufferSize: number,
397
- factory = this.factory as LooseFaustDspFactory
428
+ factory = this.factory as LooseFaustDspFactory,
429
+ context?: BaseAudioContext
398
430
  ) {
399
431
  if (!factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
400
432
 
401
433
  const meta = JSON.parse(factory.json);
402
434
  const instance = await FaustWasmInstantiator.createAsyncMonoDSPInstance(factory);
403
435
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
436
+ if (context) factory.soundfiles = await SoundfileReader.loadSoundfiles(meta, factory.soundfiles || {}, context);
404
437
  const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);
405
438
  return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
406
439
  }
@@ -507,6 +540,22 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
507
540
  }
508
541
  }
509
542
 
543
+ addSoundfiles(soundfileMap: Record<string, AudioData>) {
544
+ if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
545
+ for (const id in soundfileMap) {
546
+ this.voiceFactory.soundfiles[id] = soundfileMap[id];
547
+ }
548
+ }
549
+ getSoundfileList() {
550
+ if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
551
+ const meta = JSON.parse(this.voiceFactory.json);
552
+ const map = SoundfileReader.findSoundfilesFromMeta(meta);
553
+ if (!this.effectFactory) return Object.keys(map);
554
+ const effectMeta = JSON.parse(this.effectFactory.json);
555
+ const effectMap = SoundfileReader.findSoundfilesFromMeta(effectMeta);
556
+ return Object.keys({ ...effectMap, ...map });
557
+ }
558
+
510
559
  async createNode<SP extends boolean = false>(
511
560
  context: BaseAudioContext,
512
561
  voices: number,
@@ -631,7 +680,8 @@ const dependencies = {
631
680
  voices: number,
632
681
  voiceFactory = this.voiceFactory as LooseFaustDspFactory,
633
682
  mixerModule = this.mixerModule,
634
- effectFactory = this.effectFactory as LooseFaustDspFactory | null
683
+ effectFactory = this.effectFactory as LooseFaustDspFactory | null,
684
+ context?: BaseAudioContext
635
685
  ) {
636
686
  if (!voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
637
687
 
@@ -639,6 +689,10 @@ const dependencies = {
639
689
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : undefined;
640
690
  const instance = await FaustWasmInstantiator.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || undefined);
641
691
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
692
+ if (context) {
693
+ voiceFactory.soundfiles = await SoundfileReader.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
694
+ if (effectFactory) effectFactory.soundfiles = await SoundfileReader.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
695
+ }
642
696
  const soundfiles = { ...effectFactory?.soundfiles, ...voiceFactory.soundfiles };
643
697
  const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);
644
698
  return new FaustPolyOfflineProcessor(polyDsp, bufferSize);
@@ -3,7 +3,7 @@ import type { AudioData, FaustDspMeta, FaustUIItem, LooseFaustDspFactory } from
3
3
 
4
4
  /** Read metadata and fetch soundfiles */
5
5
  class SoundfileReader {
6
- static get fallbackPaths() { return [location.href, location.origin, "http://127.0.0.1:8000"]; }
6
+ static get fallbackPaths() { return [location.href, location.origin]; }
7
7
 
8
8
  /**
9
9
  * Convert an audio buffer to audio data.
@@ -25,7 +25,7 @@ class SoundfileReader {
25
25
  * @param dspMeta : the metadata
26
26
  * @returns : the URLs
27
27
  */
28
- private static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"] {
28
+ static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"] {
29
29
  const soundfiles: LooseFaustDspFactory["soundfiles"] = {};
30
30
  const callback = (item: FaustUIItem) => {
31
31
  if (item.type === "soundfile") {
@@ -1196,7 +1196,7 @@ export declare class SoundfileReader {
1196
1196
  * @param dspMeta : the metadata
1197
1197
  * @returns : the URLs
1198
1198
  */
1199
- private static findSoundfilesFromMeta;
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 IFaustMonoDspGenerator {
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
  *
@@ -1381,9 +1393,10 @@ export interface IFaustMonoDspGenerator {
1381
1393
  * @param sampleRate - the sample rate in Hz
1382
1394
  * @param bufferSize - the buffer size in frames
1383
1395
  * @param factory - default is the compiled factory
1396
+ * @param context - if this exists, will be used to fetch soundfiles online
1384
1397
  * @returns the compiled processor or 'null' if failure
1385
1398
  */
1386
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<IFaustMonoOfflineProcessor | null>;
1399
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<IFaustMonoOfflineProcessor | null>;
1387
1400
  /**
1388
1401
  * Get DSP JSON description with its UI and metadata as object.
1389
1402
  *
@@ -1403,7 +1416,7 @@ export interface IFaustMonoDspGenerator {
1403
1416
  */
1404
1417
  getUI(): FaustUIDescriptor;
1405
1418
  }
1406
- export interface IFaustPolyDspGenerator {
1419
+ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1407
1420
  /**
1408
1421
  * Compile a monophonic DSP factory from given code.
1409
1422
  *
@@ -1440,9 +1453,10 @@ export interface IFaustPolyDspGenerator {
1440
1453
  * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1441
1454
  * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1442
1455
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1456
+ * @param context - if this exists, will be used to fetch soundfiles online
1443
1457
  * @returns the compiled processor or 'null' if failure
1444
1458
  */
1445
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<IFaustPolyOfflineProcessor | null>;
1459
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<IFaustPolyOfflineProcessor | null>;
1446
1460
  /**
1447
1461
  * Get DSP JSON description with its UI and metadata as object.
1448
1462
  *
@@ -1468,6 +1482,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1468
1482
  factory: FaustDspFactory | null;
1469
1483
  constructor();
1470
1484
  compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1485
+ addSoundfiles(soundfileMap: Record<string, AudioData>): void;
1486
+ getSoundfileList(): string[];
1471
1487
  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
1488
  createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
1473
1489
  createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
@@ -1475,7 +1491,7 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1475
1491
  prototype: AudioWorkletProcessor;
1476
1492
  parameterDescriptors: AudioParamDescriptor[];
1477
1493
  }>;
1478
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<FaustMonoOfflineProcessor>;
1494
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<FaustMonoOfflineProcessor>;
1479
1495
  getMeta(): any;
1480
1496
  getJSON(): string;
1481
1497
  getUI(): any;
@@ -1489,13 +1505,15 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1489
1505
  mixerModule: WebAssembly.Module;
1490
1506
  constructor();
1491
1507
  compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1508
+ addSoundfiles(soundfileMap: Record<string, AudioData>): void;
1509
+ getSoundfileList(): string[];
1492
1510
  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
1511
  createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1494
1512
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1495
1513
  prototype: AudioWorkletProcessor;
1496
1514
  parameterDescriptors: AudioParamDescriptor[];
1497
1515
  }>;
1498
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<FaustPolyOfflineProcessor>;
1516
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<FaustPolyOfflineProcessor>;
1499
1517
  getMeta(): FaustDspMeta;
1500
1518
  getJSON(): string;
1501
1519
  getUI(): FaustUIDescriptor;
@@ -3111,7 +3111,7 @@ var WavDecoder_default = WavDecoder;
3111
3111
  // src/SoundfileReader.ts
3112
3112
  var SoundfileReader = class {
3113
3113
  static get fallbackPaths() {
3114
- return [location.href, location.origin, "http://127.0.0.1:8000"];
3114
+ return [location.href, location.origin];
3115
3115
  }
3116
3116
  /**
3117
3117
  * Convert an audio buffer to audio data.
@@ -3544,6 +3544,20 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
3544
3544
  return null;
3545
3545
  }
3546
3546
  }
3547
+ addSoundfiles(soundfileMap) {
3548
+ if (!this.factory)
3549
+ throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3550
+ for (const id in soundfileMap) {
3551
+ this.factory.soundfiles[id] = soundfileMap[id];
3552
+ }
3553
+ }
3554
+ getSoundfileList() {
3555
+ if (!this.factory)
3556
+ throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3557
+ const meta = JSON.parse(this.factory.json);
3558
+ const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
3559
+ return Object.keys(map);
3560
+ }
3547
3561
  async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
3548
3562
  var _a, _b;
3549
3563
  if (!factory)
@@ -3701,12 +3715,14 @@ const dependencies = {
3701
3715
  throw e;
3702
3716
  }
3703
3717
  }
3704
- async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory) {
3718
+ async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory, context) {
3705
3719
  if (!factory)
3706
3720
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3707
3721
  const meta = JSON.parse(factory.json);
3708
3722
  const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
3709
3723
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
3724
+ if (context)
3725
+ factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
3710
3726
  const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);
3711
3727
  return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
3712
3728
  }
@@ -3796,6 +3812,24 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
3796
3812
  return null;
3797
3813
  }
3798
3814
  }
3815
+ addSoundfiles(soundfileMap) {
3816
+ if (!this.voiceFactory)
3817
+ throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3818
+ for (const id in soundfileMap) {
3819
+ this.voiceFactory.soundfiles[id] = soundfileMap[id];
3820
+ }
3821
+ }
3822
+ getSoundfileList() {
3823
+ if (!this.voiceFactory)
3824
+ throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3825
+ const meta = JSON.parse(this.voiceFactory.json);
3826
+ const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
3827
+ if (!this.effectFactory)
3828
+ return Object.keys(map);
3829
+ const effectMeta = JSON.parse(this.effectFactory.json);
3830
+ const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
3831
+ return Object.keys({ ...effectMap, ...map });
3832
+ }
3799
3833
  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`) {
3800
3834
  var _a, _b;
3801
3835
  if (!voiceFactory)
@@ -3890,13 +3924,18 @@ const dependencies = {
3890
3924
  throw e;
3891
3925
  }
3892
3926
  }
3893
- async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory) {
3927
+ async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, context) {
3894
3928
  if (!voiceFactory)
3895
3929
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
3896
3930
  const voiceMeta = JSON.parse(voiceFactory.json);
3897
3931
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
3898
3932
  const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
3899
3933
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
3934
+ if (context) {
3935
+ voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
3936
+ if (effectFactory)
3937
+ effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
3938
+ }
3900
3939
  const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
3901
3940
  const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);
3902
3941
  return new FaustPolyOfflineProcessor(polyDsp, bufferSize);