Decoder
Decodes Opus packets back into raw PCM audio frames.
The decoder state is an opaque libopus pointer that persists across calls - do not create a new Decoder per packet. One Decoder instance per audio stream is the correct usage.
Call destroy when the decoder is no longer needed to free the native state.
Summary
Properties
Decoder.handle :: FFIPointerDecoder.inputPointer :: FFIPointerDecoder.outputPointer :: FFIPointerDecoder.sampleRate :: numberDecoder.channels :: numberProperties
Section titled “Properties”handle
Section titled “handle”inputPointer
Section titled “inputPointer”Native buffer that each Opus packet is copied into before decoding, reused for every call.
outputPointer
Section titled “outputPointer”Native buffer that libopus decodes PCM into, reused for every call.
sampleRate
Section titled “sampleRate”channels
Section titled “channels”Methods
Section titled “Methods”decode
Section titled “decode”Decoder : decode ( opusBuffer ) -> buffer
Decodes an Opus packet into a raw s16le PCM frame.
Parameters
| opusBuffer: buffer |
Returns
| buffer |
decodeFec
Section titled “decodeFec”Decoder : decodeFec ( nextPacket ) -> buffer
Recovers the lost frame preceding nextPacket using the FEC data embedded in that packet.
Use when a packet is missing but the following packet has already arrived.
Parameters
| nextPacket: buffer |
Returns
| buffer |
decodePLC
Section titled “decodePLC”Decoder : decodePLC ( ) -> buffer
Synthesises a comfort-noise frame for a lost packet when no FEC data is available (packet loss concealment).
Returns
| buffer |
destroy
Section titled “destroy”Decoder : destroy ( ) -> ()
Frees the native decoder state. No-op if already destroyed.
Functions
Section titled “Functions”Decoder . new ( sampleRate , channels ) -> Decoder
Responsible for constructing this class.