# VorbisBitArray

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

*** ** * ** ***


```
@UnstableApi
class VorbisBitArray
```

<br />

*** ** * ** ***

Wraps a byte array, providing methods that allow it to be read as a Vorbis bitstream.

See the [Vorbis bitpacking specification](https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-360002)

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#VorbisBitArray(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Creates a new instance that wraps an existing array. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#bitsLeft()()` Returns the number of remaining bits. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#getPosition()()` Returns the reading position in bits. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#readBit()()` Reads a single bit. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#readBits(int)(numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Reads up to 32 bits. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#reset()()` Resets the reading position to zero. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#setPosition(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the reading position in bits. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/container/VorbisBitArray#skipBits(int)(numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Skips `numberOfBits` bits. |

## Public constructors

### VorbisBitArray

```
VorbisBitArray(data: ByteArray<Byte>!)
```

Creates a new instance that wraps an existing array.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | the array to wrap. |

## Public functions

### bitsLeft

```
fun bitsLeft(): Int
```

Returns the number of remaining bits.

### getPosition

```
fun getPosition(): Int
```

Returns the reading position in bits.

### readBit

```
@CanIgnoreReturnValue
fun readBit(): Boolean
```

Reads a single bit.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the bit is set, `false` otherwise. |

### readBits

```
fun readBits(numBits: Int): Int
```

Reads up to 32 bits.

| Parameters |
|---|---|
| `numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bits to read. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | An integer whose bottom `numBits` bits hold the read data. |

### reset

```
fun reset(): Unit
```

Resets the reading position to zero.

### setPosition

```
fun setPosition(position: Int): Unit
```

Sets the reading position in bits.

| Parameters |
|---|---|
| `position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The new reading position in bits. |

### skipBits

```
fun skipBits(numBits: Int): Unit
```

Skips `numberOfBits` bits.

| Parameters |
|---|---|
| `numBits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bits to skip. |