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-wv
function which will create and returnbitreader:reader
object. 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-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 filesunknown-metadata
The reader does not know how to read metadata
metadata
Metadata objectOption Value Allocation: instance Type: nil
Initarg: :metadata
Readers: (unknown-metadata)
metadata-riff-header
Option | Value |
Superclasses: | (metadata-ignorable t) |
Metaclass: | standard-class |
Default Initargs: | nil |
Contents the original RIFF header in DATA slot
metadata-riff-trailer
Option | Value |
Superclasses: | (metadata-ignorable t) |
Metaclass: | standard-class |
Default Initargs: | nil |
Contents the original RIFF trailer in DATA slot
BLOCK-SLOTNAME
.
wv-block
Option | Value |
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
id
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv::block-id
Initform: 0
size
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv::block-size
Initform: 0
version
Option Value Type: (easy-audio.core:ub 16)
Read Only: nil
Accessor: easy-audio.wv::block-version
Initform: 0
track-number
Option Value Type: (easy-audio.core:ub 8)
Read Only: nil
Accessor: easy-audio.wv:block-track-number
Initform: 0
index-number
Option Value Type: (easy-audio.core:ub 8)
Read Only: nil
Accessor: easy-audio.wv:block-index-number
Initform: 0
total-samples
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv:block-total-samples
Initform: 0
block-index
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv:block-block-index
Initform: 0
block-samples
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv:block-block-samples
Initform: 0
flags
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv::block-flags
Initform: 0
crc
Option Value Type: (easy-audio.core:ub 32)
Read Only: nil
Accessor: easy-audio.wv::block-crc
Initform: 0
metadata
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv:block-metadata
decorr-passes
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv::block-decorr-passes
decorr-samples
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv::block-decorr-samples
entropy-median
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv::block-entropy-median
residual
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv::block-residual
int32-info
Option Value Type: t
Read Only: nil
Accessor: easy-audio.wv::block-int32-info
wvx-bits
Option Value Type: t
Read Only: nil
Accessor: 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
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 streammake-output-buffers
(reader)
Make output buffers to bind them to
*residual-buffers*
to reduce consing.*residual-buffers*
Works with
make-output-buffers
to reduce consing.
Bind this variable to output buffers when you read multiple
block in a loop to reduce consing.with-output-buffers
((reader) &body body)
Calls to
read-wv-block
, restore-sync
etc. can be done inside this macro to
avoid unnecessary consing if all WavPack blocks in the stream contain the same number
of samples and have the same number of channels.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.