deemp.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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:14 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:14 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:23:46 jaf
  12. * Removed all static local variables that were SAVE'd in the Fortran
  13. * code, and put them in struct lpc10_decoder_state that is passed as an
  14. * argument.
  15. *
  16. * Removed init function, since all initialization is now done in
  17. * init_lpc10_decoder_state().
  18. *
  19. * Revision 1.1 1996/08/19 22:32:34 jaf
  20. * Initial revision
  21. *
  22. */
  23. /* -- translated by f2c (version 19951025).
  24. You must link the resulting object file with the libraries:
  25. -lf2c -lm (in that order)
  26. */
  27. #include "f2c.h"
  28. #ifdef P_R_O_T_O_T_Y_P_E_S
  29. extern int deemp_(real *x, integer *n, struct lpc10_decoder_state *st);
  30. #endif
  31. /* ***************************************************************** */
  32. /* DEEMP Version 48 */
  33. /* $Log$
  34. * Revision 1.15 2004/06/26 03:50:14 markster
  35. * Merge source cleanups (bug #1911)
  36. *
  37. * Revision 1.14 2003/02/12 13:59:14 matteo
  38. * mer feb 12 14:56:57 CET 2003
  39. *
  40. * Revision 1.1.1.1 2003/02/12 13:59:14 matteo
  41. * mer feb 12 14:56:57 CET 2003
  42. *
  43. * Revision 1.2 2000/01/05 08:20:39 markster
  44. * Some OSS fixes and a few lpc changes to make it actually work
  45. *
  46. * Revision 1.2 1996/08/20 20:23:46 jaf
  47. * Removed all static local variables that were SAVE'd in the Fortran
  48. * code, and put them in struct lpc10_decoder_state that is passed as an
  49. * argument.
  50. *
  51. * Removed init function, since all initialization is now done in
  52. * init_lpc10_decoder_state().
  53. *
  54. * Revision 1.1 1996/08/19 22:32:34 jaf
  55. * Initial revision
  56. * */
  57. /* Revision 1.3 1996/03/20 15:54:37 jaf */
  58. /* Added comments about which indices of array arguments are read or */
  59. /* written. */
  60. /* Added entry INITDEEMP to reinitialize the local state variables, if */
  61. /* desired. */
  62. /* Revision 1.2 1996/03/14 22:11:13 jaf */
  63. /* Comments added explaining which of the local variables of this */
  64. /* subroutine need to be saved from one invocation to the next, and which */
  65. /* do not. */
  66. /* Revision 1.1 1996/02/07 14:44:53 jaf */
  67. /* Initial revision */
  68. /* ***************************************************************** */
  69. /* De-Emphasize output speech with 1 / ( 1 - .75z**-1 ) */
  70. /* cascaded with 200 Hz high pass filter */
  71. /* ( 1 - 1.9998z**-1 + z**-2 ) / ( 1 - 1.75z**-1 + .78z**-2 ) */
  72. /* WARNING! The coefficients above may be out of date with the code */
  73. /* below. Either that, or some kind of transformation was performed */
  74. /* on the coefficients above to create the code below. */
  75. /* Input: */
  76. /* N - Number of samples */
  77. /* Input/Output: */
  78. /* X - Speech */
  79. /* Indices 1 through N are read before being written. */
  80. /* This subroutine maintains local state from one call to the next. If */
  81. /* you want to switch to using a new audio stream for this filter, or */
  82. /* reinitialize its state for any other reason, call the ENTRY */
  83. /* INITDEEMP. */
  84. /* Subroutine */ int deemp_(real *x, integer *n, struct lpc10_decoder_state *st)
  85. {
  86. /* Initialized data */
  87. real *dei1;
  88. real *dei2;
  89. real *deo1;
  90. real *deo2;
  91. real *deo3;
  92. /* System generated locals */
  93. integer i__1;
  94. real r__1;
  95. /* Local variables */
  96. integer k;
  97. real dei0;
  98. /* Arguments */
  99. /* Local variables that need not be saved */
  100. /* Local state */
  101. /* All of the locals saved below were not given explicit initial */
  102. /* values in the original code. I think 0 is a safe choice. */
  103. /* Parameter adjustments */
  104. if (x) {
  105. --x;
  106. }
  107. /* Function Body */
  108. dei1 = &(st->dei1);
  109. dei2 = &(st->dei2);
  110. deo1 = &(st->deo1);
  111. deo2 = &(st->deo2);
  112. deo3 = &(st->deo3);
  113. i__1 = *n;
  114. for (k = 1; k <= i__1; ++k) {
  115. dei0 = x[k];
  116. r__1 = x[k] - *dei1 * 1.9998f + *dei2;
  117. x[k] = r__1 + *deo1 * 2.5f - *deo2 * 2.0925f + *deo3 * .585f;
  118. *dei2 = *dei1;
  119. *dei1 = dei0;
  120. *deo3 = *deo2;
  121. *deo2 = *deo1;
  122. *deo1 = x[k];
  123. }
  124. return 0;
  125. } /* deemp_ */