@grame/faustwasm 0.0.67 → 0.1.0
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/README.md +1 -1
- package/assets/standalone/faust-ui/index.css +17 -0
- package/assets/standalone/faust-ui/index.css.map +1 -1
- package/assets/standalone/faust-ui/index.js +294 -47
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +145 -4
- package/assets/standalone/faustwasm/index.js +449 -73
- package/assets/standalone/faustwasm/index.js.map +3 -3
- package/assets/standalone/index-poly.js +9 -6
- package/assets/standalone/index.js +9 -6
- package/dist/cjs/index.d.ts +145 -4
- package/dist/cjs/index.js +449 -73
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs-bundle/index.d.ts +145 -4
- package/dist/cjs-bundle/index.js +550 -174
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.d.ts +145 -4
- package/dist/esm/index.js +449 -73
- package/dist/esm/index.js.map +3 -3
- package/dist/esm-bundle/index.d.ts +145 -4
- package/dist/esm-bundle/index.js +550 -174
- package/dist/esm-bundle/index.js.map +3 -3
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +2 -2
- package/src/FaustAudioWorkletProcessor.ts +16 -3
- package/src/FaustDspGenerator.ts +18 -3
- package/src/FaustWasmInstantiator.ts +62 -26
- package/src/FaustWebAudioDsp.ts +682 -51
- package/src/faust2wasmFiles.js +6 -4
- package/test/faustlive-wasm/faust-ui/index.css +17 -0
- package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
- package/test/faustlive-wasm/faust-ui/index.js +294 -47
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +145 -4
- package/test/faustlive-wasm/faustwasm/index.js +449 -73
- package/test/faustlive-wasm/faustwasm/index.js.map +3 -3
- package/TODO.md +0 -5
- package/test/tp0.dsp +0 -17
- package/test/tp0.dsp.json +0 -30
- package/test/tp0_local.dsp +0 -5
|
@@ -356,9 +356,11 @@ export declare class FaustDspInstance implements IFaustDspInstance {
|
|
|
356
356
|
}
|
|
357
357
|
export declare class FaustWasmInstantiator {
|
|
358
358
|
private static createWasmImport;
|
|
359
|
-
private static
|
|
359
|
+
private static createWasmMemoryPoly;
|
|
360
|
+
private static createWasmMemoryMono;
|
|
360
361
|
private static createMonoDSPInstanceAux;
|
|
361
|
-
private static
|
|
362
|
+
private static createMemoryMono;
|
|
363
|
+
private static createMemoryPoly;
|
|
362
364
|
private static createMixerAux;
|
|
363
365
|
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<FaustDspFactory>;
|
|
364
366
|
static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
|
|
@@ -375,6 +377,117 @@ export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: numb
|
|
|
375
377
|
}[]) => void;
|
|
376
378
|
export type MetadataHandler = (key: string, value: string) => void;
|
|
377
379
|
export type UIHandler = (item: FaustUIItem) => void;
|
|
380
|
+
declare class WasmAllocator {
|
|
381
|
+
private readonly memory;
|
|
382
|
+
private allocatedBytes;
|
|
383
|
+
constructor(memory: WebAssembly.Memory, offset: number);
|
|
384
|
+
/**
|
|
385
|
+
* Allocates a block of memory of the specified size, returning the pointer to the
|
|
386
|
+
* beginning of the block. The block is allocated at the current offset and the
|
|
387
|
+
* offset is incremented by the size of the block.
|
|
388
|
+
*
|
|
389
|
+
* @param sizeInBytes The size of the block to allocate in bytes.
|
|
390
|
+
* @returns The offset (pointer) to the beginning of the allocated block.
|
|
391
|
+
*/
|
|
392
|
+
alloc(sizeInBytes: number): number;
|
|
393
|
+
/**
|
|
394
|
+
* Returns the underlying buffer object.
|
|
395
|
+
*
|
|
396
|
+
* @returns The buffer object.
|
|
397
|
+
*/
|
|
398
|
+
getBuffer(): ArrayBuffer;
|
|
399
|
+
/**
|
|
400
|
+
* Returns the Int32 view of the underlying buffer object.
|
|
401
|
+
*
|
|
402
|
+
* @returns The view of the memory buffer as Int32Array.
|
|
403
|
+
*/
|
|
404
|
+
getInt32Array(): Int32Array;
|
|
405
|
+
/**
|
|
406
|
+
* Returns the Float32 view of the underlying buffer object.
|
|
407
|
+
*
|
|
408
|
+
* @returns The view of the memory buffer as Float32Array.
|
|
409
|
+
*/
|
|
410
|
+
getFloat32Array(): Float32Array;
|
|
411
|
+
/**
|
|
412
|
+
* Returns the Float64 view of the underlying buffer object..
|
|
413
|
+
*
|
|
414
|
+
* @returns The view of the memory buffer as Float64Array.
|
|
415
|
+
*/
|
|
416
|
+
getFloat64Array(): Float64Array;
|
|
417
|
+
}
|
|
418
|
+
declare class Soundfile {
|
|
419
|
+
private readonly fPtr;
|
|
420
|
+
private readonly fBuffers;
|
|
421
|
+
private readonly fLength;
|
|
422
|
+
private readonly fSR;
|
|
423
|
+
private readonly fOffset;
|
|
424
|
+
private readonly fSampleSize;
|
|
425
|
+
private readonly fPtrSize;
|
|
426
|
+
private readonly fAllocator;
|
|
427
|
+
constructor(allocator: WasmAllocator, ptrSize: number, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number);
|
|
428
|
+
private allocBuffers;
|
|
429
|
+
shareBuffers(curChan: number, maxChan: number): void;
|
|
430
|
+
copyToOut(part: number, maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
431
|
+
copyToOutReal32(maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
432
|
+
copyToOutReal64(maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
433
|
+
emptyFile(part: number, offset: number): number;
|
|
434
|
+
displayMemory(where?: string, mem?: boolean): void;
|
|
435
|
+
getPtr(): number;
|
|
436
|
+
getHEAP32(): Int32Array;
|
|
437
|
+
getHEAPFloat32(): Float32Array;
|
|
438
|
+
getHEAPFloat64(): Float64Array;
|
|
439
|
+
}
|
|
440
|
+
declare class SoundfileReader {
|
|
441
|
+
private readonly fAllocator;
|
|
442
|
+
private readonly fPtrSize;
|
|
443
|
+
private readonly fSampleSize;
|
|
444
|
+
private readonly fContext;
|
|
445
|
+
private readonly fAudioBuffers;
|
|
446
|
+
constructor(allocator: WasmAllocator, context: BaseAudioContext, ptrSize: number, sampleSize: number);
|
|
447
|
+
/**
|
|
448
|
+
* Check if the file exists in the given directories.
|
|
449
|
+
*
|
|
450
|
+
* @param directories : the list of directories to search for the file
|
|
451
|
+
* @param fileName : the name of the file to search for
|
|
452
|
+
* @returns : the path of the file if found, otherwise an empty string
|
|
453
|
+
*/
|
|
454
|
+
private checkFile;
|
|
455
|
+
/**
|
|
456
|
+
* Check if all soundfiles exist and return their real path_name.
|
|
457
|
+
*
|
|
458
|
+
* @param directories : the list of directories to search for the file
|
|
459
|
+
* @param fileNameList : the list of file names to search for
|
|
460
|
+
* @returns : the list of path names of the files if found, otherwise an empty string
|
|
461
|
+
*/
|
|
462
|
+
checkFiles(directories: string[], fileNameList: string[]): Promise<string[]>;
|
|
463
|
+
/**
|
|
464
|
+
* Get the channels and length values of the given sound resource.
|
|
465
|
+
*
|
|
466
|
+
* @param pathName : the name of the file, or sound resource identified this way
|
|
467
|
+
* @returns channels and length of the soundfile
|
|
468
|
+
*/
|
|
469
|
+
private getParamsFile;
|
|
470
|
+
/**
|
|
471
|
+
* Read one sound resource and fill the 'soundfile' structure accordingly
|
|
472
|
+
*
|
|
473
|
+
* @param soundfile - the soundfile to be filled
|
|
474
|
+
* @param pathName - the name of the file, or sound resource identified this way
|
|
475
|
+
* @param part - the part number to be filled in the soundfile
|
|
476
|
+
* @param maxChan - the maximum number of mono channels to fill
|
|
477
|
+
*
|
|
478
|
+
* @returns the offset in the soundfile buffer
|
|
479
|
+
*
|
|
480
|
+
*/
|
|
481
|
+
private readFile;
|
|
482
|
+
/**
|
|
483
|
+
* Crate a soundfile, load all parts and copy audio data to the wasm soundfile buffer.
|
|
484
|
+
* @param pathNameList : list of soundfile paths
|
|
485
|
+
* @param maxChan : maximum number of channels
|
|
486
|
+
* @param isDouble : whether the soundfile will be copied as double
|
|
487
|
+
*/
|
|
488
|
+
createSoundfile(pathNameList: string[], maxChan: number, isDouble: boolean): Promise<Soundfile | null>;
|
|
489
|
+
getHEAP32(): Int32Array;
|
|
490
|
+
}
|
|
378
491
|
/**
|
|
379
492
|
* DSP implementation: mimic the C++ 'dsp' class:
|
|
380
493
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
@@ -552,6 +665,11 @@ export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
|
552
665
|
}
|
|
553
666
|
export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
|
|
554
667
|
}
|
|
668
|
+
export type SoundfileItem = {
|
|
669
|
+
name: string;
|
|
670
|
+
url: string;
|
|
671
|
+
basePtr: number;
|
|
672
|
+
};
|
|
555
673
|
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
556
674
|
protected fOutputHandler: OutputParamHandler | null;
|
|
557
675
|
protected fComputeHandler: ComputeHandler | null;
|
|
@@ -567,11 +685,13 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
567
685
|
protected fInputsItems: string[];
|
|
568
686
|
protected fOutputsItems: string[];
|
|
569
687
|
protected fDescriptor: FaustUIInputItem[];
|
|
688
|
+
protected fSoundfiles: SoundfileItem[];
|
|
689
|
+
protected fEndMemory: number;
|
|
570
690
|
protected fAudioInputs: number;
|
|
571
691
|
protected fAudioOutputs: number;
|
|
572
692
|
protected fBufferSize: number;
|
|
573
|
-
protected
|
|
574
|
-
protected
|
|
693
|
+
protected fPtrSize: number;
|
|
694
|
+
protected fSampleSize: number;
|
|
575
695
|
protected fPitchwheelLabel: {
|
|
576
696
|
path: string;
|
|
577
697
|
min: number;
|
|
@@ -588,6 +708,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
588
708
|
protected fUICallback: UIHandler;
|
|
589
709
|
protected fProcessing: boolean;
|
|
590
710
|
protected fDestroyed: boolean;
|
|
711
|
+
protected fFirstCall: boolean;
|
|
591
712
|
protected fJSONDsp: FaustDspMeta;
|
|
592
713
|
constructor(sampleSize: number, bufferSize: number);
|
|
593
714
|
static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
|
|
@@ -595,6 +716,23 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
595
716
|
static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
|
|
596
717
|
static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
|
|
597
718
|
static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
|
|
719
|
+
static splitNames(input: string): string[];
|
|
720
|
+
/**
|
|
721
|
+
* Load a soundfile possibly containing several parts.
|
|
722
|
+
*
|
|
723
|
+
* @param sfReader : the soundfile reader
|
|
724
|
+
* @param sfOffset : the offset in the wasm memory
|
|
725
|
+
* @param name : the name of the soundfile
|
|
726
|
+
* @param url : the url of the soundfile
|
|
727
|
+
*/
|
|
728
|
+
private loadSoundfile;
|
|
729
|
+
/**
|
|
730
|
+
* Init soundfiles memory.
|
|
731
|
+
*
|
|
732
|
+
* Soundfile pointers are located at the beginning of the DSP struct memory (one after the other),
|
|
733
|
+
* so that the TS scode can setup them easily.
|
|
734
|
+
*/
|
|
735
|
+
protected initSoundfileMemory(allocator: WasmAllocator, sfReader: SoundfileReader, baseDSP: number): Promise<void>;
|
|
598
736
|
protected updateOutputs(): void;
|
|
599
737
|
metadata(handler: MetadataHandler): void;
|
|
600
738
|
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
@@ -616,6 +754,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
616
754
|
getJSON(): string;
|
|
617
755
|
getUI(): FaustUIDescriptor;
|
|
618
756
|
getDescriptors(): FaustUIInputItem[];
|
|
757
|
+
hasSoundfiles(): boolean;
|
|
619
758
|
start(): void;
|
|
620
759
|
stop(): void;
|
|
621
760
|
destroy(): void;
|
|
@@ -624,6 +763,7 @@ export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implement
|
|
|
624
763
|
private fInstance;
|
|
625
764
|
private fDSP;
|
|
626
765
|
constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
766
|
+
init(context: BaseAudioContext | null): Promise<void>;
|
|
627
767
|
private initMemory;
|
|
628
768
|
toString(): string;
|
|
629
769
|
compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
|
|
@@ -678,6 +818,7 @@ export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implement
|
|
|
678
818
|
private fAudioMixingHalf;
|
|
679
819
|
private fVoiceTable;
|
|
680
820
|
constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
821
|
+
init(context: BaseAudioContext | null): Promise<void>;
|
|
681
822
|
private initMemory;
|
|
682
823
|
toString(): string;
|
|
683
824
|
private allocVoice;
|