audio

package
v0.0.0-...-69b8586 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: BSD-2-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SourceFloat32 = SourceFormat(iota)
	SourceInt16
	SourceInt32
)

Variables

This section is empty.

Functions

func GetBlocksInterface

func GetBlocksInterface(s Source) interface{}

func Ingest

func Ingest(s Source, buf interface{}, bitDepth int) error

Ingest TODO: make this using Generics when type switch is supported

Types

type AllowedSourceTypes

type AllowedSourceTypes interface {
	float32 | int16 | int32
}

type ForwardSink

type ForwardSink struct {
	Sink
	Target      Sink
	SamplesRead atomic.Uint64
	Duration    atomic.Int64
}

func NewForwardSink

func NewForwardSink(target Sink) *ForwardSink

func (*ForwardSink) GetDuration

func (n *ForwardSink) GetDuration() time.Duration

func (*ForwardSink) GetSamplesRead

func (n *ForwardSink) GetSamplesRead() uint64

func (*ForwardSink) Process

func (n *ForwardSink) Process(source Source)

type NullSink

type NullSink struct {
	Sink
}

func NewNullSink

func NewNullSink() *NullSink

func (*NullSink) Process

func (n *NullSink) Process(source Source)

type Sink

type Sink interface {
	Process(source Source)
}

type Source

type Source interface {
	GetBitDepth() int
	GetSampleRate() int
	GetChannels() int
	GetFormat() SourceFormat
	ToFloat32() TypedSource[float32]
	ToInt16() TypedSource[int16]
	ToInt32(bitDepth int) TypedSource[int32]

	IngestFloat32(buf []float32)
	IngestInt8(buf []int8, bitDepth int)
	IngestInt16(buf []int16, bitDepth int)
	IngestInt24(buf []byte, bitDepth int)
	IngestInt32(buf []int32, bitDepth int)

	//Split a Source into multiple ones. After calling this function, the source is locked.
	Split(n int) []Source
	Close()
	Unlock()
	Locked() bool
}

func NewInterface

func NewInterface(s Source) Source

func NewTypedInterface

func NewTypedInterface(s Source, bitDepth, sampleRate, channels int) Source

func Split

func Split[T AllowedSourceTypes](s TypedSource[T], n int) (sources []Source)

type SourceFormat

type SourceFormat int

type TypedSource

type TypedSource[T AllowedSourceTypes] interface {
	Source
	New() TypedSource[T]
	IngestNative(buf []T, bitDepth int)
	GetBlocks() chan []T
	// SwapBlocks swaps current Blocks with a different one, and returns old one
	SwapBlocks(blocks chan []T) chan []T
}

func NewSource

func NewSource[T AllowedSourceTypes](bitDepth, sampleRate, channels int) TypedSource[T]

Directories

Path Synopsis
internal/resampler
Package resampler implements audio resampler.
Package resampler implements audio resampler.
aac
mp3
tta

Jump to

Keyboard shortcuts

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