Skip to main content

AudioData

The AudioData interface of the WebCodecs API represents an audio sample.

MDN Reference

Methods

allocationSize()

allocationSize(options): number;

The allocationSize() method of the AudioData interface returns the size in bytes required to hold the current sample as filtered by options passed into the method.

MDN Reference

Parameters

ParameterType
optionsAudioDataCopyToOptions

Returns

number


clone()

clone(): AudioData;

The clone() method of the AudioData interface creates a new AudioData object with reference to the same media resource as the original.

MDN Reference

Returns

AudioData


close()

close(): void;

The close() method of the AudioData interface clears all states and releases the reference to the media resource.

MDN Reference

Returns

void


copyTo()

copyTo(destination, options): void;

The copyTo() method of the AudioData interface copies a plane of an AudioData object to a destination buffer.

MDN Reference

Parameters

ParameterType
destinationAllowSharedBufferSource
optionsAudioDataCopyToOptions

Returns

void

Properties

duration

readonly duration: number;

The duration read-only property of the AudioData interface returns the duration in microseconds of this AudioData object.

MDN Reference


format

readonly format: AudioSampleFormat | null;

The format read-only property of the AudioData interface returns the sample format of the AudioData object.

MDN Reference


numberOfChannels

readonly numberOfChannels: number;

The numberOfChannels read-only property of the AudioData interface returns the number of channels in the AudioData object.

MDN Reference


numberOfFrames

readonly numberOfFrames: number;

The numberOfFrames read-only property of the AudioData interface returns the number of frames in the AudioData object.

MDN Reference


sampleRate

readonly sampleRate: number;

The sampleRate read-only property of the AudioData interface returns the sample rate in Hz.

MDN Reference


timestamp

readonly timestamp: number;

The timestamp read-only property of the AudioData interface returns the timestamp of this AudioData object.

MDN Reference