---
title: "AudioData | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface AudioData

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData)

interface AudioData {  
    [duration](#duration): number;  
    [format](#format): [AudioSampleFormat](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.AudioSampleFormat/) | null;  
    [numberOfChannels](#numberofchannels): number;  
    [numberOfFrames](#numberofframes): number;  
    [sampleRate](#samplerate): number;  
    [timestamp](#timestamp): number;  
    [allocationSize](#allocationsize-1)(options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/)): number;  
    [clone](#clone-1)(): AudioData;  
    [close](#close-1)(): void;  
    [copyTo](#copyto-1)(  
        destination: [AllowSharedBufferSource](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.AllowSharedBufferSource/),  
        options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/),  
    ): void;  
}

##### Index

### Properties[](#properties)

[duration](#duration) [format](#format) [numberOfChannels](#numberofchannels) [numberOfFrames](#numberofframes) [sampleRate](#samplerate) [timestamp](#timestamp)

### Methods[](#methods)

[allocationSize](#allocationsize) [clone](#clone) [close](#close) [copyTo](#copyto)

## Properties[](#properties-1)

### `Readonly`duration[](#duration)

duration: number

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/duration)

### `Readonly`format[](#format)

format: [AudioSampleFormat](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.AudioSampleFormat/) | null

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/format)

### `Readonly`numberOfChannels[](#numberofchannels)

numberOfChannels: number

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/numberOfChannels)

### `Readonly`numberOfFrames[](#numberofframes)

numberOfFrames: number

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/numberOfFrames)

### `Readonly`sampleRate[](#samplerate)

sampleRate: number

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/sampleRate)

### `Readonly`timestamp[](#timestamp)

timestamp: number

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

[MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/timestamp)

## Methods[](#methods-1)

### allocationSize[](#allocationsize)

-   allocationSize(options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/)): number[](#allocationsize-1)
    
    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](https://developer.mozilla.org/docs/Web/API/AudioData/allocationSize)
    
    #### Parameters
    
    -   options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/)
    
    #### Returns number
    

### clone[](#clone)

-   clone(): AudioData[](#clone-1)
    
    The **`clone()`** method of the AudioData interface creates a new AudioData object with reference to the same media resource as the original.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/clone)
    
    #### Returns AudioData
    

### close[](#close)

-   close(): void[](#close-1)
    
    The **`close()`** method of the AudioData interface clears all states and releases the reference to the media resource.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/close)
    
    #### Returns void
    

### copyTo[](#copyto)

-   copyTo(  
        destination: [AllowSharedBufferSource](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.AllowSharedBufferSource/),  
        options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/),  
    ): void[](#copyto-1)
    
    The **`copyTo()`** method of the AudioData interface copies a plane of an AudioData object to a destination buffer.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/AudioData/copyTo)
    
    #### Parameters
    
    -   destination: [AllowSharedBufferSource](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.AllowSharedBufferSource/)
    -   options: [AudioDataCopyToOptions](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.AudioDataCopyToOptions/)
    
    #### Returns void
