Documentation
¶
Overview ¶
Package analysis computes information about a file that playback does not need, starting with the waveform a seek bar draws.
It never touches the playback ring: the ring is forward-only and feeding the device, so reading it would steal audio. Waveform opens its own decoder and runs synchronously on the caller's goroutine, which is why every entry point takes a context a scrubbing UI can cancel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBuckets = errors.New("analysis: Buckets must be positive")
ErrBuckets means Options.Buckets was not positive. It is a caller bug rather than a decode failure, so it is returned before any file is touched.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
Min, Max, RMS float32
}
Bucket is one column of a waveform: the extremes and the RMS of the mono downmix over a slice of frames.
type Options ¶
type Options struct {
// Buckets is the requested column count. It must be positive.
Buckets int
// OnProgress reports how far the decode has come, in frames. It is called
// once with zero before the first read and after every chunk. It runs on
// the calling goroutine, so a UI must keep it cheap.
OnProgress func(done, total int64)
// CacheDir overrides the on-disk cache directory. Empty selects
// <user cache dir>/molo/waveform. Tests set it so they never touch the
// real cache.
CacheDir string
// NoCache skips both reading and writing the cache.
NoCache bool
}
Options controls one waveform pass. Buckets is required; the rest have sensible zero values.
type Result ¶
type Result struct {
Buckets []Bucket
Format core.FrameFormat
Frames int64
}
Result is a decoded waveform. It is named Result rather than Waveform because a type and the function that builds it cannot share one identifier.