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) throwsParameters
sampleRateThe sample rate for the decoder. Discord expects this to be 48k.
channelsThe number of channels in the stream to decode, should always be 2.
gainThe 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
audioA pointer to the audio data.
packetSizeThe number of bytes in this packet.
frameSizeThe size of the frame in samples per channel.
Return Value
An opus encoded packet.
DiscordOpusDecoder Class Reference