Skip to content

md-audio

[module] md-audio

Types

[record] audio

[constructor] (make-audio #!key (CHANNELS 1) (RATE 44100) (DATA '()))
[predicate] audio?
implementation: defstruct

field getter setter default type
channels audio-channels audio-channels-set! 1 fixnum
rate audio-rate audio-rate-set! 44100 fixnum
data audio-data audio-data-set! '() (list-of vector)

The main data structure for wrapping audio data. Internally, all audio data is handled as float.

PCM WAV file handling

[procedure] (raw->audio DATA CHANNELS RATE SAMPLE-LENGTH SIGNEDNESS ENDIANNESS)

Convert raw (headerless) PCM WAV data into an audio structure. SAMPLE-LENGTH is the number of bytes used by one sample in one channel.

[procedure] (import-raw FILENAME #!optional (CHANNELS 1) (RATE 44100) (SAMPLE-LENGTH 1) (SIGNEDNESS 'unsigned) (ENDIANNESS 'little))

Construct an audio structure from a raw (headerless) PCM audio file.

[procedure] (import-pcm-wav FILENAME)

Construct an audio structure from a PCM WAVE (RIFF) file.

[procedure] (audio->raw AUDIO BITS-PER-SAMPLE SIGNEDNESS ENDIANNESS)

[procedure] (audio->pcm-wav AUDIO BITS-PER-SAMPLE)

Extract raw PCM audio from the audio structure AUDIO.

[procedure] (export-pcm-wav FILENAME AUDIO BITS-PER-SAMPLE)

Export the audio structure AUDIO to the PCM WAV file FILENAME, using a bit depth of BITS-PER-SAMPLE.

[procedure] (normalize AUDIO)

Normalize the range of the audio structure AUDIO to (-1.0, 1.0)

[procedure] (resample AUDIO TARGET-RATE #!optional (WINDOW-SIZE 44))

Resample AUDIO to the sample rate TARGET-RATE using Blackman windowed interpolation. Optionally, WINDOW-SIZE may specify the number of samples used by the Blackman window function for interpolation.