1 /*
2  * Copyright 1993 Network Computing Devices, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name Network Computing Devices, Inc. not be
9  * used in advertising or publicity pertaining to distribution of this
10  * software without specific, written prior permission.
11  *
12  * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
13  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14  * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
16  * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17  * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18  * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19  * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * $NCDId: @(#)wave.h,v 1.10 1995/05/23 23:40:21 greg Exp $
23  */
24 
25 /*
26  * WAVE support library
27  */
28 
29 #ifndef _WAVE_H_
30 #define _WAVE_H_
31 
32 #include <audio/audio.h>	/* for AuInt32 and AuUint32 */
33 
34 #ifndef _WaveConst
35 #define _WaveConst const
36 #endif						/* _WaveConst */
37 
38 #ifndef _FUNCPROTOBEGIN
39 #ifdef __cplusplus			/* for C++ V2.0 */
40 #define _FUNCPROTOBEGIN extern "C" {	/* do not leave open across includes */
41 #define _FUNCPROTOEND }
42 #else
43 #define _FUNCPROTOBEGIN
44 #define _FUNCPROTOEND
45 #endif
46 #endif /* _FUNCPROTOBEGIN */
47 
48 #define RIFF_RiffID			"RIFF"
49 #define RIFF_WaveID			"WAVE"
50 #define RIFF_ListID			"LIST"
51 #define RIFF_ListInfoID			"INFO"
52 
53 #define RIFF_InfoIcmtID			"ICMT"
54 
55 #define RIFF_WaveFmtID			"fmt "
56 #define RIFF_WaveFmtSize		16
57 #define RIFF_WaveDataID			"data"
58 
59 #define	RIFF_WAVE_FORMAT_PCM		0x0001	/* Microsoft PCM */
60 #define	RIFF_IBM_FORMAT_MULAW		0x0101	/* IBM mu-law format */
61 #define	RIFF_IBM_FORMAT_ALAW		0x0102	/* IBM a-law format */
62 #define	RIFF_IBM_FORMAT_ADPCM		0x0103	/* IBM AVC Adaptive
63 						 * Differential Pulse Code
64 						 * Modulation format */
65 typedef AuUint32 RIFF_FOURCC;
66 
67 typedef struct
68 {
69     RIFF_FOURCC     ckID;			/* chunk ID */
70     AuInt32            ckSize;			/* chunk size, in bytes */
71 }               RiffChunk;
72 
73 typedef struct
74 {
75     FILE           *fp;
76     char           *comment;
77     short           channels,
78                     bitsPerSample;
79     AuInt32            sampleRate;
80     AuUint32   dataOffset,
81                     numSamples;
82 
83     /* private data */
84     AuUint32 fileSize, dataSize, sizeOffset;
85     unsigned int writing;
86     short format;
87 }               WaveInfo;
88 
89 /*****************************************************************************
90  *			       PUBLIC INTERFACES			     *
91  *****************************************************************************/
92 
93 _FUNCPROTOBEGIN
94 
95 extern WaveInfo *
96 WaveOpenFileForReading(
97 		       const char *		/* file name */
98 );
99 
100 extern WaveInfo *
101 WaveOpenFileForWriting(
102 		       const char *,		/* file name */
103 		       WaveInfo *		/* info */
104 );
105 
106 extern int
107 WaveCloseFile(
108 	      WaveInfo *			/* info */
109 );
110 
111 extern int
112 WaveReadFile(
113 	     char *,				/* buffer */
114 	     int,				/* num bytes */
115 	     WaveInfo *				/* info */
116 );
117 
118 extern int
119 WaveWriteFile(
120 	      char *,				/* buffer */
121 	      int,				/* num bytes */
122 	      WaveInfo *			/* info */
123 );
124 
125 extern int
126 WaveSeekFile(
127 	      int,                              /* number of audio bytes */
128 	      WaveInfo *			/* info */
129 );
130 
131 extern int
132 WaveTellFile(
133 	      WaveInfo *			/* info */
134 );
135 
136 extern int
137 WaveFlushFile(
138 	      WaveInfo *			/* info */
139 );
140 
141 extern int
142 WaveRewindFile(
143 	       WaveInfo *			/* info */
144 );
145 
146 _FUNCPROTOEND
147 
148 #endif						/* _WAVE_H_ */
149