93
C H A P T E R 6
Real-Time Filtering
For carrying out real-time filtering, it is required to know how to acquire input samples, process
them, and provide the result. is chapter addresses these issues toward achieving real-time
filtering implementation on the ARM processor of a smartphone.
6.1 FIR FILTER IMPLEMENTATION
An FIR filter can be implemented in C using standard math functions or by using NEON
intrinsics. e goal of the implementation is to have a minimum cycle time algorithm. is
means doing the filtering as fast as possible in order to achieve the highest sampling frequency
(the smallest sampling time interval). Initially, the filter is implemented in C, since this demands
the least coding effort. In Chapter 9 covering optimization, alternative implementations will
be considered based on this algorithm. e difference equation yŒn D
P
N 1
kD0
B
k
xŒn k is
implemented to realize the filter.
Considering Q15 representation here, 16-bit samples need to get multiplied by 16-bit
coefficients. In order to store the product in 32 bits, it has to be left shifted by one to get rid
of the extended sign bit. Now, to export the product to the output, it must be right shifted by
16 to place it in the lower 16 bits. Alternatively, the product may be right shifted by 15 without
removing the sign bit but this will result in a slight loss of precision in the intermediate result
accumulator.
To implement the algorithm in C, standard multiplication expressions and the shift oper-
ators << and >> are used as shown below. Here, result is 32 bits wide, while the variables
coefficient and sample are 16 bits wide.
result = ( coefficient * sample ) << 1;
result = result >> 16;
or
result = ( coefficient * sample ) >> 15;
For the proper operation of the FIR filter, it is required that the current sample and N 1
previous samples be processed at the same time, where N is the number of coefficients. Hence,
the N most current samples have to be stored and updated with each incoming sample. is can
be done easily via the following code.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.228.35