foo-webview-sdk
    Preparing search index...

    Class PcmBufferExperimental

    Samples of one audio.decodePcm task, backed by the shared buffer the host posted. Nothing is copied until you call PcmBuffer.toAudioBuffer.

    The memory is read-only: writing through a view from PcmBuffer.getChannelView crashes the page's renderer process, and with it the whole foobar2000 window. Call PcmBuffer.release when you are done so the shared memory can be reclaimed.

    Index
    • Experimental

      Parameters

      • buffer: ArrayBuffer

        The one-shot buffer from a sharedbufferreceived event.

      • releaseBuffer: (buffer: ArrayBuffer) => void

        Frees the page's view, usually chrome.webview.releaseBuffer.

      Returns PcmBuffer

      PcmHeaderError when the buffer is not a one-shot PCM buffer this SDK can read.

    channels: number

    1 when the request set mono.

    duration: number

    frames / sampleRate, in seconds.

    frames: number

    Frames per channel.

    resampled: boolean

    Converted to sampleRate with foobar2000's resampler.

    sampleRate: number

    Samples per second per channel.

    start: number

    Track time of the first frame, in seconds.

    truncated: boolean

    The audio ran past the size estimated from the track length, or its format changed partway; the samples end at the cut.

    • Experimental

      Zero-copy view of one channel, frames samples long.

      Treat it as read-only: writing to it crashes the renderer process. It is deliberately not called getChannelData, whose Web Audio namesake returns an array you may modify. Views stop working after PcmBuffer.release, or once the buffer handed out by PcmBuffer.transfer has actually been transferred.

      Parameters

      • channel: number

        0-based channel index.

      Returns Float32Array<ArrayBuffer>

      RangeError for a channel outside 0 to channels - 1; Error once released or transferred.

    • Experimental

      Copy the samples into a new AudioBuffer, which you may modify and play.

      Needs a page with Web Audio; sampleRate must be one AudioBuffer accepts (Chromium takes 3000 to 768000 Hz).

      Returns AudioBuffer

      Error once released or transferred.

    • Experimental

      Hand over the underlying ArrayBuffer, for example to worker.postMessage(buffer, [buffer]).

      After this call the object gives out no more views and PcmBuffer.release does nothing. Views taken earlier keep working until the buffer is actually transferred with postMessage; from then on they are detached (byteLength 0). A transferred buffer can no longer be released on this page; to free it early, transfer it back to the page and pass it to chrome.webview.releaseBuffer. The header stays at the start of the buffer, so the receiver can read it with readPcmHeader.

      Returns ArrayBuffer

      Error once released or transferred.