WAV Import/Export for GNU Octave
The functions wavread() and wavwrite() for GNU Octave allow for importing multi-channel PCM data as a matrix and exporting a matrix as PCM data again.
GNU Octave is a language for performing numerical computations and it is highly compatible to MATLAB. The analysis of digital signals forms a central application of that software and the RIFF/WAVE format (file suffix .wav) provides a simple container for storing such signals. Sadly, Octave does not offer feasible functions to deal with that format yet. The ones from the Octave-Forge extension turned out to be quite inefficient and not that versatile.
Features
My functions allow the user to import a WAV file as an Octave matrix and export a matrix to a WAV file again. They provide the following features:
- LPCM samples in 8, 16 or 32 bit resolution
- IEEE-float samples in 16 or 32 bit resolution
- arbitrary number of channels
Usage
In Octave, they can be used like every other function:
## read samples 10e5 to 10e5 + 50000 and the ## sampling rate and resolution of the signal [y, fs, bits] = wavread("input.wav", [1e5 1e5+5e4]); ## write matrix y to output.wav and use the ## sampling rate fs and a resolution of bits. wavwrite("output.wav", y, fs, bits); ## plot the first channel plot([0 : 5e4-1], y(:, 1));
A more detailed explanation is included per help wavread.
Getting Started
The code is part of Octave since version 3.0.0.