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
Section titled “Properties”handle
Section titled “handle”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.