opus

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is a type used for functional options

func Application

func Application(a opus.Application) Option

Application is a functional option through which the Encoder profile can be selected. By default, RestrictedLowdelay is set. Check the opus documentation to learn more about the different profiles.

func Bitrate

func Bitrate(rate int) Option

Bitrate is a functional option to set the output bitrate of the opus encoder. The default value is 24kbit/s.

func Channels

func Channels(chs int) Option

Channels is a functional option to set the amount of channels to be used with the audio device. Typically this is either Mono (1) or Stereo (2). Make sure that your audio device supports the specified amount of channels. By default the encoder uses 1 channel, and the decoder 2 channels.

func Complexity

func Complexity(c int) Option

Complexity is a functional option to set the compuational complexity of the opus encoder. For the specific values, check the opus encoder documentation. By default a complexity of 5 is selected.

func MaxBandwidth

func MaxBandwidth(maxBw opus.Bandwidth) Option

MaxBandwidth is a functional option to set the maximum bandpass that the encoder can select. Check the opus documentation to learn more about the available bandwidths. By default Wideband (8kHz) is selected.

func Samplerate

func Samplerate(s float64) Option

Samplerate is a functional option to set the sampling rate of the audio device. Make sure your audio device supports the specified sampling rate. By default, the encoder is set to 48kHz.

type Options

type Options struct {
	Name         string
	Samplerate   float64
	Channels     int
	Bitrate      int
	MaxBandwidth opus.Bandwidth
	Application  opus.Application
	Complexity   int
}

Options is a data structure which is passed into an opus encoder or decoder. The struct is filled through functional options.

type OpusDecoder

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

OpusDecoder is the data structure which holds internal values for the decoder.

func NewOpusDecoder

func NewOpusDecoder(opts ...Option) (*OpusDecoder, error)

NewOpusDecoder is the constructor method for an Opus decoder.

func (*OpusDecoder) Decode

func (oc *OpusDecoder) Decode(data []byte, pcm []float32, opts ...ac.Options) (int, error)

Decode encoded Opus data into the supplied float32 buffer. On success, the number of samples written into the buffer will be returned.

func (*OpusDecoder) Name

func (oc *OpusDecoder) Name() string

Name returns the name of the audio codec

func (*OpusDecoder) Options

func (oc *OpusDecoder) Options() Options

Options returns a copy of the codec's options

type OpusEncoder

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

OpusEncoder is the data structure for the opus encoder. This struct hold the internal values of the encoder.

func NewEncoder

func NewEncoder(opts ...Option) (*OpusEncoder, error)

NewEncoder is the constructor method for an Opus encoder.

func (*OpusEncoder) Encode

func (oEnc *OpusEncoder) Encode(pcm interface{}, data []byte) (int, error)

Encode either []float32 or []int16 with the opus codec into the supplied buffer. On success the amount of bytes written into the buffer will be returned.

func (*OpusEncoder) Name

func (oEnc *OpusEncoder) Name() string

Name returns the name of the audio codec

func (*OpusEncoder) Options

func (oEnc *OpusEncoder) Options() Options

Options returns a copy of the codec's options

Jump to

Keyboard shortcuts

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