Easy Audio ยป WavPack

WavPack decoder works in the same manner as FLAC decoder, with exception that there is no metadata blocks in the beggining of file, but metadata section in each WavPack block. This metadata is not as useful as FLAC metadata, though. Information about track title, album or performer is usualy stored in APEv2 tag in the end of file. So the algorithm for WavPack is usually this:

  1. Open a WavPack file/Get a stream with element type (unsigned-byte 8). This step is the same as for FLAC format.
  2. Pass the stream to wv:open-wv function which will create and return bitreader:reader object. Again, this is what you do when working with FLAC, just the function name differs.
  3. Read the first WavPack block with wv:read-wv-block. It contains all information about channels, samplerate, etc. If the stream/file contains more than 2 channels (i.e. 5.1 audio), you can read multiple stereo or mono blocks with wv:read-wv-block-multichannel.
  4. Decode the block with wv:decode-wv-block and repeat previous step.

API

Conditions.
wavpack-error
General WavPack error
    wavpack-warning
    General WavPack warning
      block-error
      Error associated with block reader/decoder error
        lost-sync
        Error signaled when sync is obviously lost (e.g. first 4 bytes in block are not Wavpack ID). Errors signalled when reading a block which cause loss of sync are not of this type, but of block-error. Useful for skipping garbage in audio files
          unknown-metadata
          The reader does not know how to read metadata
          • metadata
            Metadata object
            Allocationinstance
            Typenil
            Initarg:metadata
            Readers(unknown-metadata)
          Metadata.
          metadata-riff-header
          Superclasses(metadata-ignorable t)
          Metaclassstandard-class
          Default Initargsnil
          Contents the original RIFF header in DATA slot
            metadata-riff-trailer
            Superclasses(metadata-ignorable t)
            Metaclassstandard-class
            Default Initargsnil
            Contents the original RIFF trailer in DATA slot
              WavPack blocks. WavPack block class has readers/accessors in the form BLOCK-SLOTNAME.
              wv-block
              Constructormake-wv-block
              Predicatewv-block-p
              Copiercopy-wv-block
              Print Function(lambda (struct stream k) (declare (ignore k)) (print-unreadable-object (struct stream type t identity t) (format stream samples ~d..~d (block-block-index struct) (+ (block-block-index struct) (block-block-samples struct)))))
              WavPack block structure
              • id
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv::block-id
                Initform0
              • size
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv::block-size
                Initform0
              • version
                Type(easy-audio.core:ub 16)
                Read Onlynil
                Accessoreasy-audio.wv::block-version
                Initform0
              • track-number
                Type(easy-audio.core:ub 8)
                Read Onlynil
                Accessoreasy-audio.wv:block-track-number
                Initform0
              • index-number
                Type(easy-audio.core:ub 8)
                Read Onlynil
                Accessoreasy-audio.wv:block-index-number
                Initform0
              • total-samples
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv:block-total-samples
                Initform0
              • block-index
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv:block-block-index
                Initform0
              • block-samples
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv:block-block-samples
                Initform0
              • flags
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv::block-flags
                Initform0
              • crc
                Type(easy-audio.core:ub 32)
                Read Onlynil
                Accessoreasy-audio.wv::block-crc
                Initform0
              • metadata
                Typet
                Read Onlynil
                Accessoreasy-audio.wv:block-metadata
              • decorr-passes
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-decorr-passes
              • decorr-samples
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-decorr-samples
              • entropy-median
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-entropy-median
              • residual
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-residual
              • int32-info
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-int32-info
              • wvx-bits
                Typet
                Read Onlynil
                Accessoreasy-audio.wv::block-wvx-bits
              read-wv-block(reader)
              Read the next block in the stream. reader's position must be set to the beginning of this block explicitly (e.g. by calling restore-sync).
              read-wv-block-multichannel(reader)
              Read a list of Wavpack blocks in an multichannel configuration different from 1.0 or 2.0. Each block in the list can itself be mono or stereo. Read the format specification for the details.
              decode-wv-block(wv-block)
              Decode a wavpack block, destructively modifying it. This function returns a list of simple-arrays, each correspoding to a separate channel.
              block-samplerate(wv-block)
              Return a sample rate of a block.
              block-bps(wv-block)
              Return bits per second of a block.
              block-channels(wv-block)
              Return a number of channels (a block can have 1 or 2 channels).
              Other stuff.
              restore-sync(reader)
              Restore the reader's position to the first occurring block in the stream.
              restore-sync-multichannel(reader)
              Restore sync in multichannel configuration. The reader position is set to the beginning of the first channel block.
              seek-sample(reader number)
              Set reader position to beginning of the block which contains a sample with the specified number. Works for readers associated with files. Return a position of the sample in the block.
              open-wv(stream)
              Return bitreader handle of Wavpack stream.
              read-new-block(c)
              Function to be supplied to handler-bind in order to deal with lost-sync condition. It transfers control to read-new-block-single or to read-new-block-multichannel depending on the situation. A newly read block or a list of blocks is always returned from handler-bind if bitreader-eof is not signalled.