| 1 | /* |
| 2 | |
| 3 | $Log$ |
| 4 | Revision 1.15 2004/06/26 03:50:14 markster |
| 5 | Merge source cleanups (bug #1911) |
| 6 | |
| 7 | Revision 1.14 2003/02/12 13:59:15 matteo |
| 8 | mer feb 12 14:56:57 CET 2003 |
| 9 | |
| 10 | Revision 1.1.1.1 2003/02/12 13:59:15 matteo |
| 11 | mer feb 12 14:56:57 CET 2003 |
| 12 | |
| 13 | Revision 1.2 2000/01/05 08:20:39 markster |
| 14 | Some OSS fixes and a few lpc changes to make it actually work |
| 15 | |
| 16 | * Revision 1.1 1996/08/19 22:30:58 jaf |
| 17 | * Initial revision |
| 18 | * |
| 19 | |
| 20 | */ |
| 21 | |
| 22 | /* -- translated by f2c (version 19951025). |
| 23 | You must link the resulting object file with the libraries: |
| 24 | -lf2c -lm (in that order) |
| 25 | */ |
| 26 | |
| 27 | #include "f2c.h" |
| 28 | |
| 29 | #ifdef P_R_O_T_O_T_Y_P_E_S |
| 30 | extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__); |
| 31 | #endif |
| 32 | |
| 33 | /* ******************************************************************* */ |
| 34 | |
| 35 | /* PREEMP Version 55 */ |
| 36 | |
| 37 | /* $Log$ |
| 38 | * Revision 1.15 2004/06/26 03:50:14 markster |
| 39 | * Merge source cleanups (bug #1911) |
| 40 | * |
| 41 | * Revision 1.14 2003/02/12 13:59:15 matteo |
| 42 | * mer feb 12 14:56:57 CET 2003 |
| 43 | * |
| 44 | * Revision 1.1.1.1 2003/02/12 13:59:15 matteo |
| 45 | * mer feb 12 14:56:57 CET 2003 |
| 46 | * |
| 47 | * Revision 1.2 2000/01/05 08:20:39 markster |
| 48 | * Some OSS fixes and a few lpc changes to make it actually work |
| 49 | * |
| 50 | * Revision 1.1 1996/08/19 22:30:58 jaf |
| 51 | * Initial revision |
| 52 | * */ |
| 53 | /* Revision 1.3 1996/03/14 23:16:29 jaf */ |
| 54 | /* Just added a few comments about which array indices of the arguments */ |
| 55 | /* are used, and mentioning that this subroutine has no local state. */ |
| 56 | |
| 57 | /* Revision 1.2 1996/03/11 23:23:34 jaf */ |
| 58 | /* Added a bunch of comments to an otherwise simple subroutine. */ |
| 59 | |
| 60 | /* Revision 1.1 1996/02/07 14:48:48 jaf */ |
| 61 | /* Initial revision */ |
| 62 | |
| 63 | |
| 64 | /* ******************************************************************* */ |
| 65 | |
| 66 | /* Preemphasize speech with a single-zero filter. */ |
| 67 | /* (When coef = .9375, preemphasis is as in LPC43.) */ |
| 68 | |
| 69 | /* Inputs: */ |
| 70 | /* NSAMP - Number of samples to filter */ |
| 71 | /* INBUF - Input speech buffer */ |
| 72 | /* Indices 1 through NSAMP are read. */ |
| 73 | /* COEF - Preemphasis coefficient */ |
| 74 | /* Input/Output: */ |
| 75 | /* Z - Filter state */ |
| 76 | /* Output: */ |
| 77 | /* PEBUF - Preemphasized speech buffer (can be equal to INBUF) */ |
| 78 | /* Indices 1 through NSAMP are modified. */ |
| 79 | |
| 80 | /* This subroutine has no local state. */ |
| 81 | |
| 82 | /* Subroutine */ int preemp_(real *inbuf, real *pebuf, integer *nsamp, real * |
| 83 | coef, real *z__) |
| 84 | { |
| 85 | /* System generated locals */ |
| 86 | integer i__1; |
| 87 | |
| 88 | /* Local variables */ |
| 89 | real temp; |
| 90 | integer i__; |
| 91 | |
| 92 | /* Arguments */ |
| 93 | /* Local variables */ |
| 94 | |
| 95 | /* None of these need to have their values saved from one */ |
| 96 | /* invocation to the next. */ |
| 97 | |
| 98 | /* Logically, this subroutine computes the output sequence */ |
| 99 | /* pebuf(1:nsamp) defined by: */ |
| 100 | |
| 101 | /* pebuf(i) = inbuf(i) - coef * inbuf(i-1) */ |
| 102 | |
| 103 | /* where inbuf(0) is defined by the value of z given as input to */ |
| 104 | /* this subroutine. */ |
| 105 | |
| 106 | /* What is this filter's frequency response and phase response? */ |
| 107 | |
| 108 | /* Why is this filter applied to the speech? */ |
| 109 | |
| 110 | /* Could it be more efficient to apply multiple filters */ |
| 111 | /* simultaneously, by combining them into one equivalent filter? */ |
| 112 | |
| 113 | /* Are there ever cases when "factoring" one high-order filter into |
| 114 | */ |
| 115 | /* multiple smaller-order filter actually reduces the number of */ |
| 116 | /* arithmetic operations needed to perform them? */ |
| 117 | /* When I first read this subroutine, I didn't understand why the */ |
| 118 | /* variable temp was used. It seemed that the statements in the do |
| 119 | */ |
| 120 | /* loop could be replaced with the following: */ |
| 121 | |
| 122 | /* pebuf(i) = inbuf(i) - coef * z */ |
| 123 | /* z = inbuf(i) */ |
| 124 | |
| 125 | /* The reason for temp is so that even if pebuf and inbuf are the */ |
| 126 | /* same arrays in memory (i.e., they are aliased), then this */ |
| 127 | /* subroutine will still work correctly. I didn't realize this */ |
| 128 | /* until seeing the comment after PEBUF above that says "(can be */ |
| 129 | /* equal to INBUF)". */ |
| 130 | /* Parameter adjustments */ |
| 131 | --pebuf; |
| 132 | --inbuf; |
| 133 | |
| 134 | /* Function Body */ |
| 135 | i__1 = *nsamp; |
| 136 | for (i__ = 1; i__ <= i__1; ++i__) { |
| 137 | temp = inbuf[i__] - *coef * *z__; |
| 138 | *z__ = inbuf[i__]; |
| 139 | pebuf[i__] = temp; |
| 140 | /* L10: */ |
| 141 | } |
| 142 | return 0; |
| 143 | } /* preemp_ */ |