# WavUtil

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

*** ** * ** ***


```
@UnstableApi
class WavUtil
```

<br />

*** ** * ** ***

Utilities for handling WAVE files.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#DATA_FOURCC() = 1684108385` Four character code for "data". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#DS64_FOURCC() = 1685272116` Four character code for "ds64". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#FACT_FOURCC() = 1717658484` Four character code for "fact". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#FMT_FOURCC() = 1718449184` Four character code for "fmt ". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#RF64_FOURCC() = 1380333108` Four character code for "RF64". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#RIFF_FOURCC() = 1380533830` Four character code for "RIFF". |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_ALAW() = 6` WAVE type value for 8-bit ITU-T G.711 A-law audio data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_FLOAT() = 3` WAVE type value for float PCM audio data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_IMA_ADPCM() = 17` WAVE type value for IMA ADPCM audio data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_MLAW() = 7` WAVE type value for 8-bit ITU-T G.711 mu-law audio data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_PCM() = 1` WAVE type value for integer PCM audio data. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#TYPE_WAVE_FORMAT_EXTENSIBLE() = 65534` WAVE type value for extended WAVE format. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#WAVE_FOURCC() = 1463899717` Four character code for "WAVE". |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#getPcmEncodingForType(int,int)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bitsPerSample: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding` for the given WAVE format type value, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#ENCODING_INVALID()` if the type is not a known PCM type. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#getTypeForPcmEncoding(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding pcmEncoding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the WAVE format type value for the given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#isChannelMaskValid(int,int)(channelMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, channelCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Checks whether the given Microsoft WAVE channel mask is valid and matches the channel count. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/util/WavUtil#mapToAudioFormatChannelMask(int)(wavChannelMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Maps the given Microsoft WAVE channel mask to the corresponding Android `https://developer.android.com/reference/android/media/AudioFormat.html` channel mask. |

## Constants

### DATA_FOURCC

```
const val DATA_FOURCC = 1684108385: Int
```

Four character code for "data".

### DS64_FOURCC

```
const val DS64_FOURCC = 1685272116: Int
```

Four character code for "ds64".

### FACT_FOURCC

```
const val FACT_FOURCC = 1717658484: Int
```

Four character code for "fact".

### FMT_FOURCC

```
const val FMT_FOURCC = 1718449184: Int
```

Four character code for "fmt ".

### RF64_FOURCC

```
const val RF64_FOURCC = 1380333108: Int
```

Four character code for "RF64".

### RIFF_FOURCC

```
const val RIFF_FOURCC = 1380533830: Int
```

Four character code for "RIFF".

### TYPE_ALAW

```
const val TYPE_ALAW = 6: Int
```

WAVE type value for 8-bit ITU-T G.711 A-law audio data.

### TYPE_FLOAT

```
const val TYPE_FLOAT = 3: Int
```

WAVE type value for float PCM audio data.

### TYPE_IMA_ADPCM

```
const val TYPE_IMA_ADPCM = 17: Int
```

WAVE type value for IMA ADPCM audio data.

### TYPE_MLAW

```
const val TYPE_MLAW = 7: Int
```

WAVE type value for 8-bit ITU-T G.711 mu-law audio data.

### TYPE_PCM

```
const val TYPE_PCM = 1: Int
```

WAVE type value for integer PCM audio data.

### TYPE_WAVE_FORMAT_EXTENSIBLE

```
const val TYPE_WAVE_FORMAT_EXTENSIBLE = 65534: Int
```

WAVE type value for extended WAVE format.

### WAVE_FOURCC

```
const val WAVE_FOURCC = 1463899717: Int
```

Four character code for "WAVE".

## Public functions

### getPcmEncodingForType

```
@C.PcmEncoding
java-static fun getPcmEncodingForType(type: Int, bitsPerSample: Int): Int
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding` for the given WAVE format type value, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#ENCODING_INVALID()` if the type is not a known PCM type.

Value is one of the following:

- `Format.NO_VALUE`

<br />

### getTypeForPcmEncoding

```
java-static fun getTypeForPcmEncoding(@C.PcmEncoding pcmEncoding: Int): Int
```

Returns the WAVE format type value for the given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding pcmEncoding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding` value. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The corresponding WAVE format type. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `pcmEncoding` is not a `https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding`, or if it's `https://developer.android.com/reference/kotlin/androidx/media3/common/C#ENCODING_INVALID()` or `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#NO_VALUE()`. |

### isChannelMaskValid

```
java-static fun isChannelMaskValid(channelMask: Int, channelCount: Int): Boolean
```

Checks whether the given Microsoft WAVE channel mask is valid and matches the channel count.

| Parameters |
|---|---|
| `channelMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The WAVE channel mask. |
| `channelCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of channels. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the channel mask is valid. |

### mapToAudioFormatChannelMask

```
java-static fun mapToAudioFormatChannelMask(wavChannelMask: Int): Int
```

Maps the given Microsoft WAVE channel mask to the corresponding Android `https://developer.android.com/reference/android/media/AudioFormat.html` channel mask.

| Parameters |
|---|---|
| `wavChannelMask: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The WAVE channel mask. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The mapped `https://developer.android.com/reference/android/media/AudioFormat.html` channel mask, or `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#NO_VALUE()` if the channel mask is unknown or not applicable (such as for Ambisonics). |