Documentation ¶
Overview ¶
Package audio ...
Index ¶
- func Abs[T Sample](x T) T
- func Clip[T Sample](min, max T, samples Samples[T])
- func Max[T Sample](values Samples[T]) T
- func Mean[T Sample](samples Samples[T]) T
- func Min[T Sample](values Samples[T]) T
- func Normalize[T Sample](samples Samples[T])
- func Pop[T Sample](buffer *Samples[T]) T
- func Push[T Sample](buffer *Samples[T], samples ...T)
- func RMS[T Sample](samples Samples[T]) T
- func Unshift[T Sample](buffer *Samples[T], samples ...T)
- type Buffer
- type Format
- type Reader
- type Sample
- type Samples
- func (s Samples[T]) BitsPerSample() int
- func (s Samples[T]) Decode(b []byte, order binary.ByteOrder)
- func (s Samples[T]) DecodeFrom(r io.Reader, order binary.ByteOrder) (n int, err error)
- func (s Samples[T]) DecodeFromChunked(r io.Reader, order binary.ByteOrder, chunkSize int) (n int, err error)
- func (s Samples[T]) Encode(b []byte, order binary.ByteOrder)
- func (s Samples[T]) EncodeTo(w io.Writer, order binary.ByteOrder) (n int, err error)
- func (s Samples[T]) EncodeToChunked(w io.Writer, order binary.ByteOrder, chunkSize int) (n int, err error)
- func (s Samples[T]) ToComplex(dst []complex128) []complex128
- func (s Samples[T]) ToFloat(dst []float64) []float64
- func (s Samples[T]) ToInt16(dst []int16) []int16
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize samples to fit in [-1..1].
It doesn't make a whole lot of sense to call this function for non-float values, but you could.
NB: this function may change to bias around the centerpoint of math.MaxUint* for unsigned types.
Types ¶
type Buffer ¶
type Buffer[T Sample] [][]T
Buffer represents a multi channel audio buffer.
func Deinterleave ¶
Deinterleave splits interleaved samples into a multi channel buffer.
The provided buffer dst should be nil, or adequately sized to fit channels of samples.
func (Buffer[T]) BitsPerSample ¶
BitsPerSample is the number of bits required to store one sample.
type Format ¶
type Format interface { // Channels is the number of channels. Channels() int // BitsPerSample is the number of bits required to store one sample. BitsPerSample() int }
Format describes the audio format.
type Sample ¶
type Sample interface { constraints.Integer | constraints.Float }
Sample is an audio sample, it can be any of the native Go numeric types.
type Samples ¶
type Samples[T Sample] []T
Samples represents a mono audio buffer, or a single channel.
func Interleave ¶
Interleave a buffer into a single samples slice.
The provided samples dst should be nil, or adequately sized to fit channels of samples.
func (Samples[T]) BitsPerSample ¶
BitsPerSample is the number of bits required to store one sample.
func (Samples[T]) DecodeFrom ¶
DecodeFrom reads samples from r to s.
func (Samples[T]) DecodeFromChunked ¶
func (s Samples[T]) DecodeFromChunked(r io.Reader, order binary.ByteOrder, chunkSize int) (n int, err error)
DecodeFromChunked reads samples from r to s.
If s doesn't contain a multiple of chunkSize samples, an additional smaller chunk will be read to complete to read.
func (Samples[T]) EncodeToChunked ¶
func (s Samples[T]) EncodeToChunked(w io.Writer, order binary.ByteOrder, chunkSize int) (n int, err error)
WriteChunked writes samples contained in src to w.
func (Samples[T]) ToComplex ¶
func (s Samples[T]) ToComplex(dst []complex128) []complex128
ToComplex converts the samples in s to []complex128 in dst.