@grame/faustwasm 0.0.67 → 0.1.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/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 +146 -4
- package/assets/standalone/faustwasm/index.js +460 -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 +146 -4
- package/dist/cjs/index.js +460 -73
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs-bundle/index.d.ts +146 -4
- package/dist/cjs-bundle/index.js +561 -174
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.d.ts +146 -4
- package/dist/esm/index.js +460 -73
- package/dist/esm/index.js.map +3 -3
- package/dist/esm-bundle/index.d.ts +146 -4
- package/dist/esm-bundle/index.js +561 -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 +696 -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 +146 -4
- package/test/faustlive-wasm/faustwasm/index.js +460 -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
|
@@ -349,9 +349,11 @@ export declare class FaustDspInstance implements IFaustDspInstance {
|
|
|
349
349
|
}
|
|
350
350
|
export declare class FaustWasmInstantiator {
|
|
351
351
|
private static createWasmImport;
|
|
352
|
-
private static
|
|
352
|
+
private static createWasmMemoryPoly;
|
|
353
|
+
private static createWasmMemoryMono;
|
|
353
354
|
private static createMonoDSPInstanceAux;
|
|
354
|
-
private static
|
|
355
|
+
private static createMemoryMono;
|
|
356
|
+
private static createMemoryPoly;
|
|
355
357
|
private static createMixerAux;
|
|
356
358
|
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<FaustDspFactory>;
|
|
357
359
|
static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
|
|
@@ -368,6 +370,117 @@ export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: numb
|
|
|
368
370
|
}[]) => void;
|
|
369
371
|
export type MetadataHandler = (key: string, value: string) => void;
|
|
370
372
|
export type UIHandler = (item: FaustUIItem) => void;
|
|
373
|
+
declare class WasmAllocator {
|
|
374
|
+
private readonly memory;
|
|
375
|
+
private allocatedBytes;
|
|
376
|
+
constructor(memory: WebAssembly.Memory, offset: number);
|
|
377
|
+
/**
|
|
378
|
+
* Allocates a block of memory of the specified size, returning the pointer to the
|
|
379
|
+
* beginning of the block. The block is allocated at the current offset and the
|
|
380
|
+
* offset is incremented by the size of the block.
|
|
381
|
+
*
|
|
382
|
+
* @param sizeInBytes The size of the block to allocate in bytes.
|
|
383
|
+
* @returns The offset (pointer) to the beginning of the allocated block.
|
|
384
|
+
*/
|
|
385
|
+
alloc(sizeInBytes: number): number;
|
|
386
|
+
/**
|
|
387
|
+
* Returns the underlying buffer object.
|
|
388
|
+
*
|
|
389
|
+
* @returns The buffer object.
|
|
390
|
+
*/
|
|
391
|
+
getBuffer(): ArrayBuffer;
|
|
392
|
+
/**
|
|
393
|
+
* Returns the Int32 view of the underlying buffer object.
|
|
394
|
+
*
|
|
395
|
+
* @returns The view of the memory buffer as Int32Array.
|
|
396
|
+
*/
|
|
397
|
+
getInt32Array(): Int32Array;
|
|
398
|
+
/**
|
|
399
|
+
* Returns the Float32 view of the underlying buffer object.
|
|
400
|
+
*
|
|
401
|
+
* @returns The view of the memory buffer as Float32Array.
|
|
402
|
+
*/
|
|
403
|
+
getFloat32Array(): Float32Array;
|
|
404
|
+
/**
|
|
405
|
+
* Returns the Float64 view of the underlying buffer object..
|
|
406
|
+
*
|
|
407
|
+
* @returns The view of the memory buffer as Float64Array.
|
|
408
|
+
*/
|
|
409
|
+
getFloat64Array(): Float64Array;
|
|
410
|
+
}
|
|
411
|
+
declare class Soundfile {
|
|
412
|
+
private readonly fPtr;
|
|
413
|
+
private readonly fBuffers;
|
|
414
|
+
private readonly fLength;
|
|
415
|
+
private readonly fSR;
|
|
416
|
+
private readonly fOffset;
|
|
417
|
+
private readonly fSampleSize;
|
|
418
|
+
private readonly fPtrSize;
|
|
419
|
+
private readonly fAllocator;
|
|
420
|
+
constructor(allocator: WasmAllocator, ptrSize: number, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number);
|
|
421
|
+
private allocBuffers;
|
|
422
|
+
shareBuffers(curChan: number, maxChan: number): void;
|
|
423
|
+
copyToOut(part: number, maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
424
|
+
copyToOutReal32(maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
425
|
+
copyToOutReal64(maxChannels: number, offset: number, buffer: AudioBuffer): void;
|
|
426
|
+
emptyFile(part: number, offset: number): number;
|
|
427
|
+
displayMemory(where?: string, mem?: boolean): void;
|
|
428
|
+
getPtr(): number;
|
|
429
|
+
getHEAP32(): Int32Array;
|
|
430
|
+
getHEAPFloat32(): Float32Array;
|
|
431
|
+
getHEAPFloat64(): Float64Array;
|
|
432
|
+
}
|
|
433
|
+
declare class SoundfileReader {
|
|
434
|
+
private readonly fAllocator;
|
|
435
|
+
private readonly fPtrSize;
|
|
436
|
+
private readonly fSampleSize;
|
|
437
|
+
private readonly fContext;
|
|
438
|
+
private readonly fAudioBuffers;
|
|
439
|
+
constructor(allocator: WasmAllocator, context: BaseAudioContext, ptrSize: number, sampleSize: number);
|
|
440
|
+
/**
|
|
441
|
+
* Check if the file exists in the given directories.
|
|
442
|
+
*
|
|
443
|
+
* @param directories : the list of directories to search for the file
|
|
444
|
+
* @param fileName : the name of the file to search for
|
|
445
|
+
* @returns : the path of the file if found, otherwise an empty string
|
|
446
|
+
*/
|
|
447
|
+
private checkFile;
|
|
448
|
+
/**
|
|
449
|
+
* Check if all soundfiles exist and return their real path_name.
|
|
450
|
+
*
|
|
451
|
+
* @param directories : the list of directories to search for the file
|
|
452
|
+
* @param fileNameList : the list of file names to search for
|
|
453
|
+
* @returns : the list of path names of the files if found, otherwise an empty string
|
|
454
|
+
*/
|
|
455
|
+
checkFiles(directories: string[], fileNameList: string[]): Promise<string[]>;
|
|
456
|
+
/**
|
|
457
|
+
* Get the channels and length values of the given sound resource.
|
|
458
|
+
*
|
|
459
|
+
* @param pathName : the name of the file, or sound resource identified this way
|
|
460
|
+
* @returns channels and length of the soundfile
|
|
461
|
+
*/
|
|
462
|
+
private getParamsFile;
|
|
463
|
+
/**
|
|
464
|
+
* Read one sound resource and fill the 'soundfile' structure accordingly
|
|
465
|
+
*
|
|
466
|
+
* @param soundfile - the soundfile to be filled
|
|
467
|
+
* @param pathName - the name of the file, or sound resource identified this way
|
|
468
|
+
* @param part - the part number to be filled in the soundfile
|
|
469
|
+
* @param maxChan - the maximum number of mono channels to fill
|
|
470
|
+
*
|
|
471
|
+
* @returns the offset in the soundfile buffer
|
|
472
|
+
*
|
|
473
|
+
*/
|
|
474
|
+
private readFile;
|
|
475
|
+
/**
|
|
476
|
+
* Crate a soundfile, load all parts and copy audio data to the wasm soundfile buffer.
|
|
477
|
+
* @param pathNameList : list of soundfile paths
|
|
478
|
+
* @param maxChan : maximum number of channels
|
|
479
|
+
* @param isDouble : whether the soundfile will be copied as double
|
|
480
|
+
*/
|
|
481
|
+
createSoundfile(pathNameList: string[], maxChan: number, isDouble: boolean): Promise<Soundfile | null>;
|
|
482
|
+
getHEAP32(): Int32Array;
|
|
483
|
+
}
|
|
371
484
|
/**
|
|
372
485
|
* DSP implementation: mimic the C++ 'dsp' class:
|
|
373
486
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
@@ -545,6 +658,11 @@ export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
|
545
658
|
}
|
|
546
659
|
export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
|
|
547
660
|
}
|
|
661
|
+
export type SoundfileItem = {
|
|
662
|
+
name: string;
|
|
663
|
+
url: string;
|
|
664
|
+
basePtr: number;
|
|
665
|
+
};
|
|
548
666
|
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
549
667
|
protected fOutputHandler: OutputParamHandler | null;
|
|
550
668
|
protected fComputeHandler: ComputeHandler | null;
|
|
@@ -560,11 +678,13 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
560
678
|
protected fInputsItems: string[];
|
|
561
679
|
protected fOutputsItems: string[];
|
|
562
680
|
protected fDescriptor: FaustUIInputItem[];
|
|
681
|
+
protected fSoundfiles: SoundfileItem[];
|
|
682
|
+
protected fEndMemory: number;
|
|
563
683
|
protected fAudioInputs: number;
|
|
564
684
|
protected fAudioOutputs: number;
|
|
565
685
|
protected fBufferSize: number;
|
|
566
|
-
protected
|
|
567
|
-
protected
|
|
686
|
+
protected fPtrSize: number;
|
|
687
|
+
protected fSampleSize: number;
|
|
568
688
|
protected fPitchwheelLabel: {
|
|
569
689
|
path: string;
|
|
570
690
|
min: number;
|
|
@@ -581,6 +701,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
581
701
|
protected fUICallback: UIHandler;
|
|
582
702
|
protected fProcessing: boolean;
|
|
583
703
|
protected fDestroyed: boolean;
|
|
704
|
+
protected fFirstCall: boolean;
|
|
584
705
|
protected fJSONDsp: FaustDspMeta;
|
|
585
706
|
constructor(sampleSize: number, bufferSize: number);
|
|
586
707
|
static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
|
|
@@ -588,6 +709,24 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
588
709
|
static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
|
|
589
710
|
static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
|
|
590
711
|
static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
|
|
712
|
+
static splitNames(input: string): string[];
|
|
713
|
+
private extractURLsFromJSON;
|
|
714
|
+
/**
|
|
715
|
+
* Load a soundfile possibly containing several parts.
|
|
716
|
+
*
|
|
717
|
+
* @param sfReader : the soundfile reader
|
|
718
|
+
* @param sfOffset : the offset in the wasm memory
|
|
719
|
+
* @param name : the name of the soundfile
|
|
720
|
+
* @param url : the url of the soundfile
|
|
721
|
+
*/
|
|
722
|
+
private loadSoundfile;
|
|
723
|
+
/**
|
|
724
|
+
* Init soundfiles memory.
|
|
725
|
+
*
|
|
726
|
+
* Soundfile pointers are located at the beginning of the DSP struct memory (one after the other),
|
|
727
|
+
* so that the TS scode can setup them easily.
|
|
728
|
+
*/
|
|
729
|
+
protected initSoundfileMemory(allocator: WasmAllocator, sfReader: SoundfileReader, baseDSP: number): Promise<void>;
|
|
591
730
|
protected updateOutputs(): void;
|
|
592
731
|
metadata(handler: MetadataHandler): void;
|
|
593
732
|
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
@@ -609,6 +748,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
609
748
|
getJSON(): string;
|
|
610
749
|
getUI(): FaustUIDescriptor;
|
|
611
750
|
getDescriptors(): FaustUIInputItem[];
|
|
751
|
+
hasSoundfiles(): boolean;
|
|
612
752
|
start(): void;
|
|
613
753
|
stop(): void;
|
|
614
754
|
destroy(): void;
|
|
@@ -617,6 +757,7 @@ export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implement
|
|
|
617
757
|
private fInstance;
|
|
618
758
|
private fDSP;
|
|
619
759
|
constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
760
|
+
init(context: BaseAudioContext | null): Promise<void>;
|
|
620
761
|
private initMemory;
|
|
621
762
|
toString(): string;
|
|
622
763
|
compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
|
|
@@ -671,6 +812,7 @@ export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implement
|
|
|
671
812
|
private fAudioMixingHalf;
|
|
672
813
|
private fVoiceTable;
|
|
673
814
|
constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
815
|
+
init(context: BaseAudioContext | null): Promise<void>;
|
|
674
816
|
private initMemory;
|
|
675
817
|
toString(): string;
|
|
676
818
|
private allocVoice;
|