lpc10.h 7.2 KB

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