- Open the audio stream as an ordinary input stream with element
type
(unsigned-byte 8)
. - Create a bitreader object with
open-wav
. - Read wav chunks with metadata calling
read-wav-header
. - Because the metadata can be placed after the audio data itself,
rewind the reader to the beginning of audio data calling
reader-position-to-audio-data
. - Read audio samples with
read-wav-data
. - Optionaly,
decode-wav-data
. Usually this step can be ommited because the audio stream already has uncompressed PCM data.decode-wav-data
is no-op in this case.
write-pcm-wav-header
function and with-output-to-wav
macro.API
read-wav-header
(reader)
Read RIFF chunks from an audio stream
reader-position-to-audio-data
(reader subchunks)
Set the reader's position to beginning of audio data
read-wav-data
(reader format nsamples &key decompose)
Read a portion of audio data in the wav stream. Requires a
bitreader
and
format
subchunk. Reads exactly nsamples
interchannel
samples. Optionally, decomposes them into different by-channel arrays if
decompose
is T
.decode-wav-data
(format buffer)
Decodes wav audio data in the
buffer
. Often, in the case of uncompressed
data, it simply returns the buffer
unmodified.samples-num
(subchunks)
Returns a number of interchannel samples in the stream.
get-info-metadata
(subchunks)
Return metadata in the LIST INFO subchunks as an association list
+wave-format-pcm+
PCM audio format
+wave-format-float+
Float audio format
+wave-format-alaw+
A-law coded audio
+wave-format-mulaw+
Mu-law coded audio
+wave-format-extensible+
Extensible audio format
format-subchunk
Option | Value |
Superclasses: | (subchunk t) |
Metaclass: | standard-class |
Default Initargs: | nil |
Audio format subchunk
audio-format
Audio formatOption Value Allocation: instance Type: (easy-audio.core:ub 16)
Accessors: (format-audio-format)
channels-num
Number of channels in the streamOption Value Allocation: instance Type: (easy-audio.core:ub 16)
Accessors: (format-channels-num)
samplerate
Samplerate in HertzOption Value Allocation: instance Type: (easy-audio.core:ub 32)
Accessors: (format-samplerate)
byte-rate
Option Value Allocation: instance Type: (easy-audio.core:ub 32)
Accessors: (format-byte-rate)
block-align
Option Value Allocation: instance Type: (easy-audio.core:ub 16)
Accessors: (format-block-align)
bps
Bits per sampleOption Value Allocation: instance Type: (easy-audio.core:ub 16)
Accessors: (format-bps)
valid-bps
Valid bits per sampleOption Value Allocation: instance Type: (easy-audio.core:ub 16)
Accessors: (format-valid-bps)
channel-mask
Channel mask of used channelsOption Value Allocation: instance Type: (easy-audio.core:ub 32)
Accessors: (format-channel-mask)
subformat
Extended audio formatOption Value Allocation: instance Type: (easy-audio.core:sa-ub 8)
Accessors: (format-subformat)
data-subchunk
Option | Value |
Superclasses: | (subchunk t) |
Metaclass: | standard-class |
Default Initargs: | nil |
Audio data subchunk
audio-position
Option Value Allocation: instance Type: unsigned-byte
Initarg: :audio-position
Accessors: (data-audio-position)
fact-subchunk
Option | Value |
Superclasses: | (subchunk t) |
Metaclass: | standard-class |
Default Initargs: | nil |
Subchunk with actual number of samples
samples-num
Number of interchannel samplesOption Value Allocation: instance Type: (easy-audio.core:ub 32)
Accessors: (fact-samples-num)
info-subchunk
Option | Value |
Superclasses: | (data-chunk t) |
Metaclass: | standard-class |
Default Initargs: | nil |
LIST INFO subchunk. Together they constitue key-value metadata
for the audio stream
key
Key of an info subchunkOption Value Allocation: instance Type: (or symbol string)
Initarg: :key
Accessors: (info-key)
value
Value of an info subchunkOption Value Allocation: instance Type: string
Initarg: :value
Accessors: (info-value)
wav-error
General Wav error
wav-error-chunk
Error while reading a chunk
reader
Option Value Allocation: instance Type: nil
Initarg: :reader
Readers: (wav-error-reader)
rest-bytes
Option Value Allocation: instance Type: nil
Initarg: :rest-bytes
Readers: (wav-error-rest-bytes)
chunk
Option Value Allocation: instance Type: nil
Initarg: :chunk
Readers: (wav-error-chunk)
wav-warning
General Wav warning
wav-unknown-chunk
Unknown chunk warning
chunk
Option Value Allocation: instance Type: nil
Initarg: :chunk
Readers: (wav-warning-chunk)
write-pcm-wav-header
(out-stream &key samplerate channels bps totalsamples)
Writes header of uncompressed wav into stream
with-output-to-wav
((stream filename &key supersede samplerate channels bps totalsamples) &body body)
Opens a STREAM and writes PCM-coded (uncompressed) WAV header to a file with filename FILENAME