silk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package silk provides a Silk coder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bandwidth

type Bandwidth byte

Bandwidth for Silk can be NB (narrowband) MB (medium-band) or WB (wideband).

const (
	BandwidthNarrowband Bandwidth = iota + 1
	BandwidthMediumband
	BandwidthWideband
)

Bandwidth constants.

type Decoder

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

Decoder maintains the state needed to decode a stream of Silk frames.

func NewDecoder

func NewDecoder() Decoder

NewDecoder creates a new Silk Decoder.

func (*Decoder) Decode

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

Decode decodes one SILK frame of mono or stereo audio. https://datatracker.ietf.org/doc/html/rfc6716#section-4.2.1

func (*Decoder) DecodePLC

func (d *Decoder) DecodePLC(
	out []float32,
	isStereo bool,
	outputChannelCount int,
	nanoseconds int,
	bandwidth Bandwidth,
) error

DecodePLC conceals a missing SILK packet while matching the channel count selected by the outer Opus decoder.

func (*Decoder) DecodeWithRange

func (d *Decoder) DecodeWithRange(
	rangeDecoder *rangecoding.Decoder,
	out []float32,
	isStereo bool,
	nanoseconds int,
	bandwidth Bandwidth,
) error

DecodeWithRange decodes one SILK frame from an Opus range decoder shared with the CELT layer, as required by RFC 6716 hybrid packets.

func (*Decoder) DecodeWithRangeToChannels

func (d *Decoder) DecodeWithRangeToChannels(
	rangeDecoder *rangecoding.Decoder,
	out []float32,
	isStereo bool,
	outputChannelCount int,
	nanoseconds int,
	bandwidth Bandwidth,
) error

DecodeWithRangeToChannels decodes one SILK frame while matching the API output channel count selected by the outer Opus decoder.

type Encoder

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

Encoder quantizes and range-encodes a single SILK channel. It is the counterpart to Decoder and is built up one stage at a time.

State fields match the corresponding Decoder fields and use the same reset values so the encoder and decoder stay in sync across an uncoded frame.

func NewEncoder

func NewEncoder() Encoder

NewEncoder creates a SILK Encoder with its prediction state reset.

func (*Encoder) Encode

func (e *Encoder) Encode(input []int16, bandwidth Bandwidth, targetBitrate int) []byte

Encode returns one mono 20, 40, or 60 ms SILK payload without the Opus TOC. Multi-unit packets share one range stream and preserve prediction state across units and calls. Invalid unit counts return nil before state changes.

func (*Encoder) SetUseInterpolatedNLSFs

func (e *Encoder) SetUseInterpolatedNLSFs(enabled bool)

SetUseInterpolatedNLSFs enables or disables the NLSF interpolation search in findLPCNLSF, mirroring libopus's complexity-tier setting (silk_setup_complexity: enabled for encoder complexity >= 4).

Jump to

Keyboard shortcuts

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