AudioEncoder: encode() method
WebCodecs APIwindowanddedicated
WebCodecs APIwindow_and_dedicated
The **`encode()`** method of the AudioEncoder interface enqueues a control message to encode a given AudioData object.
## Syntax
```js-nolint
encode(data)
```
### Parameters
- `data`
- : An AudioData object.
### Return value
None (undefined).
### Exceptions
- `InvalidStateError` DOMException
- : Thrown if the state is not `"configured"`.
- TypeError
- : Thrown if the `AudioData` object has been [transferred](/docs/Web/API/Web_Workers_API/Transferable_objects).
## Examples
In the following example `encode` is passed an `AudioData` object.
```js
encoder.encode(data);
```
## Specifications
## Browser compatibility
source: MDN Web Docs mirror · page
Cite this
"AudioEncoder: encode() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/AudioEncoder/encode JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy