//######################################################################################################################### Class Filter public class Filter Describtion: Synthesizes a FIR-filter for DSP applications using the window-method. The filter order (number of coefficients - 1) must be >= 1. The following filter settings are supported: LP, HP, BP, BS with complex impulse response (upper or lower sideband) LP, HP, BP, BS with real impulse response (both sidebands) Constructor: public Filter(int order, int samples, double[] window) Parameters: order - Specifies the order of the FIR-filter (size = order + 1). samples - Specifies the data sampling intervall in [samples/second]. window - The window-function table to be applied. If windowing should not be performed, "window" must be set to "null". Throws: InvalidParameterException if order<1 if samples<1 if the window-function table is not either of the type double[size] or null Methods: public int getOrder() Returns: Returns the order of the FIR-filter (size = order + 1). public int getSampleRate() Returns: Returns the underlying data sampling intervall in [samples/second]. public double[][] getCoefficients() Returns the data array containing the calculated filter coefficients. Calling this method does not calculate the filter. For this "doFilter" has to be called. Returns: A data array of the type double[][] which contains the calculated filter coefficients. The sub-array double[][0] contains the real part and double[][1] the imaginary part. The latter will be empty (all elements at 0.0) in case the filter is real and not complex. public double[] getCoefficient(int index) Returns a single point of the data array, specified by "index". Calling this method does not calculate the filter. For this "doFilter" has to be called. Returns: A data array of the type double[] which contains the calculated filter coefficient specified by "index". The element double[0] contains the real part and double[1] the imaginary part. The latter will be 0.0 in case the filter is real and not complex. Throws: InvalidParameterException if the index<0 or index>order public double[] getWindow() Returns the data array containing the currently set window coefficients. Returns: A data array of the type double[] which contains the currently set window coefficients or null, if windowing has been disabled. public boolean setWindow(double[] window) Sets the window-function table to be applied. If windowing should not be performed, "window" must be set to "null". Returns: True, if setting the window-function was done successfully, false otherwise. Throws: InvalidParameterException if the window-function table is not either of the type double[size] or null. public boolean doFilter(float low, float high, int type, int mode) Performs calculation of the filter coefficients. The parameter "low" and "high" specify the low and high cutoff frequency in Hertz. The filtertype is given by "type" as follows: 0 for Lowpass (low cutoff ignored) 1 for Highpass (high cutoff ignored) 2 for Bandpass 3 for Bandstopp The parameter "mode" must be one of the following: 0 for complex coefficients, upper sideband 1 for complex coefficients, lower sideband 2 for real coefficients, both sidebands (all imaginary parts being Zero) Returns: True, if calculating the filter coefficients was done successfully, false otherwise. Throws: InvalidParameterException if cutoff frequency is out of range (low>=high, high<0, low<0, high>samples/2) if type<0 or type>3 if mode<0 or mode>2 //#########################################################################################################################