preemp.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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:30:58 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 preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__);
  22. #endif
  23. /* ******************************************************************* */
  24. /* PREEMP 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:30:58 jaf
  39. * Initial revision
  40. * */
  41. /* Revision 1.3 1996/03/14 23:16:29 jaf */
  42. /* Just added a few comments about which array indices of the arguments */
  43. /* are used, and mentioning that this subroutine has no local state. */
  44. /* Revision 1.2 1996/03/11 23:23:34 jaf */
  45. /* Added a bunch of comments to an otherwise simple subroutine. */
  46. /* Revision 1.1 1996/02/07 14:48:48 jaf */
  47. /* Initial revision */
  48. /* ******************************************************************* */
  49. /* Preemphasize speech with a single-zero filter. */
  50. /* (When coef = .9375, preemphasis is as in LPC43.) */
  51. /* Inputs: */
  52. /* NSAMP - Number of samples to filter */
  53. /* INBUF - Input speech buffer */
  54. /* Indices 1 through NSAMP are read. */
  55. /* COEF - Preemphasis coefficient */
  56. /* Input/Output: */
  57. /* Z - Filter state */
  58. /* Output: */
  59. /* PEBUF - Preemphasized speech buffer (can be equal to INBUF) */
  60. /* Indices 1 through NSAMP are modified. */
  61. /* This subroutine has no local state. */
  62. /* Subroutine */ int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *
  63. coef, real *z__)
  64. {
  65. /* System generated locals */
  66. integer i__1;
  67. /* Local variables */
  68. real temp;
  69. integer i__;
  70. /* Arguments */
  71. /* Local variables */
  72. /* None of these need to have their values saved from one */
  73. /* invocation to the next. */
  74. /* Logically, this subroutine computes the output sequence */
  75. /* pebuf(1:nsamp) defined by: */
  76. /* pebuf(i) = inbuf(i) - coef * inbuf(i-1) */
  77. /* where inbuf(0) is defined by the value of z given as input to */
  78. /* this subroutine. */
  79. /* What is this filter's frequency response and phase response? */
  80. /* Why is this filter applied to the speech? */
  81. /* Could it be more efficient to apply multiple filters */
  82. /* simultaneously, by combining them into one equivalent filter? */
  83. /* Are there ever cases when "factoring" one high-order filter into
  84. */
  85. /* multiple smaller-order filter actually reduces the number of */
  86. /* arithmetic operations needed to perform them? */
  87. /* When I first read this subroutine, I didn't understand why the */
  88. /* variable temp was used. It seemed that the statements in the do
  89. */
  90. /* loop could be replaced with the following: */
  91. /* pebuf(i) = inbuf(i) - coef * z */
  92. /* z = inbuf(i) */
  93. /* The reason for temp is so that even if pebuf and inbuf are the */
  94. /* same arrays in memory (i.e., they are aliased), then this */
  95. /* subroutine will still work correctly. I didn't realize this */
  96. /* until seeing the comment after PEBUF above that says "(can be */
  97. /* equal to INBUF)". */
  98. /* Parameter adjustments */
  99. --pebuf;
  100. --inbuf;
  101. /* Function Body */
  102. i__1 = *nsamp;
  103. for (i__ = 1; i__ <= i__1; ++i__) {
  104. temp = inbuf[i__] - *coef * *z__;
  105. *z__ = inbuf[i__];
  106. pebuf[i__] = temp;
  107. /* L10: */
  108. }
  109. return 0;
  110. } /* preemp_ */