# WavMuxer

Artifact: [androidx.media3:media3-muxer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/muxer/WavMuxer.java+class:androidx.media3.muxer.WavMuxer)

*** ** * ** ***

<br />

```
@UnstableApi
class WavMuxer : Muxer
```

<br />

*** ** * ** ***

A muxer for creating a WAV container file.

This muxer supports muxing of `https://developer.android.com/reference/kotlin/androidx/media3/common/MimeTypes#AUDIO_RAW()` with PCM encodings.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#WavMuxer(androidx.media3.muxer.SeekableMuxerOutput)(seekableMuxerOutput: https://developer.android.com/reference/kotlin/androidx/media3/muxer/SeekableMuxerOutput!)` Creates an instance. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#addMetadataEntry(androidx.media3.common.Metadata.Entry)(metadataEntry: https://developer.android.com/reference/kotlin/androidx/media3/common/Metadata.Entry!)` Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Metadata.Entry` about the output file. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#addTrack(androidx.media3.common.Format)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!)` Adds a track of the given media format. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#close()()` Closes the file. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#writeSampleData(int,java.nio.ByteBuffer,androidx.media3.muxer.BufferInfo)( trackId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!, bufferInfo: https://developer.android.com/reference/kotlin/androidx/media3/muxer/BufferInfo! )` Writes encoded sample data. |

### Inherited functions

From [java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable.html) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/java/lang/AutoCloseable.html#close()()`

## Public constructors

### WavMuxer

```
WavMuxer(seekableMuxerOutput: SeekableMuxerOutput!)
```

Creates an instance.

| Parameters |
|---|---|
| `seekableMuxerOutput: https://developer.android.com/reference/kotlin/androidx/media3/muxer/SeekableMuxerOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/muxer/SeekableMuxerOutput` to write the media data to. It will be automatically `https://developer.android.com/reference/java/nio/channels/Channel.html#close()` by the muxer when `https://developer.android.com/reference/kotlin/androidx/media3/muxer/WavMuxer#close()` is called. |

## Public functions

### addMetadataEntry

```
fun addMetadataEntry(metadataEntry: Metadata.Entry!): Unit
```

Adds `https://developer.android.com/reference/kotlin/androidx/media3/common/Metadata.Entry` about the output file.

### addTrack

```
fun addTrack(format: Format!): Int
```

Adds a track of the given media format.

All tracks must be added before any samples are written to any track.

Only a single audio track is supported.

### close

```
fun close(): Unit
```

Closes the file.

The muxer cannot be used anymore once this method returns.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/muxer/MuxerException` | If the muxer fails to finish writing the output. |

### writeSampleData

```
fun writeSampleData(
    trackId: Int,
    byteBuffer: ByteBuffer!,
    bufferInfo: BufferInfo!
): Unit
```

Writes encoded sample data.

The `bufferInfo` is ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/muxer/MuxerException` |   |