Send interleaved audio frames to another thread, wait-free.

These classes allow communicating between a non-real time thread (browser main thread or worker) and a real-time thread (in an AudioWorkletProcessor). Write and Reader cannot change role after setup, unless externally synchronized.

GC can happen during the initial construction of this object when hopefully no audio is being output. This depends on how implementations schedule GC passes. After the setup phase no GC is triggered on either side of the queue.

Constructors

Methods

  • Returns number

    Use availableWrite() instead. This method is deprecated and will be removed in future versions.

  • Returns number

    The free space in the ring buffer. This is the amount of samples that can be queued, with a guarantee of success.

  • Enqueue a buffer of interleaved audio into the ring buffer.

    Care should be taken to enqueue a number of samples that is a multiple of the channel count of the audio stream.

    Parameters

    • buf: Float32Array

      An array of interleaved audio frames.

    Returns number

    The number of samples that have been successfully written to the queue. buf is not written to during this call, so the samples that haven't been written to the queue are still available.

MMNEPVFCICPMFPCPTTAAATR