formats: clarify setting of reverse_bytes
[sox.git] / lpc10 / preemp.c
bloba6310ca9d51baa82107678483f8759a264dfe97d
1 /*
3 * Revision 1.1 1996/08/19 22:30:58 jaf
4 * Initial revision
7 */
9 /* -- translated by f2c (version 19951025).
10 You must link the resulting object file with the libraries:
11 -lf2c -lm (in that order)
14 #include "f2c.h"
16 extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__);
18 /* ******************************************************************* */
20 /* PREEMP Version 55 */
23 * Revision 1.1 1996/08/19 22:30:58 jaf
24 * Initial revision
25 * */
26 /* Revision 1.3 1996/03/14 23:16:29 jaf */
27 /* Just added a few comments about which array indices of the arguments */
28 /* are used, and mentioning that this subroutine has no local state. */
30 /* Revision 1.2 1996/03/11 23:23:34 jaf */
31 /* Added a bunch of comments to an otherwise simple subroutine. */
33 /* Revision 1.1 1996/02/07 14:48:48 jaf */
34 /* Initial revision */
37 /* ******************************************************************* */
39 /* Preemphasize speech with a single-zero filter. */
40 /* (When coef = .9375, preemphasis is as in LPC43.) */
42 /* Inputs: */
43 /* NSAMP - Number of samples to filter */
44 /* INBUF - Input speech buffer */
45 /* Indices 1 through NSAMP are read. */
46 /* COEF - Preemphasis coefficient */
47 /* Input/Output: */
48 /* Z - Filter state */
49 /* Output: */
50 /* PEBUF - Preemphasized speech buffer (can be equal to INBUF) */
51 /* Indices 1 through NSAMP are modified. */
53 /* This subroutine has no local state. */
55 /* Subroutine */ int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *
56 coef, real *z__)
58 /* System generated locals */
59 integer i__1;
61 /* Local variables */
62 real temp;
63 integer i__;
65 /* Arguments */
66 /* Local variables */
68 /* None of these need to have their values saved from one */
69 /* invocation to the next. */
71 /* Logically, this subroutine computes the output sequence */
72 /* pebuf(1:nsamp) defined by: */
74 /* pebuf(i) = inbuf(i) - coef * inbuf(i-1) */
76 /* where inbuf(0) is defined by the value of z given as input to */
77 /* this subroutine. */
79 /* What is this filter's frequency response and phase response? */
81 /* Why is this filter applied to the speech? */
83 /* Could it be more efficient to apply multiple filters */
84 /* simultaneously, by combining them into one equivalent filter? */
86 /* Are there ever cases when "factoring" one high-order filter into
88 /* multiple smaller-order filter actually reduces the number of */
89 /* arithmetic operations needed to perform them? */
90 /* When I first read this subroutine, I didn't understand why the */
91 /* variable temp was used. It seemed that the statements in the do
93 /* loop could be replaced with the following: */
95 /* pebuf(i) = inbuf(i) - coef * z */
96 /* z = inbuf(i) */
98 /* The reason for temp is so that even if pebuf and inbuf are the */
99 /* same arrays in memory (i.e., they are aliased), then this */
100 /* subroutine will still work correctly. I didn't realize this */
101 /* until seeing the comment after PEBUF above that says "(can be */
102 /* equal to INBUF)". */
103 /* Parameter adjustments */
104 --pebuf;
105 --inbuf;
107 /* Function Body */
108 i__1 = *nsamp;
109 for (i__ = 1; i__ <= i__1; ++i__) {
110 temp = inbuf[i__] - *coef * *z__;
111 *z__ = inbuf[i__];
112 pebuf[i__] = temp;
113 /* L10: */
115 return 0;
116 } /* preemp_ */