sfml.js
    Preparing search index...

    Class SoundBuffer

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

    Index

    Constructors

    • 创建空音频缓冲区,或深复制现有缓冲区。

      Parameters

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

      Returns SoundBuffer

    • 复制交错 16 位 PCM;采样率以 Hz 计,channelMap 指定各声道位置。

      Parameters

      • samples: Int16Array
      • channelCount: number
      • sampleRate: number
      • channelMap: Iterable<SoundChannel>

      Returns SoundBuffer

    Properties

    "[audioHandle]": AudioHandle<"buffer">

    Methods

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

      Parameters

      • source: Readonly

      Returns this

    • 返回 PCM 只读类型视图;空缓冲区为 undefined,重新加载后旧视图仍指向旧存储。

      Returns
          | undefined
          | Readonly<
              Pick<
                  Int16Array,
                  | number
                  | typeof iterator
                  | "length"
                  | "slice"
                  | "entries"
                  | "keys"
                  | "values"
                  | "byteLength"
                  | "byteOffset",
              >,
          >

    • 异步解码整个音频文件到原生 PCM 存储,返回是否成功。

      Parameters

      • filename: string

      Returns Promise<boolean>

    • 异步解码编码音频字节并替换 PCM,返回是否成功。

      Parameters

      • data: Uint8Array

      Returns Promise<boolean>

    • 同步复制交错 16 位 PCM 并替换内容;sampleRate 为 Hz,返回是否成功。

      Parameters

      • data: Int16Array
      • channelCount: number
      • sampleRate: number
      • channelMap: Iterable<SoundChannel>

      Returns boolean

    • 按文件扩展名异步编码保存,返回是否成功。

      Parameters

      • filename: string

      Returns Promise<boolean>