Easy Audio ยป Wav

This package is for reading Wav audio files (that is if you are lucky enough:). The working process is as simple as always:
  1. Open the audio stream as an ordinary input stream with element type (unsigned-byte 8).
  2. Create a bitreader object with open-wav.
  3. Read wav chunks with metadata calling read-wav-header.
  4. 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.
  5. Read audio samples with read-wav-data.
  6. 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.
Also you can write simple PCM WAV headers with 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)
Metaclassstandard-class
Default Initargsnil
Audio format subchunk
  • audio-format
    Audio format
    Allocationinstance
    Type(easy-audio.core:ub 16)
    Accessors(format-audio-format)
  • channels-num
    Number of channels in the stream
    Allocationinstance
    Type(easy-audio.core:ub 16)
    Accessors(format-channels-num)
  • samplerate
    Samplerate in Hertz
    Allocationinstance
    Type(easy-audio.core:ub 32)
    Accessors(format-samplerate)
  • byte-rate
    Allocationinstance
    Type(easy-audio.core:ub 32)
    Accessors(format-byte-rate)
  • block-align
    Allocationinstance
    Type(easy-audio.core:ub 16)
    Accessors(format-block-align)
  • bps
    Bits per sample
    Allocationinstance
    Type(easy-audio.core:ub 16)
    Accessors(format-bps)
  • valid-bps
    Valid bits per sample
    Allocationinstance
    Type(easy-audio.core:ub 16)
    Accessors(format-valid-bps)
  • channel-mask
    Channel mask of used channels
    Allocationinstance
    Type(easy-audio.core:ub 32)
    Accessors(format-channel-mask)
  • subformat
    Extended audio format
    Allocationinstance
    Type(easy-audio.core:sa-ub 8)
    Accessors(format-subformat)
data-subchunk
Superclasses(subchunk t)
Metaclassstandard-class
Default Initargsnil
Audio data subchunk
  • audio-position
    Allocationinstance
    Typeunsigned-byte
    Initarg:audio-position
    Accessors(data-audio-position)
fact-subchunk
Superclasses(subchunk t)
Metaclassstandard-class
Default Initargsnil
Subchunk with actual number of samples
  • samples-num
    Number of interchannel samples
    Allocationinstance
    Type(easy-audio.core:ub 32)
    Accessors(fact-samples-num)
info-subchunk
Superclasses(data-chunk t)
Metaclassstandard-class
Default Initargsnil
LIST INFO subchunk. Together they constitue key-value metadata for the audio stream
  • key
    Key of an info subchunk
    Allocationinstance
    Type(or symbol string)
    Initarg:key
    Accessors(info-key)
  • value
    Value of an info subchunk
    Allocationinstance
    Typestring
    Initarg:value
    Accessors(info-value)
wav-error
General Wav error
    wav-error-chunk
    Error while reading a chunk
    • reader
      Allocationinstance
      Typenil
      Initarg:reader
      Readers(wav-error-reader)
    • rest-bytes
      Allocationinstance
      Typenil
      Initarg:rest-bytes
      Readers(wav-error-rest-bytes)
    • chunk
      Allocationinstance
      Typenil
      Initarg:chunk
      Readers(wav-error-chunk)
    wav-warning
    General Wav warning
      wav-unknown-chunk
      Unknown chunk warning
      • chunk
        Allocationinstance
        Typenil
        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