hp100.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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:28:05 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. * Revision 1.1 1996/08/19 22:32:04 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 hp100_(real *speech, integer *start, integer *end,
  30. struct lpc10_encoder_state *st);
  31. extern int inithp100_(void);
  32. #endif
  33. /* ********************************************************************* */
  34. /* HP100 Version 55 */
  35. /* $Log$
  36. * Revision 1.15 2004/06/26 03:50:14 markster
  37. * Merge source cleanups (bug #1911)
  38. *
  39. * Revision 1.14 2003/02/12 13:59:15 matteo
  40. * mer feb 12 14:56:57 CET 2003
  41. *
  42. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  43. * mer feb 12 14:56:57 CET 2003
  44. *
  45. * Revision 1.2 2000/01/05 08:20:39 markster
  46. * Some OSS fixes and a few lpc changes to make it actually work
  47. *
  48. * Revision 1.2 1996/08/20 20:28:05 jaf
  49. * Removed all static local variables that were SAVE'd in the Fortran
  50. * code, and put them in struct lpc10_encoder_state that is passed as an
  51. * argument.
  52. *
  53. * Removed init function, since all initialization is now done in
  54. * init_lpc10_encoder_state().
  55. *
  56. * Revision 1.1 1996/08/19 22:32:04 jaf
  57. * Initial revision
  58. * */
  59. /* Revision 1.6 1996/03/15 16:45:25 jaf */
  60. /* Rearranged a few comments. */
  61. /* Revision 1.5 1996/03/14 23:20:54 jaf */
  62. /* Added comments about when INITHP100 should be used. */
  63. /* Revision 1.4 1996/03/14 23:08:08 jaf */
  64. /* Added an entry named INITHP100 that initializes the local state of */
  65. /* subroutine HP100. */
  66. /* Revision 1.3 1996/03/14 22:09:20 jaf */
  67. /* Comments added explaining which of the local variables of this */
  68. /* subroutine need to be saved from one invocation to the next, and which */
  69. /* do not. */
  70. /* Revision 1.2 1996/02/12 15:05:54 jaf */
  71. /* Added lots of comments explaining why I changed one line, which was a */
  72. /* declaration with initializations. */
  73. /* Revision 1.1 1996/02/07 14:47:12 jaf */
  74. /* Initial revision */
  75. /* ********************************************************************* */
  76. /* 100 Hz High Pass Filter */
  77. /* Jan 92 - corrected typo (1.937148 to 1.935715), */
  78. /* rounded coefficients to 7 places, */
  79. /* corrected and merged gain (.97466**4), */
  80. /* merged numerator into first two sections. */
  81. /* Input: */
  82. /* start, end - Range of samples to filter */
  83. /* Input/Output: */
  84. /* speech(end) - Speech data. */
  85. /* Indices start through end are read and modified. */
  86. /* This subroutine maintains local state from one call to the next. If */
  87. /* you want to switch to using a new audio stream for this filter, or */
  88. /* reinitialize its state for any other reason, call the ENTRY */
  89. /* INITHP100. */
  90. /* Subroutine */ int hp100_(real *speech, integer *start, integer *end,
  91. struct lpc10_encoder_state *st)
  92. {
  93. /* Temporary local copies of variables in lpc10_encoder_state.
  94. I've only created these because it might cause the loop below
  95. to execute a bit faster to access local variables, rather than
  96. variables in the lpc10_encoder_state structure. It is just a
  97. guess that it will be faster. */
  98. real z11;
  99. real z21;
  100. real z12;
  101. real z22;
  102. /* System generated locals */
  103. integer i__1;
  104. /* Local variables */
  105. integer i__;
  106. real si, err;
  107. /* Arguments */
  108. /* Local variables that need not be saved */
  109. /* Local state */
  110. /* Parameter adjustments */
  111. if (speech) {
  112. --speech;
  113. }
  114. /* Function Body */
  115. z11 = st->z11;
  116. z21 = st->z21;
  117. z12 = st->z12;
  118. z22 = st->z22;
  119. i__1 = *end;
  120. for (i__ = *start; i__ <= i__1; ++i__) {
  121. si = speech[i__];
  122. err = si + z11 * 1.859076f - z21 * .8648249f;
  123. si = err - z11 * 2.f + z21;
  124. z21 = z11;
  125. z11 = err;
  126. err = si + z12 * 1.935715f - z22 * .9417004f;
  127. si = err - z12 * 2.f + z22;
  128. z22 = z12;
  129. z12 = err;
  130. speech[i__] = si * .902428f;
  131. }
  132. st->z11 = z11;
  133. st->z21 = z21;
  134. st->z12 = z12;
  135. st->z22 = z22;
  136. return 0;
  137. } /* hp100_ */