Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
func Encode(block Block, format media.SampleFormat, bitsPerSample int) (*media.AudioFrame, error)
func EncodeInto ¶
func EncodeInto(block Block, format media.SampleFormat, bitsPerSample int, scratch *Scratch) (*media.AudioFrame, error)
Types ¶
type Block ¶
type Block struct {
Source *media.AudioFrame
Channels Channels
Layout media.ChannelLayout
Rate int
Format media.SampleFormat
Bits int
PTS media.Pts
}
type Channels ¶
type Channels [][]float32
Channels holds one []float32 sample buffer per audio channel.
type Record ¶
Record describes a Block's shape (timing and sample count) without retaining its sample data. Spool uses it to index buffered audio; callers that track block shape without buffering samples at all (e.g. a silence-run replay buffer) can reuse the same bookkeeping.
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch holds reusable per-channel and interleave buffers for repeated DecodeInto/EncodeInto calls made by the same caller, so steady-state frame processing reuses last frame's backing arrays instead of allocating a fresh []float32 per channel per frame. A Block returned by DecodeInto aliases its Scratch's buffers, so the caller must be done with it (mutate it in place and/or hand it to EncodeInto) before decoding another frame into the same Scratch. Not safe for concurrent use: a caller that decodes more than one frame concurrently (e.g. a filter with multiple input ports pulled on separate goroutines) needs one Scratch per concurrent caller.