lpcenc.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. $Log$
  3. Revision 1.15 2004/06/26 03:50:14 markster
  4. Merge source cleanups (bug #1911)
  5. Revision 1.14 2003/02/12 13:59:15 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  8. mer feb 12 14:56:57 CET 2003
  9. Revision 1.2 2000/01/05 08:20:39 markster
  10. Some OSS fixes and a few lpc changes to make it actually work
  11. * Revision 1.2 1996/08/20 20:31:21 jaf
  12. * Removed all static local variables that were SAVE'd in the Fortran
  13. * code, and put them in struct lpc10_encoder_state that is passed as an
  14. * argument.
  15. *
  16. * Removed init function, since all initialization is now done in
  17. * init_lpc10_encoder_state().
  18. *
  19. * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  20. * all lpc10 functions have more consistent naming with each other.
  21. *
  22. * Revision 1.1 1996/08/19 22:31:44 jaf
  23. * Initial revision
  24. *
  25. */
  26. /* -- translated by f2c (version 19951025).
  27. You must link the resulting object file with the libraries:
  28. -lf2c -lm (in that order)
  29. */
  30. #include "f2c.h"
  31. #ifdef P_R_O_T_O_T_Y_P_E_S
  32. extern int lpcenc_(real *speech, integer *bits);
  33. extern int initlpcenc_(void);
  34. /*:ref: prepro_ 14 2 6 4 */
  35. /*:ref: analys_ 14 5 6 4 4 6 6 */
  36. /*:ref: encode_ 14 7 4 4 6 6 4 4 4 */
  37. /*:ref: chanwr_ 14 5 4 4 4 4 4 */
  38. /*:ref: initprepro_ 14 0 */
  39. /*:ref: initanalys_ 14 0 */
  40. #endif
  41. /* Table of constant values */
  42. static integer c__180 = 180;
  43. static integer c__10 = 10;
  44. /* ***************************************************************** */
  45. /* $Log$
  46. * Revision 1.15 2004/06/26 03:50:14 markster
  47. * Merge source cleanups (bug #1911)
  48. *
  49. * Revision 1.14 2003/02/12 13:59:15 matteo
  50. * mer feb 12 14:56:57 CET 2003
  51. *
  52. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  53. * mer feb 12 14:56:57 CET 2003
  54. *
  55. * Revision 1.2 2000/01/05 08:20:39 markster
  56. * Some OSS fixes and a few lpc changes to make it actually work
  57. *
  58. * Revision 1.2 1996/08/20 20:31:21 jaf
  59. * Removed all static local variables that were SAVE'd in the Fortran
  60. * code, and put them in struct lpc10_encoder_state that is passed as an
  61. * argument.
  62. *
  63. * Removed init function, since all initialization is now done in
  64. * init_lpc10_encoder_state().
  65. *
  66. * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  67. * all lpc10 functions have more consistent naming with each other.
  68. *
  69. * Revision 1.1 1996/08/19 22:31:44 jaf
  70. * Initial revision
  71. * */
  72. /* Revision 1.2 1996/03/28 00:01:22 jaf */
  73. /* Commented out some trace statements. */
  74. /* Revision 1.1 1996/03/28 00:00:27 jaf */
  75. /* Initial revision */
  76. /* ***************************************************************** */
  77. /* Encode one frame of 180 speech samples to 54 bits. */
  78. /* Input: */
  79. /* SPEECH - Speech encoded as real values in the range [-1,+1]. */
  80. /* Indices 1 through 180 read, and modified (by PREPRO). */
  81. /* Output: */
  82. /* BITS - 54 encoded bits, stored 1 per array element. */
  83. /* Indices 1 through 54 written. */
  84. /* This subroutine maintains local state from one call to the next. If */
  85. /* you want to switch to using a new audio stream for this filter, or */
  86. /* reinitialize its state for any other reason, call the ENTRY */
  87. /* INITLPCENC. */
  88. /* Subroutine */ int lpc10_encode(real *speech, integer *bits,
  89. struct lpc10_encoder_state *st)
  90. {
  91. integer irms, voice[2], pitch, ipitv;
  92. real rc[10];
  93. extern /* Subroutine */ int encode_(integer *, integer *, real *, real *,
  94. integer *, integer *, integer *), chanwr_(integer *, integer *,
  95. integer *, integer *, integer *, struct lpc10_encoder_state *),
  96. analys_(real *, integer *,
  97. integer *, real *, real *, struct lpc10_encoder_state *),
  98. prepro_(real *, integer *, struct lpc10_encoder_state *);
  99. integer irc[10];
  100. real rms;
  101. /* Arguments */
  102. /* $Log$
  103. * Revision 1.15 2004/06/26 03:50:14 markster
  104. * Merge source cleanups (bug #1911)
  105. *
  106. * Revision 1.14 2003/02/12 13:59:15 matteo
  107. * mer feb 12 14:56:57 CET 2003
  108. *
  109. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  110. * mer feb 12 14:56:57 CET 2003
  111. *
  112. * Revision 1.2 2000/01/05 08:20:39 markster
  113. * Some OSS fixes and a few lpc changes to make it actually work
  114. *
  115. * Revision 1.2 1996/08/20 20:31:21 jaf
  116. * Removed all static local variables that were SAVE'd in the Fortran
  117. * code, and put them in struct lpc10_encoder_state that is passed as an
  118. * argument.
  119. *
  120. * Removed init function, since all initialization is now done in
  121. * init_lpc10_encoder_state().
  122. *
  123. * Changed name of function from lpcenc_ to lpc10_encode, simply to make
  124. * all lpc10 functions have more consistent naming with each other.
  125. *
  126. * Revision 1.1 1996/08/19 22:31:44 jaf
  127. * Initial revision
  128. * */
  129. /* Revision 1.3 1996/03/29 22:03:47 jaf */
  130. /* Removed definitions for any constants that were no longer used. */
  131. /* Revision 1.2 1996/03/26 19:34:33 jaf */
  132. /* Added comments indicating which constants are not needed in an */
  133. /* application that uses the LPC-10 coder. */
  134. /* Revision 1.1 1996/02/07 14:43:51 jaf */
  135. /* Initial revision */
  136. /* LPC Configuration parameters: */
  137. /* Frame size, Prediction order, Pitch period */
  138. /* Local variables that need not be saved */
  139. /* Uncoded speech parameters */
  140. /* Coded speech parameters */
  141. /* Local state */
  142. /* None */
  143. /* Parameter adjustments */
  144. if (speech) {
  145. --speech;
  146. }
  147. if (bits) {
  148. --bits;
  149. }
  150. /* Function Body */
  151. prepro_(&speech[1], &c__180, st);
  152. analys_(&speech[1], voice, &pitch, &rms, rc, st);
  153. encode_(voice, &pitch, &rms, rc, &ipitv, &irms, irc);
  154. chanwr_(&c__10, &ipitv, &irms, irc, &bits[1], st);
  155. return 0;
  156. } /* lpcenc_ */