WaveIO is a simple C library which allows for reading/writing WAV files. The file must be PCM coded, 8 or 16 bits/sample and with 1 or 2 channels.
I wrote this library for my students, in order to allow them to do experiments with audio signals. I needed a simple interface and I did not want to rely on any external libraries => I decided to write this software by myself.
Although I tested and debugged this library, I would keep it, by now, in a "beta" state. Please, let me know if you discover/correct any bugs.
WaveIO gives you
cc -c waveio.c)cc -o myprogram myprogram.o waveio.o)#include <errno.h> #include "waveio.h" // In case of error, print a suitable message and exit. void handle_error(char *msg) { waveio_perror(msg); exit(1); } int main(int argc, char **argv) { WAV_FILE *Output; wav_samples *buf; int16 data[N]; // Read the samples of pippo.wav buf = slurp_wav_file("/tmp/pippo.wav"); if (buf==NULL) handle_error("Could not read pippo.wav"); // Process the first channel of pippo.wav to obtain some other // audio data (which goes in data[]) process_audio(data, buf->chan0); // Write the result to pluto.wav Output = open_output_wav("/tmp/pluto.wav", // Output file 1, // mono // use the same bit/sample and sampling frequency // of the input file buf->bit_per_samples, buf->freq); if (Output==NULL) handle_error("Could not open pluto.wav"); if (write_wav_samples(Output, data, buf->nsamples) < buf->nsamples) handle_error("Error while writing to pluto.wav"); close_wav_file(Output); return 0; }
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001