opus

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: MIT, MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package opus provides a Opus Audio Codec RFC 6716 implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bandwidth

type Bandwidth byte

The Bandwidth the Opus codec scales from 6 kbit/s narrowband mono speech to 510 kbit/s fullband stereo music, with algorithmic delays ranging from 5 ms to 65.2 ms. At any given time, either the LP layer, the MDCT layer, or both, may be active. It can seamlessly switch between all of its various operating modes, giving it a great deal of flexibility to adapt to varying content and network conditions without renegotiating the current session. The codec allows input and output of various audio bandwidths, defined as follows: +----------------------+-----------------+-------------------------+ | Abbreviation | Audio Bandwidth | Sample Rate (Effective) | +----------------------+-----------------+-------------------------+ | NB (narrowband) | 4 kHz | 8 kHz | | | | | | MB (medium-band) | 6 kHz | 12 kHz | | | | | | WB (wideband) | 8 kHz | 16 kHz | | | | | | SWB (super-wideband) | 12 kHz | 24 kHz | | | | | | FB (fullband) | 20 kHz (*) | 48 kHz | +----------------------+-----------------+-------------------------+

https://datatracker.ietf.org/doc/html/rfc6716#section-2

const (
	BandwidthNarrowband Bandwidth = iota + 1
	BandwidthMediumband
	BandwidthWideband
	BandwidthSuperwideband
	BandwidthFullband
)

Bandwidth constants.

func (Bandwidth) SampleRate

func (b Bandwidth) SampleRate() int

SampleRate returns the effective SampleRate for a given bandwidth.

func (Bandwidth) String

func (b Bandwidth) String() string

type Configuration

type Configuration byte

Configuration numbers in each range (e.g., 0...3 for NB SILK- only) correspond to the various choices of frame size, in the same order. For example, configuration 0 has a 10 ms frame size and configuration 3 has a 60 ms frame size. +-----------------------+-----------+-----------+-------------------+ | Configuration | Mode | Bandwidth | Frame Sizes | | Number(s) | | | | +-----------------------+-----------+-----------+-------------------+ | 0...3 | SILK-only | NB | 10, 20, 40, 60 ms | | | | | | | 4...7 | SILK-only | MB | 10, 20, 40, 60 ms | | | | | | | 8...11 | SILK-only | WB | 10, 20, 40, 60 ms | | | | | | | 12...13 | Hybrid | SWB | 10, 20 ms | | | | | | | 14...15 | Hybrid | FB | 10, 20 ms | | | | | | | 16...19 | CELT-only | NB | 2.5, 5, 10, 20 ms | | | | | | | 20...23 | CELT-only | WB | 2.5, 5, 10, 20 ms | | | | | | | 24...27 | CELT-only | SWB | 2.5, 5, 10, 20 ms | | | | | | | 28...31 | CELT-only | FB | 2.5, 5, 10, 20 ms | +-----------------------+-----------+-----------+-------------------+

https://datatracker.ietf.org/doc/html/rfc6716#section-3.1

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes the Opus bitstream into PCM.

func NewDecoder

func NewDecoder() Decoder

NewDecoder creates a new Opus Decoder.

func NewDecoderWithOutput

func NewDecoderWithOutput(sampleRate, channels int) (Decoder, error)

NewDecoderWithOutput creates a new Opus Decoder with the requested output sample rate and channel count.

func (*Decoder) Decode

func (d *Decoder) Decode(in, out []byte) (bandwidth Bandwidth, isStereo bool, err error)

Decode decodes the Opus bitstream into S16LE PCM.

func (*Decoder) DecodeFloat32

func (d *Decoder) DecodeFloat32(in []byte, out []float32) (bandwidth Bandwidth, isStereo bool, err error)

DecodeFloat32 decodes the Opus bitstream into F32LE PCM.

func (*Decoder) DecodeToFloat32

func (d *Decoder) DecodeToFloat32(in []byte, out []float32) (int, error)

DecodeToFloat32 decodes Opus data into float32 PCM and returns the sample count per channel.

func (*Decoder) DecodeToInt16

func (d *Decoder) DecodeToInt16(in []byte, out []int16) (int, error)

DecodeToInt16 decodes Opus data into signed 16-bit PCM and returns the sample count per channel.

func (*Decoder) Init

func (d *Decoder) Init(sampleRate, channels int) error

Init initializes a pre-allocated Opus decoder.

Directories

Path Synopsis
internal
bitdepth
Package bitdepth provides utilities to convert between different audio bitdepths
Package bitdepth provides utilities to convert between different audio bitdepths
celt
Package celt implements the MDCT layer of the Opus decoder.
Package celt implements the MDCT layer of the Opus decoder.
rangecoding
Package rangecoding provides a Range coder for the Opus bitstream
Package rangecoding provides a Range coder for the Opus bitstream
resample/silk
Package silkresample ports the RFC 6716 SILK resampler.
Package silkresample ports the RFC 6716 SILK resampler.
silk
Package silk provides a Silk coder
Package silk provides a Silk coder
slicetools
Package slicetools provides shared helpers for reusing scratch slices.
Package slicetools provides shared helpers for reusing scratch slices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL