Vixen
02b45cc4
csharp
public sealed class OpusPacketDecoder

Turns Opus packets back into audio, and invents the ones that never arrived.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The interesting half is what it does with nothing. Decoding a packet is a library call. A voice decoder's job is what happens when the packet is not there — and doing nothing is the worst of the options, because a hole in a waveform is a click, and a click is more noticeable than the syllable that went missing.

Two ways to not have a packet. Its successor may carry a coarse copy of it, which the encoder put there on purpose and which is very nearly the real audio; failing that, the decoder extrapolates its own state — pitch and spectrum carried forward and faded. Both live in Conceal, because Opus will not say which one it did.

Fields and properties (4)

  • public const int Rate

    The rate Opus decodes at, whatever it was encoded from.

  • public int FrameSize

    How many frames come out of one packet.

  • public AudioFormat Format

    What comes out.

  • public long Concealed

    How many frames this decoder has had to produce without the packet for them.

Methods (5)

  • public OpusPacketDecoder(int channels = 1, int frameMilliseconds = 20)

    A decoder for one talker.

  • public int Decode(ReadOnlySpan<byte> packet, Span<float> pcm)

    Decodes a packet that arrived.

  • public int Conceal(Span<float> pcm, ReadOnlySpan<byte> next = default(ReadOnlySpan<byte>))

    Produces a frame that never arrived, out of its successor if that helps.

  • public void Reset()

    Forgets the signal, for a new talker in the same slot.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (3)

  • OpusAudioPacketDecoderVixen.Video.Codecs
  • VoiceReceiverVixen.Audio.Codecs
  • VoiceTestsVixen.Audio.Codecs.Tests