dart_flac library

Pure-Dart FLAC decoding and metadata parsing.

Import this library when you need to read FLAC metadata, decode frames, stream little-endian PCM chunks, verify STREAMINFO MD5 signatures, or write decoded samples to a WAV byte stream. The package has no native bindings and works on the Dart VM, Flutter, AOT, and web when bytes are supplied directly.

Classes

ApplicationBlock
FLAC APPLICATION metadata block.
BlockType
Block type identifiers for FLAC metadata blocks.
ChannelAssignment
Channel assignment identifiers used in FLAC frame headers.
CueSheetBlock
FLAC CUESHEET metadata block.
CueSheetTrack
A single track in a CueSheetBlock.
CueSheetTrackIndex
An index point within a CueSheetTrack.
FlacFrame
A fully decoded FLAC audio frame containing one or more channels.
FlacReader
High-level FLAC file reader.
FrameHeader
The decoded header of a single FLAC audio frame.
Md5Verifier
Streaming MD5 verifier for FLAC PCM samples.
MetadataBlock
Base class for all FLAC metadata blocks.
PaddingBlock
FLAC PADDING metadata block.
PictureBlock
FLAC PICTURE metadata block.
PictureType
Picture types as defined in the ID3v2 APIC frame specification.
SeekPoint
A single seek point in a FLAC SeekTableBlock.
SeekTableBlock
FLAC SEEKTABLE metadata block.
StreamInfoBlock
Decoded FLAC STREAMINFO metadata block.
StreamingFlacDecoder
A push-based FLAC decoder.
UnknownMetadataBlock
A metadata block whose type is not recognised by this library version.
VorbisCommentBlock
FLAC VORBIS_COMMENT metadata block.

Enums

BlockingStrategy
The blocking strategy used in a FLAC frame.
Md5VerificationResult
Result of verifying decoded PCM against the MD5 signature stored in the STREAMINFO block.

Functions

decodeFlacBytesToPcm(Uint8List flacBytes, {int outputBitsPerSample = 16}) Uint8List
Isolate-safe companion to decodeFlacFileToPcm that takes raw FLAC bytes instead of a filesystem path.
decodeFlacFileToPcm(String path, {int outputBitsPerSample = 16}) Future<Uint8List>
Decodes a FLAC file at path and returns the entire audio track as interleaved, little-endian, signed PCM bytes.
frameToInterleavedPcm(FlacFrame frame, int outputBitsPerSample) Uint8List
Converts a decoded FlacFrame to interleaved, little-endian, signed PCM bytes — the format expected by virtually every low-level audio sink.
frameToWavPcmBytes(FlacFrame frame, int outputBitsPerSample, {int skipSamples = 0, int? takeSamples}) Uint8List
Converts frame to WAV-compatible PCM bytes.
parseMetadataBlock(int type, bool isLast, int length, Uint8List data) MetadataBlock
Dispatches a raw metadata block to its typed parser.
readLengthPrefixedStringLE(Uint8List data, int offset) → (String, int)
Reads a string prefixed by a 32-bit little-endian length field.
readUint32BE(Uint8List data, int offset) int
Reads a 32-bit big-endian unsigned integer from data at offset.
readUint32LE(Uint8List data, int offset) int
Reads a 32-bit little-endian unsigned integer from data at offset.
readUint64BE(Uint8List data, int offset) → Int64
Reads a 64-bit big-endian unsigned integer from data at offset as an Int64.
readUtf8Bytes(Uint8List data, int offset, int byteLength) String
Reads a UTF-8 encoded string of byteLength bytes from data at offset.
writeWavBytes({required Iterable<FlacFrame> frames, required int sampleRate, required int channels, required int bitsPerSample}) Uint8List
Serialises decoded FLAC samples as a RIFF/WAVE byte buffer.
writeWavHeaderBytes({required int dataSize, required int sampleRate, required int channels, required int bitsPerSample}) Uint8List
Returns a 44-byte RIFF/WAVE PCM header for a following PCM payload.