1 /*
2 
3  * Revision 1.2  1996/08/20  20:28:05  jaf
4  * Removed all static local variables that were SAVE'd in the Fortran
5  * code, and put them in struct lpc10_encoder_state that is passed as an
6  * argument.
7  *
8  * Removed init function, since all initialization is now done in
9  * init_lpc10_encoder_state().
10  *
11  * Revision 1.1  1996/08/19  22:32:04  jaf
12  * Initial revision
13  *
14 
15 */
16 
17 /*  -- translated by f2c (version 19951025).
18    You must link the resulting object file with the libraries:
19 	-lf2c -lm   (in that order)
20 */
21 
22 #include "f2c.h"
23 
24 extern int hp100_(real *speech, integer *start, integer *end,
25 		  struct lpc10_encoder_state *st);
26 extern int inithp100_(void);
27 
28 /* ********************************************************************* */
29 
30 /*      HP100 Version 55 */
31 
32 /* ********************************************************************* */
33 
34 /*    100 Hz High Pass Filter */
35 
36 /* Jan 92 - corrected typo (1.937148 to 1.935715), */
37 /*          rounded coefficients to 7 places, */
38 /*          corrected and merged gain (.97466**4), */
39 /*          merged numerator into first two sections. */
40 
41 /* Input: */
42 /*  start, end - Range of samples to filter */
43 /* Input/Output: */
44 /*  speech(end) - Speech data. */
45 /*                Indices start through end are read and modified. */
46 
47 /* This subroutine maintains local state from one call to the next.  If */
48 /* you want to switch to using a new audio stream for this filter, or */
49 /* reinitialize its state for any other reason, call the ENTRY */
50 /* INITHP100. */
hp100_(real * speech,integer * start,integer * end,struct lpc10_encoder_state * st)51 /* Subroutine */ int hp100_(real *speech, integer *start, integer *end,
52 	struct lpc10_encoder_state *st)
53 {
54     /* Temporary local copies of variables in lpc10_encoder_state.
55        I've only created these because it might cause the loop below
56        to execute a bit faster to access local variables, rather than
57        variables in the lpc10_encoder_state structure.  It is just a
58        guess that it will be faster. */
59 
60     real z11;
61     real z21;
62     real z12;
63     real z22;
64 
65     /* System generated locals */
66     integer i__1;
67 
68     /* Local variables */
69     integer i__;
70     real si, err;
71 
72 /*       Arguments */
73 /*       Local variables that need not be saved */
74 /*       Local state */
75     /* Parameter adjustments */
76     if (speech) {
77 	--speech;
78 	}
79 
80     /* Function Body */
81 
82     z11 = st->z11;
83     z21 = st->z21;
84     z12 = st->z12;
85     z22 = st->z22;
86 
87     i__1 = *end;
88     for (i__ = *start; i__ <= i__1; ++i__) {
89 	si = speech[i__];
90 	err = si + z11 * 1.859076f - z21 * .8648249f;
91 	si = err - z11 * 2.f + z21;
92 	z21 = z11;
93 	z11 = err;
94 	err = si + z12 * 1.935715f - z22 * .9417004f;
95 	si = err - z12 * 2.f + z22;
96 	z22 = z12;
97 	z12 = err;
98 	speech[i__] = si * .902428f;
99     }
100 
101     st->z11 = z11;
102     st->z21 = z21;
103     st->z12 = z12;
104     st->z22 = z22;
105 
106     return 0;
107 } /* hp100_ */
108