riff-wave API Documentation
riff-wave.read
Functins to read WAVE files.
read-sample (Function)
Syntax:
— Function: read-sample stream sample-size
→ sample
Arguments and Values:
stream—a binary input stream.
sample-size—the sample size of the WAVE stream.
sample—either an (unsigned-byte 8)
or an (unsigned-byte 16)
depending on sample-size.
Description:
read-sample
reads and returns a sample of sample-size from stream.
read-wave-header (Function)
Syntax:
— Function: read-wave-header stream
→ sample-rate, sample-size, n-channels, length
Arguments and Values:
stream—a binary input stream.
sample-rate—the sample rate in Hertz specified by the WAVE header. Represented as a positive integer.
sample-size—the sample size specified by the WAVE header. May be be 1 or 2 indicating 8-bit or 16-bit samples respectively.
n-channels—the number of channels specified by the WAVE header. Represented as a positive integer.
length—the contained number of samples per channel specified by the WAVE header. Represented as an unsigned integer.
Description:
read-wave-header
reads a PCM WAVE header at stream and returns the sample-rate, sample-size, n-channels, and length of the WAVE stream specified by the header. Stream is advanced to the beginning of the first sample and read-sample
may be used to read length times n-samples of sample-size from stream.
E.g. if a WAVE stream contains two channels and has a length of four, then there should be eight samples in the stream, with each even sample belonging to the first channel and each odd sample belonging to the second channel of the stream.
Exceptional Situations:
Signals an error of type error
if stream does not contain a RIFF/WAVE header using the PCM audio format.
riff-wave.write
Functions to write WAVE files.
write-sample (Function)
Syntax:
— Function: write-sample sample sample-size stream
Arguments and Values:
sample—the sample value represented as a (real -1 1)
.
sample-size—one to write an 8-bit sample; Two to write a 16-bit sample.
stream—a binary output stream.
write-sample
writes sample encoded in sample-size bytes to stream.
write-wave-header (Function)
Syntax:
— Function: write-wave-header sample-rate sample-size n-channels length stream
Arguments and Values:
sample-rate—an (unsigned-byte 32)
denoting the sample rate in Hertz.
sample-size—one for 8-bit samples; Two for 16-bit samples.
n-channels—a positive integer denoting the number of channels.
length—an unsigned integer denoting the number of samples per channel following the WAVE header.
stream—a binary output stream.
Description:
write-wave-header
writes the PCM WAVE header specified by sample-rate, sample-size, n-channels and length to stream. write-sample
should be used to write n-channels times length samples of sample-size to stream.