pcm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 1 module, 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 pcm contains stateful, provider-neutral PCM stream utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeALaw added in v0.2.0

func DecodeALaw(encoded []byte) []byte

DecodeALaw expands A-law bytes to little-endian 16-bit mono PCM.

func DecodeALawSample added in v0.2.0

func DecodeALawSample(value byte) int16

DecodeALawSample expands one A-law byte.

func DecodeMuLaw added in v0.2.0

func DecodeMuLaw(encoded []byte) []byte

DecodeMuLaw expands µ-law bytes to little-endian 16-bit mono PCM.

func DecodeMuLawSample added in v0.2.0

func DecodeMuLawSample(value byte) int16

DecodeMuLawSample expands one µ-law byte.

func EncodeALaw added in v0.2.0

func EncodeALaw(pcm16le []byte) []byte

EncodeALaw compands little-endian 16-bit mono PCM.

func EncodeALawSample added in v0.2.0

func EncodeALawSample(sample int16) byte

EncodeALawSample compands one 16-bit sample.

func EncodeMuLaw added in v0.2.0

func EncodeMuLaw(pcm16le []byte) []byte

EncodeMuLaw compands little-endian 16-bit mono PCM. A trailing odd byte is ignored: it is not a sample.

func EncodeMuLawSample added in v0.2.0

func EncodeMuLawSample(sample int16) byte

EncodeMuLawSample compands one 16-bit sample.

Types

type Resampler

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

Resampler incrementally converts mono signed 16-bit little-endian PCM with linear interpolation. A Resampler is stateful and must be used by one stream at a time. Push never invents a right-hand sample at a frame boundary; Finalize supplies the terminal hold sample and fixes the exact output length. This makes output independent of how input is partitioned into frames.

func NewResampler

func NewResampler(inputRate, outputRate uint32) (*Resampler, error)

NewResampler creates a mono PCM16 stream resampler.

func (*Resampler) Finalize

func (resampler *Resampler) Finalize() ([]byte, error)

Finalize returns the terminal samples. It is valid exactly once.

func (*Resampler) InputRate

func (resampler *Resampler) InputRate() uint32

InputRate returns the immutable source sample rate.

func (*Resampler) OutputRate

func (resampler *Resampler) OutputRate() uint32

OutputRate returns the immutable destination sample rate.

func (*Resampler) Push

func (resampler *Resampler) Push(input []byte) ([]byte, error)

Push consumes another sample-aligned PCM16LE fragment and returns all output samples that no longer depend on future input.

Jump to

Keyboard shortcuts

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