Digital Signal Processing Reference
In-Depth Information
on how the variables are initially declared. For example, if the variables are
double , the increment is 8; if they are int , the increment is 2.
Now, returning to our discussion of Listing 8.2, we next enter a for loop
(line 11) used to calculate the effects of each quadratic factor on the ultimate
output value. Lines 12-13 compute the value of w and increment the pointer in the
C array as each value is used. Lines 14-15 then make the calculations representing
the right half of Figure 8.2 to determine the output value. The pointer c is now
pointing to the b coefficients for the next quadratic section. Lines 16-17 update
the values of the memory states and increment m1 and m2 to point to the memory
states of the next quadratic section. The final step in the determination of the
output value is the conversion of the floating-point value of o to the fixed point
value of *y . The method used in converting the floating point value to an integer
value insures that both positive and negative values will be rounded correctly. The
pointer y is then incremented and the process repeats for the next value in the
input array. We should note that by the end of the outer for loop, the c , m1 , and
m2 pointers will be pointing to values that do not belong to them. That's all right
as long as we don't try to access them. The next time an input value is filtered,
lines 6-8 will reset the pointers to the correct positions.
One advantage of the algorithm we have just developed is that it can be used
effectively for either real-time or nonreal-time applications. The value x can be
taken from either an input port of a DSP system, or from an array of values to be
processed (as illustrated). Likewise, the value y can be fed to an output port of a
DSP system or placed in an output array (as we have done). We will see a
program for a complete filtering system in Section 8.4.
8.3 C CODE FOR FIR FILTER IMPLEMENTATION
An FIR filter has no feedback and thus its system diagram can be displayed as
shown in Figure 8.4. This configuration represents a convolution involving N
coefficients, as described by (8.17).
Figure 8.4 System diagram for general FIR filter implementation.
N
=
1
y
(
n
)
=
g
x
(
n
k
)
a
(
k
)
(8.17)
k
0
Search WWH ::




Custom Search