nx.js
Classes

AudioBuffer

A short audio asset residing in memory, created from an audio file using decodeAudioData(), or from raw data using createBuffer(). Once put into an AudioBuffer, the audio can be played by being passed into an AudioBufferSourceNode.

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer

Implements

Constructors

new AudioBuffer()

new AudioBuffer(options): AudioBuffer

Parameters

ParameterType
optionsAudioBufferOptions

Returns

AudioBuffer

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/AudioBuffer

Accessors

duration

get duration(): number

Duration of the PCM audio data stored in the buffer, in seconds.

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/duration

Returns

number

Implementation of

globalThis.AudioBuffer.duration


length

get length(): number

Length of the PCM audio data stored in the buffer, in sample-frames.

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/length

Returns

number

Implementation of

globalThis.AudioBuffer.length


numberOfChannels

get numberOfChannels(): number

The number of discrete audio channels stored in the buffer.

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/numberOfChannels

Returns

number

Implementation of

globalThis.AudioBuffer.numberOfChannels


sampleRate

get sampleRate(): number

The sample rate of the PCM audio data, in samples per second.

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/sampleRate

Returns

number

Implementation of

globalThis.AudioBuffer.sampleRate

Methods

copyFromChannel()

copyFromChannel(destination, channelNumber, bufferOffset): void

Copies the samples from the specified channel into the destination array.

Parameters

ParameterTypeDefault value
destinationFloat32Arrayundefined
channelNumbernumberundefined
bufferOffsetnumber0

Returns

void

Implementation of

globalThis.AudioBuffer.copyFromChannel

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/copyFromChannel


copyToChannel()

copyToChannel(source, channelNumber, bufferOffset): void

Copies the samples from the source array into the specified channel.

Parameters

ParameterTypeDefault value
sourceFloat32Arrayundefined
channelNumbernumberundefined
bufferOffsetnumber0

Returns

void

Implementation of

globalThis.AudioBuffer.copyToChannel

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/copyToChannel


getChannelData()

getChannelData(channel): Float32Array

Returns the Float32Array containing the PCM data for the requested channel.

Note

In nx.js, the returned array is a live view of the data the audio render thread reads — mutations are heard, even during playback.

Parameters

ParameterTypeDescription
channelnumberAn index representing the channel to get data for (0 is the first channel).

Returns

Float32Array

Implementation of

globalThis.AudioBuffer.getChannelData

See

https://developer.mozilla.org/docs/Web/API/AudioBuffer/getChannelData

On this page