WAVREAD(3SP)

NAME
WavRead, WavWrite - read and write SPHERE-headered waveform files

SYNOPSIS

#include <speech.h>

int WavRead (char *filename, short **samples_p, int *rate_p)

int WavWrite (char *wavfile, short *samples, int len, int sample_rate,
	      int compress_flag)

DESCRIPTION
WavRead reads the samples from filename, returning the number of samples read. Space is allocated and assigned to *samples_p. The samples are uncompressed, if necessary, and placed in host byte order. The sample rate (number of samples in one second) is assigned to *rate_p.

WavWrite writes len shorts from samples to the file wavfile. It prepends a SPHERE wave file header which specifies the given sample_rate. This should be the number of samples per second. If compress_flag is nonzero, the data will be written in compressed format. The file is not given read permission until after writing is complete.

DIAGNOSTICS
If an error occurs, -1 is returned and the external variable char *ErrorString is set.

BUGS
Only works with (compressed) 16 bit data.

AUTHORS
The SPHERE file format was developed by the National Institute of Standards in Technology.

The shortpack compression algorithm is from Mike Phillips; the code is by Peter Daly. Both from Spoken Language Systems Group at MIT Laboratory for Computer Science.