Documentation
¶
Overview ¶
Package flac provides a native Go FLAC encoder and decoder. It uses no CGO and no external binaries; the encoder hot paths are SIMD-accelerated behind a pure-Go fallback (bit-identical output), so it builds and runs on every Go target.
The high-level PCM streaming API lives in the pcm subpackage (github.com/tphakala/go-flac/pcm). Use pcm.NewDecoder to decode a FLAC stream to interleaved little-endian PCM, and pcm.NewEncoder to encode interleaved little-endian PCM to a FLAC stream. This root package exposes only shared types used across the public API. Codec internals live under internal/.
Index ¶
Constants ¶
const Version = "0.4.3"
Version is the current library version. go-flac follows semantic versioning.
Variables ¶
var ( // ErrSeekUnsupported is returned by SeekToSample when the source is not seekable. ErrSeekUnsupported = errors.New("go-flac: seek unsupported (source is not an io.Seeker)") // ErrMissingStreamInfo means the stream had no STREAMINFO metadata block, or it did // not appear first. ErrMissingStreamInfo = errors.New("go-flac: missing or misplaced STREAMINFO block") // ErrCRCMismatch means a frame header CRC-8 or frame CRC-16 did not match. ErrCRCMismatch = errors.New("go-flac: CRC mismatch") // ErrMD5Mismatch means the decoded-audio MD5 did not match the STREAMINFO MD5. ErrMD5Mismatch = errors.New("go-flac: MD5 mismatch") // ErrUnsupported marks a reserved or illegal coded value, or an unsupported layout. ErrUnsupported = errors.New("go-flac: unsupported or reserved bitstream value") // ErrEncoderClosed is returned by Encoder.Write after Close has been called. ErrEncoderClosed = errors.New("go-flac: encoder is closed") // ErrTruncatedStream means the stream ended before delivering the sample count // STREAMINFO declares (an inter-frame cut on a zero-MD5 stream), or a frame body // was cut short. Mid-frame truncation wraps io.ErrUnexpectedEOF. ErrTruncatedStream = errors.New("go-flac: truncated stream") // ErrInvalidSeek means SeekToSample was called with a negative sample index. ErrInvalidSeek = errors.New("go-flac: invalid seek (negative sample index)") )
Sentinel errors returned by the decoder and the pcm streaming layer. Callers can test for them with errors.Is.
Functions ¶
This section is empty.
Types ¶
type StreamInfo ¶
type StreamInfo struct {
SampleRate int // samples per second, e.g. 44100
Channels int // number of channels, 1..8
BitDepth int // bits per sample, e.g. 16 or 24
TotalSamples uint64 // inter-channel sample count; 0 if unknown
MD5 [16]byte // MD5 of the unencoded audio; all-zero if absent
}
StreamInfo describes a FLAC stream's global properties, mirroring the STREAMINFO metadata block.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
wav2flac
command
Command wav2flac encodes a PCM WAV file to FLAC using the pure-Go go-flac encoder.
|
Command wav2flac encodes a PCM WAV file to FLAC using the pure-Go go-flac encoder. |
|
internal
|
|
|
bitio
Package bitio implements MSB-first bit-level reading and writing in the bit order used by the FLAC bitstream.
|
Package bitio implements MSB-first bit-level reading and writing in the bit order used by the FLAC bitstream. |
|
crc
Package crc provides the checksums FLAC requires: CRC-8 over each frame header, CRC-16 over each complete frame, and the MD5 of the unencoded audio stored in STREAMINFO.
|
Package crc provides the checksums FLAC requires: CRC-8 over each frame header, CRC-16 over each complete frame, and the MD5 of the unencoded audio stored in STREAMINFO. |
|
frame
Package frame implements FLAC frame and subframe coding: the frame header (with CRC-8 sync validation and frame-sync scanning used for seek and resync), the four subframe types (constant, verbatim, fixed, LPC), and inter-channel decorrelation (left/side, right/side, mid/side).
|
Package frame implements FLAC frame and subframe coding: the frame header (with CRC-8 sync validation and frame-sync scanning used for seek and resync), the four subframe types (constant, verbatim, fixed, LPC), and inter-channel decorrelation (left/side, right/side, mid/side). |
|
i32
Package i32 provides SIMD-accelerated operations on int32 slices that back go-flac's integer hot loops (Rice cost search, fixed predictors, quantized LPC, stereo decorrelation) where the per-sample work is integer arithmetic and channel (de)interleaving rather than floating-point math.
|
Package i32 provides SIMD-accelerated operations on int32 slices that back go-flac's integer hot loops (Rice cost search, fixed predictors, quantized LPC, stereo decorrelation) where the per-sample work is integer arithmetic and channel (de)interleaving rather than floating-point math. |
|
lpc
Package lpc, analysis side: windowing, autocorrelation, Levinson-Durbin, coefficient quantization, and order estimation for the encoder.
|
Package lpc, analysis side: windowing, autocorrelation, Levinson-Durbin, coefficient quantization, and order estimation for the encoder. |
|
meta
Package meta implements FLAC metadata blocks: STREAMINFO, VORBIS_COMMENT, SEEKTABLE, PICTURE, CUESHEET, PADDING, and APPLICATION.
|
Package meta implements FLAC metadata blocks: STREAMINFO, VORBIS_COMMENT, SEEKTABLE, PICTURE, CUESHEET, PADDING, and APPLICATION. |
|
rice
Package rice implements FLAC's Rice/Golomb residual coding: encoding and decoding of partitioned residuals and the parameter search that picks the cheapest Rice parameter per partition.
|
Package rice implements FLAC's Rice/Golomb residual coding: encoding and decoding of partitioned residuals and the parameter search that picks the cheapest Rice parameter per partition. |
|
Package pcm is the high-level, clean-room PCM streaming API for go-flac.
|
Package pcm is the high-level, clean-room PCM streaming API for go-flac. |