# 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
public final class WavUtil
```

<br />

*** ** * ** ***

Utilities for handling WAVE files.

## Summary

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

| ### Public methods |
|---|---|
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/androidx/media3/common/util/WavUtil#getPcmEncodingForType(int,int)(int type, int bitsPerSample)` Returns the `https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding` for the given WAVE format type value, or `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` if the type is not a known PCM type. |
| `static int` | `https://developer.android.com/reference/androidx/media3/common/util/WavUtil#getTypeForPcmEncoding(int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding)` Returns the WAVE format type value for the given `https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding`. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/WavUtil#isChannelMaskValid(int,int)(int channelMask, int channelCount)` Checks whether the given Microsoft WAVE channel mask is valid and matches the channel count. |
| `static int` | `https://developer.android.com/reference/androidx/media3/common/util/WavUtil#mapToAudioFormatChannelMask(int)(int wavChannelMask)` 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

```
public static final int DATA_FOURCC = 1684108385
```

Four character code for "data".

### DS64_FOURCC

```
public static final int DS64_FOURCC = 1685272116
```

Four character code for "ds64".

### FACT_FOURCC

```
public static final int FACT_FOURCC = 1717658484
```

Four character code for "fact".

### FMT_FOURCC

```
public static final int FMT_FOURCC = 1718449184
```

Four character code for "fmt ".

### RF64_FOURCC

```
public static final int RF64_FOURCC = 1380333108
```

Four character code for "RF64".

### RIFF_FOURCC

```
public static final int RIFF_FOURCC = 1380533830
```

Four character code for "RIFF".

### TYPE_ALAW

```
public static final int TYPE_ALAW = 6
```

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

### TYPE_FLOAT

```
public static final int TYPE_FLOAT = 3
```

WAVE type value for float PCM audio data.

### TYPE_IMA_ADPCM

```
public static final int TYPE_IMA_ADPCM = 17
```

WAVE type value for IMA ADPCM audio data.

### TYPE_MLAW

```
public static final int TYPE_MLAW = 7
```

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

### TYPE_PCM

```
public static final int TYPE_PCM = 1
```

WAVE type value for integer PCM audio data.

### TYPE_WAVE_FORMAT_EXTENSIBLE

```
public static final int TYPE_WAVE_FORMAT_EXTENSIBLE = 65534
```

WAVE type value for extended WAVE format.

### WAVE_FOURCC

```
public static final int WAVE_FOURCC = 1463899717
```

Four character code for "WAVE".

## Public methods

### getPcmEncodingForType

```
@C.PcmEncoding
public static int getPcmEncodingForType(int type, int bitsPerSample)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding` for the given WAVE format type value, or `https://developer.android.com/reference/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

```
public static int getTypeForPcmEncoding(@C.PcmEncoding int pcmEncoding)
```

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

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

| Returns |
|---|---|
| `int` | 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/androidx/media3/common/C.PcmEncoding`, or if it's `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` or `https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()`. |

### isChannelMaskValid

```
public static boolean isChannelMaskValid(int channelMask, int channelCount)
```

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

| Parameters |
|---|---|
| `int channelMask` | The WAVE channel mask. |
| `int channelCount` | The number of channels. |

| Returns |
|---|---|
| `boolean` | Whether the channel mask is valid. |

### mapToAudioFormatChannelMask

```
public static int mapToAudioFormatChannelMask(int wavChannelMask)
```

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

| Parameters |
|---|---|
| `int wavChannelMask` | The WAVE channel mask. |

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