kunstmusik / webaudio-csound-samples-example

Example showing loading samples from the web and running them with Csound
https://kunstmusik.github.io/webaudio-csound-samples-example
5 stars 0 forks source link

TypeScript #2

Open pablozoani opened 3 years ago

pablozoani commented 3 years ago

Hi Steven! I am trying to use your @ kunstmusik / csound package, but it has taken me a long time trying to add types, I didn't even succeed. I am trying to build my first synth in a web application without wasting my knowledge of csound :) Is there a way to add types to the csoundObj? Regards Pablo

pablozoani commented 3 years ago

I got it working with a file index.d.ts like this

declare module "@kunstmusik/csound" {

    export = CsoundObj

    declare class CsoundObj {
        /** Create a CsoundObj
         * @constructor
         */
        constructor()

        /**
         * This static method creates a new Csound Engine node unattached
         * to a CsoundObj object. It can be used in scenarios where
         * CsoundObj is not needed (ie. WebAudio API programming)
         *
         *  @param {number} InputChannelCount number of input channels
         *  @param {number} OutputChannelCount number of output channels
         *  @return A new Csound Engine Node (CsoundNode or CsoundScriptProcessorNode)
         */
        createNode: (InputChannelCount: number, OutputChannelCount: number) => any

        // ...
kunstmusik commented 3 years ago

Hi @pablozoani sorry I didn't get to this issue earlier. Glad to see you found a solution! I've had a standing todo to add a typescript interface definition to the npm csound release for a while now but haven't had a chance to implement it. I'm working with @hlolli now on to merge our versions of WebAudio Csound which is a big change, but hope to have typescript implemented as part of this work. If you'd like to contribute on this once it would be very welcome.

pablozoani commented 3 years ago

@kunstmusik Yes, i want to help. Invite me to the project or send me a message at: pablozoani@hotmail.com Regards