Asterisk - The Open Source Telephony Project  18.5.0
lpc10.h
Go to the documentation of this file.
1 /*
2 
3 $Log$
4 Revision 1.18 2004/08/31 13:32:11 markster
5 Merge NetBSD and Courtesty tone with modifications (bug #2329)
6 
7 Revision 1.17 2003/10/26 18:50:49 markster
8 Make it build and run on MacOS X
9 
10 Revision 1.3 2003/10/26 18:50:49 markster
11 Make it build and run on MacOS X
12 
13 Revision 1.2 2003/04/23 19:13:35 markster
14 More OpenBSD patches
15 
16 Revision 1.1.1.2 2003/03/16 22:37:30 matteo
17 dom mar 16 23:37:23 CET 2003
18 
19 Revision 1.2 2003/03/16 16:09:48 markster
20 Mere James's cleanups for fewer build warnings
21 
22 Revision 1.1 2000/01/05 00:20:06 markster
23 Add broken lpc10 code... It's not too far from working I don't think...
24 
25  * Revision 1.1 1996/08/19 22:47:31 jaf
26  * Initial revision
27  *
28 
29 */
30 
31 #ifndef __LPC10_H__
32 #define __LPC10_H__
33 
34 #define P_R_O_T_O_T_Y_P_E_S
35 
36 #define LPC10_SAMPLES_PER_FRAME 180
37 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
38 
39 
40 /*
41 
42  The "#if defined"'s in this file are by no means intended to be
43  complete. They are what Nautilus uses, which has been successfully
44  compiled under DOS with the Microsoft C compiler, and under a few
45  versions of Unix with the GNU C compiler.
46 
47  */
48 
49 #if defined(unix) || defined(__unix__) || defined(__NetBSD__)
50 typedef short INT16;
51 typedef int INT32;
52 #endif
53 
54 
55 #if defined(__MSDOS__) || defined(MSDOS)
56 typedef int INT16;
57 typedef long INT32;
58 #endif
59 
60 #if defined(__APPLE__)
61 typedef short INT16;
62 typedef int INT32;
63 #endif
64 
65 #if defined(WIN32) && defined(_MSC_VER)
66 typedef __int16 INT16;
67 typedef __int32 INT32;
68 #pragma warning(disable: 4005)
69 #endif
70 
71 
72 /* The initial values for every member of this structure is 0, except
73  where noted in comments. */
74 
75 /* These two lines are copied from f2c.h. There should be a more
76  elegant way of doing this than having the same declarations in two
77  files. */
78 
79 typedef float real;
80 typedef INT32 integer;
81 typedef INT32 logical;
82 typedef INT16 shortint;
83 
85  /* State used only by function hp100 */
90 
91  /* State used by function analys */
92  real inbuf[540], pebuf[540];
93  real lpbuf[696], ivbuf[312];
95  integer osbuf[10]; /* no initial value necessary */
96  integer osptr; /* initial value 1 */
98  integer vwin[6] /* was [2][3] */; /* initial value vwin[4] = 307; vwin[5] = 462; */
99  integer awin[6] /* was [2][3] */; /* initial value awin[4] = 307; awin[5] = 462; */
100  integer voibuf[8] /* was [2][4] */;
102  real rcbuf[30] /* was [10][3] */;
104 
105 
106  /* State used by function onset */
108  real d__; /* initial value 1.f */
109  real fpc; /* no initial value necessary */
110  real l2buf[16];
112  integer l2ptr1; /* initial value 1 */
113  integer l2ptr2; /* initial value 9 */
114  integer lasti; /* no initial value necessary */
115  logical hyst; /* initial value FALSE_ */
116 
117  /* State used by function voicin */
118  real dither; /* initial value 20.f */
121  real voice[6] /* was [2][3] */; /* initial value is probably unnecessary */
125  /* Initial values:
126  lbve = 3000;
127  fbve = 3000;
128  fbue = 187;
129  ofbue = 187;
130  sfbue = 187;
131  lbue = 93;
132  olbue = 93;
133  slbue = 93;
134  snr = (real) (fbve / fbue << 6);
135  */
136 
137  /* State used by function dyptrk */
138  real s[60];
139  integer p[120] /* was [60][2] */;
142 
143  /* State used by function chanwr */
145 
146 };
147 
148 
150 
151  /* State used by function decode */
152  integer iptold; /* initial value 60 */
153  logical first; /* initial value TRUE_ */
156  integer iavgp; /* initial value 60 */
158  integer drc[30] /* was [3][10] */;
159  integer dpit[3];
160  integer drms[3];
161 
162  /* State used by function synths */
163  real buf[360];
164  integer buflen; /* initial value 180 */
165 
166  /* State used by function pitsyn */
167  integer ivoico; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
168  integer ipito; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
169  real rmso; /* initial value 1.f */
170  real rco[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
171  integer jsamp; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
172  logical first_pitsyn; /* initial value TRUE_ */
173 
174  /* State used by function bsynz */
176  real exc[166];
177  real exc2[166];
185 
186  /* State used by function random */
187  integer j; /* initial value 2 */
188  integer k; /* initial value 5 */
189  shortint y[5]; /* initial value { -21161,-8478,30892,-10216,16950 } */
190 
191  /* State used by function deemp */
197 
198 };
199 
200 
201 
202 /*
203 
204  Calling sequence:
205 
206  Call create_lpc10_encoder_state(), which returns a pointer to an
207  already initialized lpc10_encoder_state structure.
208 
209  lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of
210  array speech[], and writes indices 0 through
211  (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads
212  and writes the lpc10_encoder_state structure contents. The
213  lpc10_encoder_state structure should *not* be initialized for every
214  frame of encoded speech. Once at the beginning of execution, done
215  automatically for you by create_lpc10_encoder_state(), is enough.
216 
217  init_lpc10_encoder_state() reinitializes the lpc10_encoder_state
218  structure. This might be useful if you are finished processing one
219  sound sample, and want to reuse the same lpc10_encoder_state
220  structure to process another sound sample. There might be other
221  uses as well.
222 
223  Note that the comments in the lpc10/lpcenc.c file imply that indices
224  1 through 180 of array speech[] are read. These comments were
225  written for the Fortran version of the code, before it was
226  automatically converted to C by the conversion program f2c. f2c
227  seems to use the convention that the pointers to arrays passed as
228  function arguments point to the first index used in the Fortran
229  code, whatever index that might be (usually 1), and then it modifies
230  the pointer inside of the function, like so:
231 
232  if (speech) {
233  --speech;
234  }
235 
236  So that the code can access the first value at index 1 and the last
237  at index 180. This makes the translated C code "closer" to the
238  original Fortran code.
239 
240  The calling sequence for the decoder is similar to the encoder. The
241  only significant difference is that the array bits[] is read
242  (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the
243  array speech[] is written (indices 0 through
244  (LPC10_SAMPLES_PER_FRAME-1)).
245 
246  */
247 
250 int lpc10_encode (real *speech, INT32 *bits, struct lpc10_encoder_state *st);
251 
254 int lpc10_decode (INT32 *bits, real *speech, struct lpc10_decoder_state *st);
255 
256 #endif /* __LPC10_H__ */
integer fbve
Definition: lpc10.h:122
integer fbue
Definition: lpc10.h:122
integer olbue
Definition: lpc10.h:124
real rcbuf[30]
Definition: lpc10.h:102
void init_lpc10_encoder_state(struct lpc10_encoder_state *st)
Definition: lpcini.c:272
integer buflen
Definition: lpc10.h:164
integer erate
Definition: lpc10.h:157
integer iavgp
Definition: lpc10.h:156
integer awin[6]
Definition: lpc10.h:99
int lpc10_encode(real *speech, INT32 *bits, struct lpc10_encoder_state *st)
Definition: lpcenc.c:108
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
logical first
Definition: lpc10.h:153
integer iptold
Definition: lpc10.h:152
integer lbve
Definition: lpc10.h:122
integer vwin[6]
Definition: lpc10.h:98
real lpbuf[696]
Definition: lpc10.h:93
integer l2ptr1
Definition: lpc10.h:112
integer osbuf[10]
Definition: lpc10.h:95
integer iovoic
Definition: lpc10.h:155
integer slbue
Definition: lpc10.h:124
struct lpc10_decoder_state * create_lpc10_decoder_state(void)
Definition: lpcini.c:369
integer sfbue
Definition: lpc10.h:123
integer p[120]
Definition: lpc10.h:139
real rmsbuf[3]
Definition: lpc10.h:101
integer obound[3]
Definition: lpc10.h:97
real inbuf[540]
Definition: lpc10.h:92
logical hyst
Definition: lpc10.h:115
int lpc10_decode(INT32 *bits, real *speech, struct lpc10_decoder_state *st)
Definition: lpcdec.c:113
integer voibuf[8]
Definition: lpc10.h:100
real pebuf[540]
Definition: lpc10.h:92
float real
Definition: lpc10.h:79
integer lasti
Definition: lpc10.h:114
integer lbue
Definition: lpc10.h:122
integer ivp2h
Definition: lpc10.h:154
real voice[6]
Definition: lpc10.h:121
real ivbuf[312]
Definition: lpc10.h:93
struct lpc10_encoder_state * create_lpc10_encoder_state(void)
Definition: lpcini.c:258
integer ipito
Definition: lpc10.h:168
integer isync
Definition: lpc10.h:144
integer osptr
Definition: lpc10.h:96
integer ofbue
Definition: lpc10.h:123
real l2buf[16]
Definition: lpc10.h:110
integer l2ptr2
Definition: lpc10.h:113
real s[60]
Definition: lpc10.h:138
logical first_pitsyn
Definition: lpc10.h:172
integer jsamp
Definition: lpc10.h:171
INT32 logical
Definition: lpc10.h:81
INT16 shortint
Definition: lpc10.h:82
integer ivoico
Definition: lpc10.h:167
void init_lpc10_decoder_state(struct lpc10_decoder_state *st)
Definition: lpcini.c:383
integer ipoint
Definition: lpc10.h:140
INT32 integer
Definition: lpc10.h:80