You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-4Lines changed: 70 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,17 @@
2
2
3
3
Kopus is a lightweight Kotlin Multiplatform wrapper for the [Opus audio codec](https://opus-codec.org/). It provides Kotlin bindings for Opus encoding and decoding functionality across Android, JVM, and iOS platforms.
@@ -76,6 +81,59 @@ val pcmOutput = decoder.decode(encodedData, frameSize)
76
81
decoder.close()
77
82
```
78
83
84
+
## Packet Loss Concealment (PLC)
85
+
86
+
Handle missing packets gracefully. When a packet is lost, pass `null` to the decoder to generate concealment audio. With `kopus-full`, DRED provides neural network-based recovery for even better quality.
87
+
88
+
```kotlin
89
+
val decoder =OpusDecoder(sampleRate =48000, channels =1)
90
+
91
+
// Normal decode
92
+
val audio = decoder.decode(packet, frameSize =960)
93
+
94
+
// Packet lost - generate concealment
95
+
val concealed = decoder.decode(null, frameSize =960)
96
+
```
97
+
98
+

99
+
100
+
## Surround Sound (5.1, 7.1)
101
+
102
+
Encode and decode multi-channel audio using the multistream API. Supports standard channel layouts like 5.1 and 7.1 surround.
103
+
104
+
```kotlin
105
+
// 5.1 surround: 6 channels
106
+
val encoder =OpusMultistreamEncoder(
107
+
sampleRate =48000,
108
+
channels =6,
109
+
streams =4,
110
+
coupledStreams =2,
111
+
mapping = byteArrayOf(0, 4, 1, 2, 3, 5)
112
+
)
113
+
val encoded = encoder.encode(surroundPcm)
114
+
encoder.close()
115
+
```
116
+
117
+

118
+
119
+
## Ambisonics (Spatial Audio)
120
+
121
+
Encode spatial audio using ambisonics with the projection API. The encoder automatically handles the channel mapping for first-order ambisonics (4 channels).
122
+
123
+
```kotlin
124
+
// First-order ambisonics: 4 channels (W, Y, Z, X)
125
+
val encoder =OpusProjectionEncoder(
126
+
sampleRate =48000,
127
+
channels =4,
128
+
streams =2,
129
+
coupledStreams =2
130
+
)
131
+
val encoded = encoder.encode(ambisonicsPcm)
132
+
encoder.close()
133
+
```
134
+
135
+

136
+
79
137
## Advanced Usage
80
138
81
139
### Direct Control with ctl/ctlQuery
@@ -163,6 +221,14 @@ Desktop builds are more complex as they require libraries for multiple operating
163
221
164
222
This produces native libraries that are packaged into the JVM artifacts, ensuring cross-platform compatibility.
165
223
224
+
### Building kopus-full
225
+
226
+
To build the full variant with DRED/OSCE/QEXT support:
227
+
```bash
228
+
./scripts/build_opus_apple.sh --full
229
+
./gradlew build -Pkopus.full=true
230
+
```
231
+
166
232
## License
167
233
168
234
Kopus is released under the MIT License. See [LICENSE](LICENSE) for details.
0 commit comments