DiscordOpusDecoder
open class DiscordOpusDecoder : DiscordOpusCodeable
An Opus decoder.
Takes Opus packets and returns raw PCM 16-bit-lesample data.
-
The number of channels.
Declaration
Swift
public let channels: Int
-
The sampling rate.
Declaration
Swift
public let sampleRate: Int
-
Creates a Decoder that takes Opus encoded data and outputs raw PCM 16-bit-lesample data.
Declaration
Swift
public init(sampleRate: Int, channels: Int, gain: Int = 0) throws
Parameters
sampleRate
The sample rate for the decoder. Discord expects this to be 48k.
channels
The number of channels in the stream to decode, should always be 2.
gain
The gain for this decoder.
-
Decodes Opus data into raw PCM 16-bit-lesample data.
Declaration
Swift
open func decode(_ audio: UnsafePointer<UInt8>?, packetSize: Int, frameSize: Int) throws -> [opus_int16]
Parameters
audio
A pointer to the audio data.
packetSize
The number of bytes in this packet.
frameSize
The size of the frame in samples per channel.
Return Value
An opus encoded packet.