4 Revision 1.4 2000/01/05 00:20:06 markster
7 Revision 1.1 2000/01/05 00:20:06 markster
8 Add broken lpc10 code... It's not too far from working I don't think...
10 * Revision 1.1 1996/08/19 22:47:31 jaf
19 #define LPC10_SAMPLES_PER_FRAME 180
20 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
25 The "#if defined"'s in this file are by no means intended to be
26 complete. They are what Nautilus uses, which has been successfully
27 compiled under DOS with the Microsoft C compiler, and under a few
28 versions of Unix with the GNU C compiler.
38 #if defined(__MSDOS__) || defined(MSDOS)
45 /* The initial values for every member of this structure is 0, except
46 where noted in comments. */
48 /* These two lines are copied from f2c.h. There should be a more
49 elegant way of doing this than having the same declarations in two
53 typedef INT32 integer;
54 typedef INT32 logical;
55 typedef INT16 shortint;
57 struct lpc10_encoder_state {
58 /* State used only by function hp100 */
64 /* State used by function analys */
65 real inbuf[540], pebuf[540];
66 real lpbuf[696], ivbuf[312];
68 integer osbuf[10]; /* no initial value necessary */
69 integer osptr; /* initial value 1 */
71 integer vwin[6] /* was [2][3] */; /* initial value vwin[4] = 307; vwin[5] = 462; */
72 integer awin[6] /* was [2][3] */; /* initial value awin[4] = 307; awin[5] = 462; */
73 integer voibuf[8] /* was [2][4] */;
75 real rcbuf[30] /* was [10][3] */;
79 /* State used by function onset */
81 real d__; /* initial value 1.f */
82 real fpc; /* no initial value necessary */
85 integer l2ptr1; /* initial value 1 */
86 integer l2ptr2; /* initial value 9 */
87 integer lasti; /* no initial value necessary */
88 logical hyst; /* initial value FALSE_ */
90 /* State used by function voicin */
91 real dither; /* initial value 20.f */
94 real voice[6] /* was [2][3] */; /* initial value is probably unnecessary */
95 integer lbve, lbue, fbve, fbue;
107 snr = (real) (fbve / fbue << 6);
110 /* State used by function dyptrk */
112 integer p[120] /* was [60][2] */;
116 /* State used by function chanwr */
122 struct lpc10_decoder_state {
124 /* State used by function decode */
125 integer iptold; /* initial value 60 */
126 logical first; /* initial value TRUE_ */
129 integer iavgp; /* initial value 60 */
131 integer drc[30] /* was [3][10] */;
135 /* State used by function synths */
137 integer buflen; /* initial value 180 */
139 /* State used by function pitsyn */
140 integer ivoico; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
141 integer ipito; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
142 real rmso; /* initial value 1.f */
143 real rco[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
144 integer jsamp; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
145 logical first_pitsyn; /* initial value TRUE_ */
147 /* State used by function bsynz */
159 /* State used by function random */
160 integer j; /* initial value 2 */
161 integer k; /* initial value 5 */
162 shortint y[5]; /* initial value { -21161,-8478,30892,-10216,16950 } */
164 /* State used by function deemp */
179 Call create_lpc10_encoder_state(), which returns a pointer to an
180 already initialized lpc10_encoder_state structure.
182 lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of
183 array speech[], and writes indices 0 through
184 (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads
185 and writes the lpc10_encoder_state structure contents. The
186 lpc10_encoder_state structure should *not* be initialized for every
187 frame of encoded speech. Once at the beginning of execution, done
188 automatically for you by create_lpc10_encoder_state(), is enough.
190 init_lpc10_encoder_state() reinitializes the lpc10_encoder_state
191 structure. This might be useful if you are finished processing one
192 sound sample, and want to reuse the same lpc10_encoder_state
193 structure to process another sound sample. There might be other
196 Note that the comments in the lpc10/lpcenc.c file imply that indices
197 1 through 180 of array speech[] are read. These comments were
198 written for the Fortran version of the code, before it was
199 automatically converted to C by the conversion program f2c. f2c
200 seems to use the convention that the pointers to arrays passed as
201 function arguments point to the first index used in the Fortran
202 code, whatever index that might be (usually 1), and then it modifies
203 the pointer inside of the function, like so:
209 So that the code can access the first value at index 1 and the last
210 at index 180. This makes the translated C code "closer" to the
211 original Fortran code.
213 The calling sequence for the decoder is similar to the encoder. The
214 only significant difference is that the array bits[] is read
215 (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the
216 array speech[] is written (indices 0 through
217 (LPC10_SAMPLES_PER_FRAME-1)).
221 struct lpc10_encoder_state * create_lpc10_encoder_state ();
222 void init_lpc10_encoder_state (struct lpc10_encoder_state *st);
223 int lpc10_encode (real *speech, INT32 *bits, struct lpc10_encoder_state *st);
225 struct lpc10_decoder_state * create_lpc10_decoder_state ();
226 void init_lpc10_decoder_state (struct lpc10_decoder_state *st);
227 int lpc10_decode (INT32 *bits, real *speech, struct lpc10_decoder_state *st);
229 #endif /* __LPC10_H__ */