node-web-audio-api icon indicating copy to clipboard operation
node-web-audio-api copied to clipboard

Improve documentation

Open ScreamZ opened this issue 1 year ago • 1 comments

Hello!

First I wanted to thank you for this awesome library, It's been months that I have been looking for such capabilities, especially since this time I'm working to play sound effects in an escape room where the state is driven by a NodeJS application and sound too.

I was relying on Chrome + Puppeteer currently, which is kind of dirty and not working all the time.

If you could help me with some issues while implementing I would be happy to help on deploying real documentation for this tool which can help in the adoption of the product (which is highly underrated at the moment I guess).

Something like https://starlight.astro.build/, what do you think ? This is a static website that can be hosted on github pages for free and live in that repository.


What could live in documentation

  • Installation of a jack server and configuration of required library per system.
  • Usage example detailed which remote loading and things like that. As an example how to create ArrayBuffer from NodeJS Buffer using a library like axios
async function getArrayBufferFromURL(url: string): Promise<ArrayBuffer> {
  try {
    // Make an HTTP GET request to the specified URL
    const response = await axios.get<Buffer>(url, { responseType: "arraybuffer" }); // In fact this returns a Buffer currently in NodeJS

    const arrayBuffer = new ArrayBuffer(response.data.length);
    const view = new Uint8Array(arrayBuffer);
    for (let i = 0; i < response.data.length; ++i) {
      view[i] = response.data[i];
    }

    // Return the array buffer
    return arrayBuffer;
  } catch (error: any) {
    console.error("Error fetching data:", error.message);
    throw error;
  }
}

const audioBuffer = await context.decodeAudioData(await getArrayBufferFromURL(config.url));

What do you think ?

ScreamZ avatar Jan 18 '24 12:01 ScreamZ