lpfilt.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.1 1996/08/19 22:31:35 jaf
  12. * Initial revision
  13. *
  14. */
  15. /* -- translated by f2c (version 19951025).
  16. You must link the resulting object file with the libraries:
  17. -lf2c -lm (in that order)
  18. */
  19. #include "f2c.h"
  20. #ifdef P_R_O_T_O_T_Y_P_E_S
  21. extern int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *nsamp);
  22. #endif
  23. /* *********************************************************************** */
  24. /* LPFILT Version 55 */
  25. /* $Log$
  26. * Revision 1.15 2004/06/26 03:50:14 markster
  27. * Merge source cleanups (bug #1911)
  28. *
  29. * Revision 1.14 2003/02/12 13:59:15 matteo
  30. * mer feb 12 14:56:57 CET 2003
  31. *
  32. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  33. * mer feb 12 14:56:57 CET 2003
  34. *
  35. * Revision 1.2 2000/01/05 08:20:39 markster
  36. * Some OSS fixes and a few lpc changes to make it actually work
  37. *
  38. * Revision 1.1 1996/08/19 22:31:35 jaf
  39. * Initial revision
  40. * */
  41. /* Revision 1.3 1996/03/15 16:53:49 jaf */
  42. /* Just put comment header in standard form. */
  43. /* Revision 1.2 1996/03/12 23:58:06 jaf */
  44. /* Comments added explaining that none of the local variables of this */
  45. /* subroutine need to be saved from one invocation to the next. */
  46. /* Revision 1.1 1996/02/07 14:47:44 jaf */
  47. /* Initial revision */
  48. /* *********************************************************************** */
  49. /* 31 Point Equiripple FIR Low-Pass Filter */
  50. /* Linear phase, delay = 15 samples */
  51. /* Passband: ripple = 0.25 dB, cutoff = 800 Hz */
  52. /* Stopband: atten. = 40. dB, cutoff = 1240 Hz */
  53. /* Inputs: */
  54. /* LEN - Length of speech buffers */
  55. /* NSAMP - Number of samples to filter */
  56. /* INBUF - Input speech buffer */
  57. /* Indices len-nsamp-29 through len are read. */
  58. /* Output: */
  59. /* LPBUF - Low passed speech buffer (must be different array than INBUF) */
  60. /* Indices len+1-nsamp through len are written. */
  61. /* This subroutine has no local state. */
  62. /* Subroutine */ int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *
  63. nsamp)
  64. {
  65. /* System generated locals */
  66. integer i__1;
  67. /* Local variables */
  68. integer j;
  69. real t;
  70. /* Arguments */
  71. /* Parameters/constants */
  72. /* Local variables that need not be saved */
  73. /* Local state */
  74. /* None */
  75. /* Parameter adjustments */
  76. --lpbuf;
  77. --inbuf;
  78. /* Function Body */
  79. i__1 = *len;
  80. for (j = *len + 1 - *nsamp; j <= i__1; ++j) {
  81. t = (inbuf[j] + inbuf[j - 30]) * -.0097201988f;
  82. t += (inbuf[j - 1] + inbuf[j - 29]) * -.0105179986f;
  83. t += (inbuf[j - 2] + inbuf[j - 28]) * -.0083479648f;
  84. t += (inbuf[j - 3] + inbuf[j - 27]) * 5.860774e-4f;
  85. t += (inbuf[j - 4] + inbuf[j - 26]) * .0130892089f;
  86. t += (inbuf[j - 5] + inbuf[j - 25]) * .0217052232f;
  87. t += (inbuf[j - 6] + inbuf[j - 24]) * .0184161253f;
  88. t += (inbuf[j - 7] + inbuf[j - 23]) * 3.39723e-4f;
  89. t += (inbuf[j - 8] + inbuf[j - 22]) * -.0260797087f;
  90. t += (inbuf[j - 9] + inbuf[j - 21]) * -.0455563702f;
  91. t += (inbuf[j - 10] + inbuf[j - 20]) * -.040306855f;
  92. t += (inbuf[j - 11] + inbuf[j - 19]) * 5.029835e-4f;
  93. t += (inbuf[j - 12] + inbuf[j - 18]) * .0729262903f;
  94. t += (inbuf[j - 13] + inbuf[j - 17]) * .1572008878f;
  95. t += (inbuf[j - 14] + inbuf[j - 16]) * .2247288674f;
  96. t += inbuf[j - 15] * .250535965f;
  97. lpbuf[j] = t;
  98. }
  99. return 0;
  100. } /* lpfilt_ */