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:
- Open a WavPack file/Get a stream with element type
(unsigned-byte 8). This step is the same as for FLAC format. - Pass the stream to
wv:open-wvfunction which will create and returnbitreader:readerobject. Again, this is what you do when working with FLAC, just the function name differs. - 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 withwv:read-wv-block-multichannel. - Decode the block with
wv:decode-wv-blockand repeat previous step.
API
Conditions.wavpack-errorGeneral WavPack error
wavpack-warningGeneral WavPack warning
block-errorError associated with block reader/decoder error
lost-syncError 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 filesunknown-metadataThe reader does not know how to read metadata
metadataMetadata objectAllocation instance Type nilInitarg :metadataReaders (unknown-metadata)
metadata-riff-header| Superclasses | (metadata-ignorable t) |
| Metaclass | standard-class |
| Default Initargs | nil |
Contents the original RIFF header in DATA slot
metadata-riff-trailer| Superclasses | (metadata-ignorable t) |
| Metaclass | standard-class |
| Default Initargs | nil |
Contents the original RIFF trailer in DATA slot
BLOCK-SLOTNAME.
wv-block| Constructor | make-wv-block |
| Predicate | wv-block-p |
| Copier | copy-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
idType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv::block-idInitform 0sizeType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv::block-sizeInitform 0versionType (easy-audio.core:ub 16)Read Only nilAccessor easy-audio.wv::block-versionInitform 0track-numberType (easy-audio.core:ub 8)Read Only nilAccessor easy-audio.wv:block-track-numberInitform 0index-numberType (easy-audio.core:ub 8)Read Only nilAccessor easy-audio.wv:block-index-numberInitform 0total-samplesType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv:block-total-samplesInitform 0block-indexType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv:block-block-indexInitform 0block-samplesType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv:block-block-samplesInitform 0flagsType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv::block-flagsInitform 0crcType (easy-audio.core:ub 32)Read Only nilAccessor easy-audio.wv::block-crcInitform 0metadataType tRead Only nilAccessor easy-audio.wv:block-metadatadecorr-passesType tRead Only nilAccessor easy-audio.wv::block-decorr-passesdecorr-samplesType tRead Only nilAccessor easy-audio.wv::block-decorr-samplesentropy-medianType tRead Only nilAccessor easy-audio.wv::block-entropy-medianresidualType tRead Only nilAccessor easy-audio.wv::block-residualint32-infoType tRead Only nilAccessor easy-audio.wv::block-int32-infowvx-bitsType tRead Only nilAccessor easy-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).
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.