1 /*------------ Telecommunications & Signal Processing Lab --------------
2                          McGill University
3 
4 Routine:
5   AFheader.h
6 
7 Description:
8   Function prototypes for the TSP library AF file internal routines
9 
10 Author / revision:
11   P. Kabal  Copyright (C) 2004
12   $Revision: 1.35 $  $Date: 2004/03/31 13:29:06 $
13 
14 ----------------------------------------------------------------------*/
15 
16 #ifndef AFheader_h_
17 #define AFheader_h_
18 
19 #include <stdio.h>	/* typedef for FILE */
20 #include <setjmp.h>	/* typedef for jmp_buf */
21 
22 struct AF_opt;				/* Audio file routine options */
23 struct AF_NHpar;			/* Headerless audio file parameters */
24 struct AF_info;				/* Information records (allocated
25 					   string) */
26 struct AF_infoX;       			/* Information fixed (fixed string) */
27 struct AF_read;				/* File format and data parameters */
28 struct AF_write;			/* File format and data parameters */
29 
30 #ifndef	AFILE_t_
31 #  define AFILE_t_
32 typedef struct AF_filepar AFILE;	/* Audio file parameters */
33 #endif
34 
35 /* Header read/write definitions */
36 #define RHEAD_S(fp,string) \
37 	AFreadHead (fp, (void *)(string), 1, (int) (sizeof (string)), \
38 		    DS_NATIVE)
39 #define RHEAD_SN(fp,string,N) \
40 	AFreadHead (fp, (void *) (string), 1, (int) (N), DS_NATIVE)
41 #define RHEAD_V(fp,value,swap) \
42 	AFreadHead (fp, (void *) &(value), (int) (sizeof (value)), 1, \
43 		    (int) (swap))
44 #define RSKIP(fp,nbytes) \
45 	AFreadHead (fp, NULL, 1, (int) (nbytes), DS_NATIVE)
46 #define WHEAD_S(fp,string) \
47 	AFwriteHead (fp, (const void *) (string), 1, (int) (sizeof (string)), \
48 		     DS_NATIVE)
49 #define WHEAD_SN(fp,string,N) \
50 	AFwriteHead (fp, (const void *) (string), 1, (int) (N), DS_NATIVE)
51 #define WHEAD_P(fp,string) \
52 	AFwriteHead (fp, (const void *) (string), 1, (int) (strlen (string)), \
53 		     DS_NATIVE)
54 #define WHEAD_V(fp,value,swap) \
55 	AFwriteHead (fp, (const void *) &(value), (int) (sizeof (value)), 1, \
56 		     (int) (swap))
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 void
63 AFaddAFspRec (const char Ident[], const char line[], int Size,
64 	      struct AF_infoX *InfoX);
65 int
66 AFdecSpeaker (const char String[], unsigned char *SpkrConfig, int MaxN);
67 int
68 AFcheckSpeakers (const unsigned char *SpkrConfig);
69 int
70 AFfindType (FILE *fp);
71 const char *
72 AFgetInfoRec (const char name[], const struct AF_info *InfoS);
73 struct AF_opt *
74 AFoptions (void);
75 void
76 AFprAFpar (AFILE *AFp, const char Fname[], FILE *fpinfo);
77 int
78 AFpreSetWPar (int Ftype, int Dformat, long int Nchan, double Sfreq,
79 	      struct AF_write *AFw);
80 AFILE *
81 AFrdAIhead (FILE *fp);
82 AFILE *
83 AFrdAUhead (FILE *fp);
84 AFILE *
85 AFrdBLhead (FILE *fp);
86 AFILE *
87 AFrdEShead (FILE *fp);
88 AFILE *
89 AFrdINhead (FILE *fp);
90 AFILE *
91 AFrdNShead (FILE *fp);
92 AFILE *
93 AFrdSFhead (FILE *fp);
94 AFILE *
95 AFrdSPhead (FILE *fp);
96 AFILE *
97 AFrdSWhead (FILE *fp);
98 AFILE *
99 AFrdTAhead (FILE *fp);
100 int
101 AFrdTextAFsp (FILE *fp, int Size, const char Ident[], struct AF_infoX *InfoX,
102 	      int Align);
103 AFILE *
104 AFrdWVhead (FILE *fp);
105 int
106 AFreadHead (FILE *fp, void *Buf, int size, int Nelem, int Swapb);
107 struct AF_opt *
108 AFresetOptions (unsigned int Cat);
109 AFILE *
110 AFsetNHread (FILE *fp, const char Fname[]);
111 AFILE *
112 AFsetNHwrite (FILE *fp, struct AF_write *AFw);
113 AFILE *
114 AFsetRead (FILE *fp, int Ftype, const struct AF_read *AFr, int Fix);
115 AFILE *
116 AFsetWrite (FILE *fp, int Ftype, const struct AF_write *AFw);
117 int
118 AFspeakerNames (int Nchan, const unsigned char *SpkrConfig, int Nextra,
119 		char *SpkrNames);
120 int
121 AFupdAIhead (AFILE *AFp);
122 int
123 AFupdAUhead (AFILE *AFp);
124 int
125 AFupdHead (AFILE *AFp);
126 int
127 AFupdWVhead (AFILE *AFp);
128 AFILE *
129 AFwrAIhead (FILE *fp, struct AF_write *AFw);
130 AFILE *
131 AFwrAUhead (FILE *fp, struct AF_write *AFw);
132 AFILE *
133 AFwrWVhead (FILE *fp, struct AF_write *AFw);
134 int
135 AFwriteHead (FILE *fp, const void *Buf, int Size, int Nv, int Swapb);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* AFheader_h_ */
142