Easy Audio ยป FLAC

To read and decode FLAC file or stream you need to follow these steps:

  1. Open a FLAC file/Get a stream with element type (unsigned-byte 8).
  2. Pass the stream to flac:open-flac function which will create and return bitreader:reader object. This object allows easy-audio library to read not just octets, but any amount of bits from audio stream.
  3. Read metadata blocks from the stream, passing the object from previous step to flac:read-metadata.
  4. Do whatever you want with metadata and read the first audio frame with flac:read-frame.
  5. Decode the frame with flac:decode-frame and repeat previous step until all data is read and decoded.

API

Conditions.
flac-error
General (unspecified) flac error
    flac-bad-metadata
    Flac metadata error
    • metadata
      Current metadata
      Allocationinstance
      Typenil
      Initarg:metadata
      Readers(flac-metadata)
    flac-bad-frame
    Bad flac frame
      Metadata blocks.
      streaminfo
      STREAMINFO metadata block. The most important metadata block in the file.
      • %minblocksize
        Type(unsigned-byte 16)
        Readereasy-audio.flac::streaminfo-%minblocksize
      • %maxblocksize
        Type(unsigned-byte 16)
        Readereasy-audio.flac::streaminfo-%maxblocksize
      • %minframesize
        Type(unsigned-byte 24)
        Readereasy-audio.flac::streaminfo-%minframesize
      • %maxframesize
        Type(unsigned-byte 24)
        Readereasy-audio.flac::streaminfo-%maxframesize
      • %samplerate
        Typealexandria:positive-fixnum
        Readereasy-audio.flac::streaminfo-%samplerate
      • %channels
        Type(integer 1 8)
        Readereasy-audio.flac::streaminfo-%channels
      • %bitspersample
        Type(integer 4 32)
        Readereasy-audio.flac::streaminfo-%bitspersample
      • %totalsamples
        Type(unsigned-byte 36)
        Readereasy-audio.flac::streaminfo-%totalsamples
      • %md5
        Type(easy-audio.core:sa-ub 8)
        Readereasy-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.
      padding
      Zero padding
        vorbis-comment
        VORBIS_COMMENT metadata block
        • vendor
          Typestring
          Readereasy-audio.flac:vorbis-comment-vendor
        • user
          Typelist
          Readereasy-audio.flac:vorbis-comment-user
        seektable
        SEEKTABLE metadata block
        • seekpoints
          Typelist
          Readereasy-audio.flac:seektable-seekpoints
        seekpoint
        A seekpoint (entry in a seektable)
        • samplenum
          Type(easy-audio.core:ub 64)
          Readereasy-audio.flac:seekpoint-samplenum
        • offset
          Type(easy-audio.core:ub 64)
          Readereasy-audio.flac:seekpoint-offset
        • samples-in-frame
          Type(easy-audio.core:ub 16)
          Readereasy-audio.flac:seekpoint-samples-in-frame
        cuesheet
        CUESHEET metadata block
        • %catalog-id
          Typestring
          Readereasy-audio.flac::cuesheet-%catalog-id
        • %lead-in
          Type(unsigned-byte 64)
          Readereasy-audio.flac::cuesheet-%lead-in
        • %cdp
          Typeboolean
          Readereasy-audio.flac::cuesheet-%cdp
        • %tracks
          Typelist
          Readereasy-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-track
        Represents a track in a cuesheet metadata
        • offset
          Type(unsigned-byte 64)
          Readereasy-audio.flac:cuesheet-track-offset
        • number
          Type(unsigned-byte 8)
          Readereasy-audio.flac:cuesheet-track-number
        • isrc
          Typestring
          Readereasy-audio.flac:cuesheet-track-isrc
        • type
          Type(member :audio :non-audio)
          Readereasy-audio.flac:cuesheet-track-type
        • pre-emphasis
          Typeboolean
          Readereasy-audio.flac:cuesheet-track-pre-emphasis
        • indices
          Typelist
          Readereasy-audio.flac:cuesheet-track-indices
        cuesheet-index
        Represents an index into a track in a cuesheet metadata
        • offset
          Type(unsigned-byte 64)
          Readereasy-audio.flac:cuesheet-index-offset
        • number
          Type(unsigned-byte 8)
          Readereasy-audio.flac:cuesheet-index-number
        picture
        PICTURE metadata block
        • %type
          Type(integer 0 20)
          Readereasy-audio.flac::picture-%type
        • %mime-type
          Typestring
          Readereasy-audio.flac::picture-%mime-type
        • %description
          Typestring
          Readereasy-audio.flac::picture-%description
        • %width
          Type(unsigned-byte 32)
          Readereasy-audio.flac::picture-%width
        • %height
          Type(unsigned-byte 32)
          Readereasy-audio.flac::picture-%height
        • %depth
          Type(unsigned-byte 32)
          Readereasy-audio.flac::picture-%depth
        • %color-num
          Type(unsigned-byte 32)
          Readereasy-audio.flac::picture-%color-num
        • %picture
          Type(easy-audio.core:sa-ub 8)
          Readereasy-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.
        Working with audio frames.
        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.
        frame
        Atomic element of audio data in the FLAC stream
        • %blocking-strategy
          Type(member :fixed :variable)
          Readereasy-audio.flac::frame-%blocking-strategy
        • %block-size
          Typeeasy-audio.flac:blocksize
          Readereasy-audio.flac::frame-%block-size
        • %sample-rate
          Typealexandria:positive-fixnum
          Readereasy-audio.flac::frame-%sample-rate
        • %channel-assignment
          Type(integer 1 11)
          Readereasy-audio.flac::frame-%channel-assignment
        • %sample-size
          Type(integer 4 32)
          Readereasy-audio.flac::frame-%sample-size
        • %number
          Typeunsigned-byte
          Readereasy-audio.flac::frame-%number
        • %crc-8
          Type(easy-audio.core:ub 8)
          Readereasy-audio.flac::frame-%crc-8
        • %subframes
          Typelist
          Readereasy-audio.flac::frame-%subframes
        • %crc-16
          Type(easy-audio.core:ub 16)
          Readereasy-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).
        Other functions / helpers.
        open-flac(stream)
        Return bitreader handler of flac stream
        read-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
        It also can decode FLAC data from OGG container. There are flac:open-ogg-flac, flac:read-ogg-metadata and flac:read-ogg-frame functions for that purpose. Seeking does not work with OGG container.