README.osx wasn't easily readable in Finder. Revert back to
[sox.git] / lpc10 / hp100.c
bloba2599dc25efcf5a6122f28aae53a689b9a0432ee
1 /*
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.
8 * Removed init function, since all initialization is now done in
9 * init_lpc10_encoder_state().
11 * Revision 1.1 1996/08/19 22:32:04 jaf
12 * Initial revision
17 /* -- translated by f2c (version 19951025).
18 You must link the resulting object file with the libraries:
19 -lf2c -lm (in that order)
22 #include "f2c.h"
24 extern int hp100_(real *speech, integer *start, integer *end,
25 struct lpc10_encoder_state *st);
26 extern int inithp100_(void);
28 /* ********************************************************************* */
30 /* HP100 Version 55 */
32 /* ********************************************************************* */
34 /* 100 Hz High Pass Filter */
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. */
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. */
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. */
51 /* Subroutine */ int hp100_(real *speech, integer *start, integer *end,
52 struct lpc10_encoder_state *st)
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. */
60 real z11;
61 real z21;
62 real z12;
63 real z22;
65 /* System generated locals */
66 integer i__1;
68 /* Local variables */
69 integer i__;
70 real si, err;
72 /* Arguments */
73 /* Local variables that need not be saved */
74 /* Local state */
75 /* Parameter adjustments */
76 if (speech) {
77 --speech;
80 /* Function Body */
82 z11 = st->z11;
83 z21 = st->z21;
84 z12 = st->z12;
85 z22 = st->z22;
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;
101 st->z11 = z11;
102 st->z21 = z21;
103 st->z12 = z12;
104 st->z22 = z22;
106 return 0;
107 } /* hp100_ */