Skip to content

Opus

Defined in: packages/voice/src/libopus.ts:132

Lunibee’s Opus encoder and decoder for 48 kHz stereo, on the system’s libopus through bun:ffi: native speed with nothing to compile. Frees its native state on destroy() (and, as a safety net, when it is collected).

new Opus(application?): Opus

Defined in: packages/voice/src/libopus.ts:148

OpusApplication = OpusApplication.Audio

Opus

When libopus is not installed or refuses the settings.

get static libraryPath(): string

Defined in: packages/voice/src/libopus.ts:179

Where libopus was loaded from.

string

decode(packet): Uint8Array

Defined in: packages/voice/src/libopus.ts:218

Decodes one Opus packet to s16le PCM (3,840 bytes for a 20 ms packet). An empty packet stands for a lost one and is concealed.

Uint8Array

Uint8Array

After destroy(), or for a corrupt packet.


destroy(): void

Defined in: packages/voice/src/libopus.ts:244

Frees the native encoder and decoder. Safe to call twice.

void


encode(pcm): Uint8Array

Defined in: packages/voice/src/libopus.ts:188

Encodes one 20 ms frame: 960 stereo samples of s16le PCM (3,840 bytes).

Uint8Array

Uint8Array

The Opus packet (a new array).

After destroy(), for a frame of the wrong size, or when libopus fails.