- 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-datais 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| Superclasses | (subchunk t) |
| Metaclass | standard-class |
| Default Initargs | nil |
Audio format subchunk
audio-formatAudio formatAllocation instance Type (easy-audio.core:ub 16)Accessors (format-audio-format)channels-numNumber of channels in the streamAllocation instance Type (easy-audio.core:ub 16)Accessors (format-channels-num)samplerateSamplerate in HertzAllocation instance Type (easy-audio.core:ub 32)Accessors (format-samplerate)byte-rateAllocation instance Type (easy-audio.core:ub 32)Accessors (format-byte-rate)block-alignAllocation instance Type (easy-audio.core:ub 16)Accessors (format-block-align)bpsBits per sampleAllocation instance Type (easy-audio.core:ub 16)Accessors (format-bps)valid-bpsValid bits per sampleAllocation instance Type (easy-audio.core:ub 16)Accessors (format-valid-bps)channel-maskChannel mask of used channelsAllocation instance Type (easy-audio.core:ub 32)Accessors (format-channel-mask)subformatExtended audio formatAllocation instance Type (easy-audio.core:sa-ub 8)Accessors (format-subformat)
data-subchunk| Superclasses | (subchunk t) |
| Metaclass | standard-class |
| Default Initargs | nil |
Audio data subchunk
audio-positionAllocation instance Type unsigned-byteInitarg :audio-positionAccessors (data-audio-position)
fact-subchunk| Superclasses | (subchunk t) |
| Metaclass | standard-class |
| Default Initargs | nil |
Subchunk with actual number of samples
samples-numNumber of interchannel samplesAllocation instance Type (easy-audio.core:ub 32)Accessors (fact-samples-num)
info-subchunk| Superclasses | (data-chunk t) |
| Metaclass | standard-class |
| Default Initargs | nil |
LIST INFO subchunk. Together they constitue key-value metadata
for the audio stream
keyKey of an info subchunkAllocation instance Type (or symbol string)Initarg :keyAccessors (info-key)valueValue of an info subchunkAllocation instance Type stringInitarg :valueAccessors (info-value)
wav-errorGeneral Wav error
wav-error-chunkError while reading a chunk
readerAllocation instance Type nilInitarg :readerReaders (wav-error-reader)rest-bytesAllocation instance Type nilInitarg :rest-bytesReaders (wav-error-rest-bytes)chunkAllocation instance Type nilInitarg :chunkReaders (wav-error-chunk)
wav-warningGeneral Wav warning
wav-unknown-chunkUnknown chunk warning
chunkAllocation instance Type nilInitarg :chunkReaders (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