AudioBuffer

open class AudioBuffer(options: AudioBufferOptions)(source)

The AudioBuffer interface represents a short audio asset residing in memory, created from an audio file using the BaseAudioContext/decodeAudioData method, or from raw data using BaseAudioContext/createBuffer.

MDN Reference

Constructors

Link copied to clipboard
constructor(options: AudioBufferOptions)

Properties

Link copied to clipboard

The duration property of the AudioBuffer interface returns a double representing the duration, in seconds, of the PCM data stored in the buffer.

Link copied to clipboard
val length: Int

The length property of the AudioBuffer interface returns an integer representing the length, in sample-frames, of the PCM data stored in the buffer.

Link copied to clipboard

The numberOfChannels property of the AudioBuffer interface returns an integer representing the number of discrete audio channels described by the PCM data stored in the buffer.

Link copied to clipboard

The sampleRate property of the AudioBuffer interface returns a float representing the sample rate, in samples per second, of the PCM data stored in the buffer.

Functions

Link copied to clipboard
fun copyFromChannel(destination: Float32Array<ArrayBuffer>, channelNumber: Int, bufferOffset: Int = definedExternally)

The copyFromChannel() method of the channel of the AudioBuffer to a specified ``js-nolint copyFromChannel(destination, channelNumber, startInChannel) `` - destination - : A Float32Array to copy the channel's samples to.

Link copied to clipboard
fun copyToChannel(source: Float32Array<ArrayBuffer>, channelNumber: Int, bufferOffset: Int = definedExternally)

The copyToChannel() method of the AudioBuffer interface copies the samples to the specified channel of the AudioBuffer, from the source array.

Link copied to clipboard

The getChannelData() method of the AudioBuffer Interface returns a Float32Array containing the PCM data associated with the channel, defined by the channel parameter (with 0 representing the first channel).