The Android FIR Filter Designer app designs minimal-order finite impulse response (FIR) digital filters based on performance specifications you provide. The application attempts to find the lowest order (smallest) set of FIR filter coefficients that satisfies the given specifications. The generated filter has approximately unity (0 dB) gain in the passband.
The output of the design procedure is a list of double-precision filter coefficients (Text output option) or an implementation of the filter in C/C++, C#, Java or MATLAB/GNU Octave source code. This output is formatted into an email you can send to any recipients.
The app has two tabs for user input. The tabs are shown below as displayed on a Google Nexus 7. The app works on any Android 2.3.3 or later device. Click each image to view in full resolution.
The minimal-order filter frequency responses for the four different types of filters designed using the default specifications are shown below. The zones forbidden by the filter design parameters are shown in gray.
When the filter design process finishes an email will be prepared containing the numerical filter coefficients and an implementation of the filter in all of the programming languages you selected in the Output Options checkboxes. An example email for the above lowpass filter design is shown below. In this example, only the Java output option was selected.
Subject: Lowpass Filter Design This email contains a digital finite impulse response (FIR) filter designed with the Android FIR Filter Designer application from www.ledin.com. This filter design and associated source code are for educational purposes and are not guaranteed to perform as desired under any circumstances. Filter specifications: Filter type : Lowpass Sample Rate : 44100 Hz Passband gain : 1 dB Stopband gain : -60 dB Low band edge : 5000 Hz High band edge : 10000 Hz Filter design results: Filter order : 18 Passband weight : 0.00866 //////// Java Source Code Implementation of Filter //////// private final int N = 19; private final double[] h = { 0.0017106420472549515, 4.260001201471347E-4, -0.010448967060907076, -0.03284676688553758, -0.05222287470220172, -0.03905038327818816, 0.02983474981723218, 0.14402898137066716, 0.2539179504433725, 0.29951664215186996, 0.2539179504433725, 0.14402898137066716, 0.02983474981723218, -0.03905038327818816, -0.05222287470220172, -0.03284676688553758, -0.010448967060907076, 4.260001201471347E-4, 0.0017106420472549515, }; private int n = 0; private double[] x = new double[N]; public double filter(double x_in) { double y = 0.0; // Store the current input, overwriting the oldest input x[n] = x_in; // Multiply the filter coefficients by the previous inputs and sum for (int i=0; i<N; i++) { y += h[i] * x[((N - i) + n) % N]; } // Increment the input buffer index to the next location n = (n + 1) % N; return y; } ///// End of Java Source Code Implementation of Filter ////
The source code implementation of the filter is not intended to be particularly efficient or to be a stellar example of object-oriented programming. It is merely an example that shows how to compute a filter output given the next input sample.
Android FIR Filter Designer FAQ
Q: How can I verify the frequency response of the FIR filter generated by this app matches the graphical representation displayed in the app?
A: One way to check the filter design is to install GNU Octave and run the code produced when the Output to MATLAB/GNU Octave checkbox is selected. The freqz
command displays a frequency response graph for the FIR filter.
Q: My filter design was not successful. What did I do wrong?
A: If you attempt to design a filter with tight tolerances (narrow transition bands between passband and stopband or a very small value for Passband Gain) the resulting design may require a very high order filter. If you would like to attempt a high order filter design you can increase the value of the Max Filter Order parameter to allow higher order filter designs to be attempted. Note that high order filter designs may require much more processing time and memory space.
Source Code
Complete source code for the Android FIR Filter Designer app is available at https://www.assembla.com/code/firdesign/subversion/nodes.
Privacy Policy
Click to view the app privacy policy.
Credits
Thanks to Jake Janovetz for providing a GPL-licensed C language implementation of the Parks–McClellan algorithm, a variation of the Remez exchange algorithm, that served as the basis for this Java language implementation.