API reference
Preparing search index…

SoundBuffer

Views retain the exact native allocation from which they were obtained.

Source & inheritance
Member directory14

Constructors

Properties

Methods

Constructors

  • Create an empty audio buffer or deep-copy an existing buffer.

    Parameters

    sourceOptional
    Readonly<
        Pick<
            SoundBuffer,
            | typeof audioHandle
            | "getSamples"
            | "getSampleCount"
            | "getSampleRate"
            | "getChannelCount"
            | "getChannelMap"
            | "getDuration"
            | "saveToFile",
        >,
    >

    Returns

    Source & inheritance
  • Copy interleaved 16-bit PCM; sample rate is in Hz and channelMap specifies each channel's position.

    Parameters

    samples
    Int16Array
    channelCount
    number
    sampleRate
    number
    channelMap
    Iterable<SoundChannel>

    Returns

    Source & inheritance

Methods

  • Copy the current source data synchronously, retaining this buffer's identity.

    Parameters

    source
    Readonly

    Returns

    this
    Source & inheritance
  • Return a read-only view of channel positions in interleaved order.

    Returns

    Readonly
    Source & inheritance
  • Return the total sample count across all channels.

    Returns

    bigint
    Source & inheritance
  • Return a read-only typed PCM view, or undefined for an empty buffer. After reloading, existing views still reference the old storage.

    Returns


        | undefined
        | Readonly<
            Pick<
                Int16Array,
                | number
                | typeof iterator
                | "length"
                | "slice"
                | "entries"
                | "keys"
                | "values"
                | "byteLength"
                | "byteOffset",
            >,
        >
    Source & inheritance
  • Asynchronously decode an entire audio file into native PCM storage, returning whether it succeeded.

    Parameters

    filename
    string

    Returns

    Promise<boolean>
    Source & inheritance
  • Asynchronously decode encoded audio bytes and replace the PCM, returning whether it succeeded.

    Parameters

    data
    Uint8Array

    Returns

    Promise<boolean>
    Source & inheritance
  • Synchronously copy interleaved 16-bit PCM and replace the contents; sampleRate is in Hz. Return whether it succeeded.

    Parameters

    data
    Int16Array
    channelCount
    number
    sampleRate
    number
    channelMap
    Iterable<SoundChannel>

    Returns

    boolean
    Source & inheritance
  • Asynchronously decode all samples from an input stream, returning whether it succeeded; stream errors reject the Promise.

    Parameters

    Returns

    Promise<boolean>
    Source & inheritance
  • Asynchronously encode and save using the file extension to select the format, returning whether it succeeded.

    Parameters

    filename
    string

    Returns

    Promise<boolean>
    Source & inheritance

Symbol members

"[audioHandle]": AudioHandle<"buffer">
Source & inheritance

Icons made by Lorc, Delapouite & Skoll · game-icons.net · CC BY 3.0