flac

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flac decodes a FLAC stream into PCM samples, with the standard library only. It is test-data tooling: cmd/speech-testdata uses it to turn LibriSpeech's FLAC files into WAVE files without ffmpeg or a dependency.

It decodes every subframe type (constant, verbatim, fixed, LPC), wasted bits, both residual coding methods with escaped partitions, and the stereo decorrelation modes, checks each frame header's CRC-8 and each frame's CRC-16, and checks the decoded audio against the stream's MD5 signature. Metadata blocks other than STREAMINFO are skipped.

Index

Constants

This section is empty.

Variables

View Source
var ErrFormat = errors.New("flac: invalid stream")

ErrFormat means the stream is not valid FLAC or uses something this decoder does not support.

View Source
var ErrIntegrity = errors.New("flac: integrity check failed")

ErrIntegrity means a frame's CRC or the stream's MD5 signature does not match.

Functions

This section is empty.

Types

type Stream

type Stream struct {
	Info StreamInfo
	// Samples holds one slice per channel, each Info.TotalSamples long.
	Samples [][]int32
}

Stream is a decoded FLAC stream.

func Decode

func Decode(r io.Reader) (Stream, error)

Decode reads a whole FLAC stream from r.

type StreamInfo

type StreamInfo struct {
	MinBlock, MaxBlock int
	SampleRate         int
	Channels           int
	BitsPerSample      int
	TotalSamples       uint64 // per channel; 0 means unknown
	MD5                [16]byte
}

StreamInfo is the stream's STREAMINFO block.

Jump to

Keyboard shortcuts

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