To read and decode FLAC file or stream you need to follow these steps:
- Open a FLAC file/Get a stream with element type
(unsigned-byte 8). - Pass the stream to
flac:open-flacfunction which will create and returnbitreader:readerobject. This object allowseasy-audiolibrary to read not just octets, but any amount of bits from audio stream. - Read metadata blocks from the stream, passing the object from previous
step to
flac:read-metadata. - Do whatever you want with metadata and read the first audio frame with
flac:read-frame. - Decode the frame with
flac:decode-frameand repeat previous step until all data is read and decoded.
API
Conditions.flac-errorGeneral (unspecified) flac error
flac-bad-metadataFlac metadata error
metadataCurrent metadataAllocation instance Type nilInitarg :metadataReaders (flac-metadata)
flac-bad-frameBad flac frame
streaminfoSTREAMINFO metadata block. The most important metadata block in the
file.
%minblocksizeType (unsigned-byte 16)Reader easy-audio.flac::streaminfo-%minblocksize%maxblocksizeType (unsigned-byte 16)Reader easy-audio.flac::streaminfo-%maxblocksize%minframesizeType (unsigned-byte 24)Reader easy-audio.flac::streaminfo-%minframesize%maxframesizeType (unsigned-byte 24)Reader easy-audio.flac::streaminfo-%maxframesize%samplerateType alexandria:positive-fixnumReader easy-audio.flac::streaminfo-%samplerate%channelsType (integer 1 8)Reader easy-audio.flac::streaminfo-%channels%bitspersampleType (integer 4 32)Reader easy-audio.flac::streaminfo-%bitspersample%totalsamplesType (unsigned-byte 36)Reader easy-audio.flac::streaminfo-%totalsamples%md5Type (easy-audio.core:sa-ub 8)Reader easy-audio.flac::streaminfo-%md5
streaminfo-minblocksize(streaminfo)The minimum block size (in samples) used in the stream.
streaminfo-maxblocksize(streaminfo)The maximum block size (in samples) used in the stream.
streaminfo-minframesize(streaminfo)The minimum frame size (in bytes) used in the stream.
streaminfo-maxframesize(streaminfo)The maximum frame size (in bytes) used in the stream.
streaminfo-samplerate(streaminfo)Sample rate in Hz.
streaminfo-channels(streaminfo)The number of channels in a stream. May be from 1 to 8.
streaminfo-bitspersample(streaminfo)Bits per sample (from 4 to 32).
streaminfo-totalsamples(streaminfo)Total number of samples in a stream. May be 0 if unknown.
streaminfo-md5(streaminfo)MD5 checksum of the whole unencoded data.
paddingZero padding
vorbis-commentVORBIS_COMMENT metadata block
vendorType stringReader easy-audio.flac:vorbis-comment-vendoruserType listReader easy-audio.flac:vorbis-comment-user
seektableSEEKTABLE metadata block
seekpointsType listReader easy-audio.flac:seektable-seekpoints
seekpointA seekpoint (entry in a seektable)
samplenumType (easy-audio.core:ub 64)Reader easy-audio.flac:seekpoint-samplenumoffsetType (easy-audio.core:ub 64)Reader easy-audio.flac:seekpoint-offsetsamples-in-frameType (easy-audio.core:ub 16)Reader easy-audio.flac:seekpoint-samples-in-frame
cuesheetCUESHEET metadata block
%catalog-idType stringReader easy-audio.flac::cuesheet-%catalog-id%lead-inType (unsigned-byte 64)Reader easy-audio.flac::cuesheet-%lead-in%cdpType booleanReader easy-audio.flac::cuesheet-%cdp%tracksType listReader easy-audio.flac::cuesheet-%tracks
cuesheet-catalog-id(cuesheet)Media catalog number.
cuesheet-lead-in(cuesheet)For CD-DA cuesheets, the number of lead-in samples, 0 otherwise.
cuesheet-cdp(cuesheet)t if cuesheet corresponds to a Compact Disk.cuesheet-tracks(cuesheet)A list of tracks.
cuesheet-trackRepresents a track in a cuesheet metadata
offsetType (unsigned-byte 64)Reader easy-audio.flac:cuesheet-track-offsetnumberType (unsigned-byte 8)Reader easy-audio.flac:cuesheet-track-numberisrcType stringReader easy-audio.flac:cuesheet-track-isrctypeType (member :audio :non-audio)Reader easy-audio.flac:cuesheet-track-typepre-emphasisType booleanReader easy-audio.flac:cuesheet-track-pre-emphasisindicesType listReader easy-audio.flac:cuesheet-track-indices
cuesheet-indexRepresents an index into a track in a cuesheet metadata
offsetType (unsigned-byte 64)Reader easy-audio.flac:cuesheet-index-offsetnumberType (unsigned-byte 8)Reader easy-audio.flac:cuesheet-index-number
picturePICTURE metadata block
%typeType (integer 0 20)Reader easy-audio.flac::picture-%type%mime-typeType stringReader easy-audio.flac::picture-%mime-type%descriptionType stringReader easy-audio.flac::picture-%description%widthType (unsigned-byte 32)Reader easy-audio.flac::picture-%width%heightType (unsigned-byte 32)Reader easy-audio.flac::picture-%height%depthType (unsigned-byte 32)Reader easy-audio.flac::picture-%depth%color-numType (unsigned-byte 32)Reader easy-audio.flac::picture-%color-num%pictureType (easy-audio.core:sa-ub 8)Reader easy-audio.flac::picture-%picture
picture-type(picture)One of 21 picture types (see the flac format description).
picture-mime-type(picture)A string with the MIME type.
picture-description(picture)Picture description (an UTF-8 coded string).
picture-width(picture)Width of the picture.
picture-height(picture)Height of the picture.
picture-depth(picture)Color depth of the picture.
picture-color-num(picture)Number of colors in an indexed picture, 0 if the picture is non-indexed.
picture-picture(picture)The picture itself as an array of octets.
read-frame(stream &optional streaminfo)Read a frame from a flac stream. An additional metadata
streaminfo may be required for some files which do not support
streaming.decode-frame(frame)Decode a frame. Returns list of decoded audio buffers (one buffer for each channel).
blocksize(nil (quote (and (unsigned-byte 16) (not (eql 0)))))Possible size of a frame in samples.
frameAtomic element of audio data in the FLAC stream
%blocking-strategyType (member :fixed :variable)Reader easy-audio.flac::frame-%blocking-strategy%block-sizeType easy-audio.flac:blocksizeReader easy-audio.flac::frame-%block-size%sample-rateType alexandria:positive-fixnumReader easy-audio.flac::frame-%sample-rate%channel-assignmentType (integer 1 11)Reader easy-audio.flac::frame-%channel-assignment%sample-sizeType (integer 4 32)Reader easy-audio.flac::frame-%sample-size%numberType unsigned-byteReader easy-audio.flac::frame-%number%crc-8Type (easy-audio.core:ub 8)Reader easy-audio.flac::frame-%crc-8%subframesType listReader easy-audio.flac::frame-%subframes%crc-16Type (easy-audio.core:ub 16)Reader easy-audio.flac::frame-%crc-16
frame-blocking-strategy(frame)Is the blocking strategy :FIXED (frame header contains the frame
number) or :VARIABLE (frame header contains the sample number)?
frame-block-size(frame)Block size in samples.
frame-sample-rate(frame)Block sample rate in Hertz.
+left-side+The encoded frame contains data for the left channel + the
difference with the right channel.
+right-side+The encoded frame contains data for the right channel + the
difference with the left channel.
+mid-side+The encoded frame contains data for the left/right average + the
difference with the left/right channels.
frame-channel-assignment(frame)Number of channels or one of
+mid-side+, +left-side+, +right-side+.frame-sample-size(frame)Bits per sample.
frame-number(frame)Number of a frame or of the first sample in the frame.
frame-crc-8(frame)CRC8 of a frame header (including the sync code).
frame-subframes(frame)List of subframes (one for each channel).
frame-crc-16(frame)CRC16 of the frame (back to and including the sync code).
open-flac(stream)Return
bitreader handler of flac streamread-metadata(bitreader)Return list of metadata blocks in the stream
seek-sample(bitreader sample &key seektable streaminfo)Seeks to an interchannel sample. Sets input to new frame, which
contains this sample. Returns position of this sample in the frame.
seektable and streaminfo are optional. Providing
streaminfo enables additional sanity checks. Currently only fixed
block size is supported.metadata-find-seektable(metadata)Return a seektable from metadata list if any
flac:open-ogg-flac, flac:read-ogg-metadata and flac:read-ogg-frame
functions for that purpose. Seeking does not work with OGG container.