NAME
opnwav - Open a waveform file for I/O
SYNOPSIS
#include "wiodef.h"
WVFILE *opnwav (char *filestring, char mode, WDB *data_blk)
DESCRIPTION
opnwav ()
opens a waveform file specified by filestring. Upon
success, a WVFILE structure is associated with the file and its pointer
is returned.
filestring
is a standard filename with optional path and extension, and may contain a
segment name and/or channel number as a suffix. The syntax for filename is:
[path/]filename[.ext][$segment][#channel]
The segment name, preceeded by a $ and the channel number preceeded by a #
may appear in any order, but must follow an extension if present. By default,
the extension is .wav.
mode
is a character string having one of the following values:
- w
- write: truncate or create for reading and writing
- r
- read: open existing file for reading only
- a
- append: open or create for reading and writing and position at end of file
- o
- open existing file for reading and writing
- p
- backwards compatable version of r
- n
- backwards compatable version of w
data_blk
is a structure that holds information about file. If an
existing file is opened, data_blk is filled with attributes from the
opened file. If a new file is requested, it is created with the attributes
from data_blk. See libcwav(3) for definition of
WDB structure.
RETURN VALUES
On success, opnwav() returns the pointer to a WVFILE structure.
On failure, a null pointer is returned and data_blk->error is set.
ERRORS
- NO_FILE
- file could not be found or created
- INVALID_FORMAT
- Invalid data_blk->format
- NO_SEGMENT
- segment not found in file
- INVALID_CHANNEL
- channel number > number of channels
- INSUF_MEMORY
- memory allocation failure
- INSUF_BUFFER
- predifined buffer too small for record.
- INVALID_FILE
- file neither RIFF nor ASEL format.
EXAMPLE
WVFILE *wfp;
WDB data_blk;
char *filename = "sound#3$AA";
NPdefwdb(data_blk);
if ((wfp = opnwav(filename, 'r', &data_blk)) == (WVFILE *) NULL) {
printf("Open error on >%s<\n",filename);
return (1);
}
SEE ALSO
clswav(),
defwdb(),
Pdefwdb(),
NPdefwdb(),
Libcwav library
AUTHOR
H.T.Bunnell, Shirley Peters