ircam-ismm / node-web-audio-api

Web Audio API implementation for Node.js
https://www.npmjs.com/package/node-web-audio-api
BSD 3-Clause "New" or "Revised" License
103 stars 13 forks source link

Improve documentation #72

Open ScreamZ opened 9 months ago

ScreamZ commented 9 months ago

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

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 ?

b-ma commented 9 months ago

Hey thanks for the proposal, actually more documentation would be really welcome indeed.

The only thing I'm unsure is to make a whole website for that at this point, I think raw markdown files in a docs directory would be enough to start with.

Then if the size of the documentation starts to be large enough, that would be really simple to insert them in a static website generator (I would go for https://vitepress.dev/ actually as I already have several documentation websites, e.g. https://soundworks.dev/, based on this solution)