idris2-dom icon indicating copy to clipboard operation
idris2-dom copied to clipboard

Support for Web Audio API

Open gergoerdi opened this issue 1 year ago • 0 comments

https://webaudio.github.io/web-audio-api/

For my particular use case, I'd like to use the AudioContext to decode the contents of a file I get (e.g. MP3) and then get access to its metadata fields and its sample contents.

Example JavaScript code:

    const AudioContext = window.AudioContext || window.webkitAudioContext;
    var audioCtx = new AudioContext();

    const response = await fetch(url);
    const buf = await audioCtx.decodeAudioData(await response.arrayBuffer());

    const ratio = cpu_freq / buf.sampleRate;
    const len = buf.length;
    const chan = buf.getChannelData(0);

    ...

Note that most parts are asynchronous.

gergoerdi avatar Aug 20 '23 13:08 gergoerdi