Interface AudioBuffer

This interface represents a memory-resident audio asset (for one-shot sounds and other short audio clips). Its format is non-interleaved IEEE 32-bit linear PCM with a nominal range of -1 -> +1. It can contain one or more channels. It is analogous to a WebGL texture. Typically, it would be expected that the length of the PCM data would be fairly short (usually somewhat less than a minute). For longer sounds, such as music soundtracks, streaming should be used with the audio element and MediaElementAudioSourceNode.

An AudioBuffer may be used by one or more AudioContexts.

Index

Properties

Methods

Properties

public duration: number

Duration of the PCM audio data in seconds.

readonly

public length: number

Length of the PCM audio data in sample-frames.

readonly

public numberOfChannels: number

The number of discrete audio channels.

readonly

public sampleRate: number

The sample-rate for the PCM audio data in samples per second.

readonly

Methods

public getChannelData(channel: number): Float32Array

Returns the Float32Array representing the PCM audio data for the specific channel.

The channel parameter is an index representing the particular channel to get data for. An index value of 0 represents the first channel. This index value MUST be less than numberOfChannels or an exception will be thrown.

Parameters

  • channel: number

Returns

Float32Array