grame-cncm / faustwasm

Faust for WebAudio written in TypeScript
13 stars 7 forks source link

soundfiles should be optional in interface LooseFaustDspFactory #8

Open recri opened 1 month ago

recri commented 1 month ago
/**
 * The Factory structure.
 */
export interface LooseFaustDspFactory {
    /** a "pointer" (as an integer) on the internal C++ factory */
    cfactory?: number;
    /** the WASM code as a binary array */
    code?: Uint8Array;
    /** the compule WASM module */
    module: WebAssembly.Module;
    /** the compiled DSP JSON description */
    json: string;
    /** whether the factory is a polyphonic one or not */
    poly?: boolean;
    /** a unique identifier */
    shaKey?: string;
    /** a map of transferable audio buffers for the `soundfile` function */
    soundfiles: Record<string, (AudioData | null)>;
}

soundfiles should be optional rather than required, most dsp's don't need them.

sletz commented 1 month ago

Can you prepare a PR ?

recri commented 1 month ago

Hmm, I could give you a pull request, but the master branch doesn't build for me with or without my proposed change.

npm run build reports, with or without my change:

src/FaustDspGenerator.ts(236,28): error TS2769: No overload matches this

call. Overload 1 of 2, '(o: {}): string[]', gave the following error. Argument of type 'Record<string, AudioData | null> | undefined' is not assignable to parameter of type '{}'. Type 'undefined' is not assignable to type '{}'. Overload 2 of 2, '(o: object): string[]', gave the following error. Argument of type 'Record<string, AudioData | null> | undefined' is not assignable to parameter of type 'object'. Type 'undefined' is not assignable to type 'object'. src/FaustDspGenerator.ts(553,53): error TS2769: No overload matches this call. Overload 1 of 2, '(o: {}): string[]', gave the following error. Argument of type 'Record<string, AudioData | null> | undefined' is not assignable to parameter of type '{}'. Type 'undefined' is not assignable to type '{}'. Overload 2 of 2, '(o: object): string[]', gave the following error. Argument of type 'Record<string, AudioData | null> | undefined' is not assignable to parameter of type 'object'. Type 'undefined' is not assignable to type 'object'. src/FaustWebAudioDsp.ts(710,31): error TS18048: 'soundfiles' is possibly 'undefined'. src/FaustWebAudioDsp.ts(735,31): error TS18048: 'soundfiles' is possibly 'undefined'. src/SoundfileReader.ts(83,13): error TS18048: 'soundfiles' is possibly 'undefined'. src/SoundfileReader.ts(88,9): error TS18048: 'soundfiles' is possibly 'undefined'. src/SoundfileReader.ts(103,17): error TS18048: 'soundfilesIn' is possibly 'undefined'. src/SoundfileReader.ts(104,34): error TS18048: 'soundfilesIn' is possibly 'undefined'.

Error: Compiled with errors

The build aborts somewhere in the pipeline with no types generated, so this commit can't be the source of the npm package I'm trying to use. But maybe I don't understand.

-- rec --

On Fri, May 24, 2024 at 12:14 AM Stéphane Letz @.***> wrote:

Can you prepare a PR ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>