CreateSoundFile(3x)MISC. REFERENCE MANUAL PAGEC
SreateSoundFile(3x)
NAME
CreateSoundFile, OpenSoundFile, ReadSoundFile, WriteSound-
File, SeekSoundFile, CloseSoundFile, - To handle sound
files.
SYNTAX
#include <io/sound.h>
#include <soundlib.h>
SFILE *CreateSoundFile( fname, sbparam )
char fname[];
struct sbparam *sbparam;
SFILE *OpenSoundFile( fname )
char fname[];
int ReadSoundFile( ptr, size, nitems, sfile )
char *ptr;
int size, nitems;
SFILE *sfile;
int WriteSoundFile( ptr, size, nitems, sfile )
char *ptr;
int size, nitems;
SFILE *sfile;
int SeekSoundFile( sfile, second, offset )
SFILE *sfile;
int second, offset;
int CloseSoundFile( sfile )
SFILE *sfile;
DESCRIPTION
CreateSoundFile creates new sound files. The function opens
a file, sets the proper header information, and prepares the
file so that sound data can be written in. f_name specifies
the name of the file to be created. sbparam represents the
sound format. CreateSoundFile returns the pointer to a
structure containing information about the sound file if the
file is successfully created. It returns a null pointer if
the file cannot be created. If the file cannot be opened,
the variable errno is set to the same error number as used
by the system call open(2).
OpenSoundFile opens already existing sound files. This
function opens the sound file, reads its header information,
and prepares the file for reading and writing. f_name
specifies the name of the file to be opened. OpenSoundFile
returns a pointer to a structure storing information con-
cerning the sound file if the file is successfully opened.
If the file cannot be opened, the function returns a null
1
CreateSoundFile(3x)MISC. REFERENCE MANUAL PAGEC
SreateSoundFile(3x)
pointer and sets the variable errno to the same error number
as used by the system call open (2).
ReadSoundFile reads sound data out of sound files. This
function reads nitems of data in blocks of length size from
the sound file sfile into the buffer ptr. The number of
blocks successfully read is returned.
This function returns 0 when the data cannot be read or when
an attempt is made to read past the end of the sound data.
If the file cannot be read, errno is set to the same error
number as used by the system call read(2)
WriteSoundFile writes sound data to sound files. This func-
tion writes nitems of data in blocks of length size stored
in the buffer ptr into the file. sfile.
The function returns the number of blocks succesfully writ-
ten. If the file cannot be written, it returns 0 and sets
the variable errno to the same error number as used by the
system call write (2).
SeekSoundFile moves sound data to the specified location.
This function moves sound data in the sound file specified
by sfile to the desired location. The location is obtained
by adding the number of seconds specified in second and the
number of bytes specified in offset.
The data movement ends at the start of the closest data
block. Accordingly, the actual position may differ slightly
from that specified with formats such as ADPCM which use
large data block sizes.
The location of the sound data is returned as a number of
bytes, if the data is moved successfully. If the data can-
not be moved, -1 is returned.
CloseSoundFile closes sound files opened using CreateSound-
file or OpenSoundFile. This function also updates header
information for the file in accordance with any changes made
in the sound data. This function must be called whenever
closing sound files.
FILES
/usr/lib/libsound.a, /usr/include/io/sound.h,
/usr/include/soundlib.h
SEE ALSO
sb(7), sbrec(1), sbplay(1), sbchk(1), sbconv(1)
2