lpfilt.c
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

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