Java Zero Format ZeroPoleFilter(float In[], int In_idx, float ZeroCoef[], float PoleCoef[], int PoleCoef_idx, int lengthInOut, int orderCoef, float Out[], int Out_idx)

Here you can find the source of ZeroPoleFilter(float In[], int In_idx, float ZeroCoef[], float PoleCoef[], int PoleCoef_idx, int lengthInOut, int orderCoef, float Out[], int Out_idx)

Description

Zero Pole Filter

License

LGPL

Declaration

public static void ZeroPoleFilter(float In[], 
            int In_idx, float ZeroCoef[],
            float PoleCoef[],
            int PoleCoef_idx, int lengthInOut,
            int orderCoef, 
            float Out[], 
            int Out_idx) 

Method Source Code

//package com.java2s;
/*/*  ww  w .j a  v a2  s. c  o  m*/
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

public class Main {
    public static void ZeroPoleFilter(float In[], /* (i) In[0] to In[lengthInOut-1] contain
                                                        filter input samples In[-orderCoef] to
                                                        In[-1] contain state of all-zero
                                                        section */
            int In_idx, float ZeroCoef[],/* (i) filter coefficients for all-zero
                                               section (ZeroCoef[0] is assumed to
                                               be 1.0f) */
            float PoleCoef[],/* (i) filter coefficients for all-pole section
                                   (ZeroCoef[0] is assumed to be 1.0f) */
            int PoleCoef_idx, int lengthInOut,/* (i) number of input/output samples */
            int orderCoef, /* (i) number of filter coefficients */
            float Out[], /* (i/o) on entrance Out[-orderCoef] to Out[-1]
                              contain state of all-pole section. On
                              exit Out[0] to Out[lengthInOut-1]
                              contain filtered samples */
            int Out_idx) {
        AllZeroFilter(In, In_idx, ZeroCoef, lengthInOut, orderCoef, Out,
                Out_idx);
        AllPoleFilter(Out, Out_idx, PoleCoef, PoleCoef_idx, lengthInOut,
                orderCoef);
    }

    public static void AllZeroFilter(float In[], /* (i) In[0] to In[lengthInOut-1] contain
                                                       filter input samples */
            int In_idx, float Coef[],/* (i) filter coefficients (Coef[0] is assumed
                                               to be 1.0f) */
            int lengthInOut,/* (i) number of input/output samples */
            int orderCoef, /* (i) number of filter coefficients */
            float Out[], /* (i/o) on entrance Out[-orderCoef] to Out[-1]
                              contain the filter state, on exit Out[0]
                              to Out[lengthInOut-1] contain filtered
                              samples */
            int Out_idx) {
        int n, k;

        for (n = 0; n < lengthInOut; n++) {
            Out[Out_idx] = Coef[0] * In[In_idx];
            for (k = 1; k <= orderCoef; k++) {
                Out[Out_idx] += Coef[k] * In[In_idx - k];
            }
            Out_idx++;
            In_idx++;
        }
    }

    public static void AllPoleFilter(float InOut[], /* (i/o) on entrance InOut[-orderCoef] to
                                                          InOut[-1] contain the state of the
                                                          filter (delayed samples). InOut[0] to
                                                          InOut[lengthInOut-1] contain the filter
                                                          input, on en exit InOut[-orderCoef] to
                                                          InOut[-1] is unchanged and InOut[0] to
                                                          InOut[lengthInOut-1] contain filtered
                                                          samples */
            int InOut_idx, float Coef[],/* (i) filter coefficients, Coef[0] is assumed
                                                  to be 1.0f */
            int Coef_idx, int lengthInOut,/* (i) number of input/output samples */
            int orderCoef) /* (i) number of filter coefficients */
    {
        int n, k;

        for (n = 0; n < lengthInOut; n++) {
            for (k = 1; k <= orderCoef; k++) {
                InOut[n + InOut_idx] -= Coef[Coef_idx + k]
                        * InOut[n - k + InOut_idx];
            }
        }
    }
}

Related

  1. zeroObjects()
  2. ZeroOneStringToBooleanArray(String data)
  3. zeroOrderBessel(float num)
  4. zeroOrMore(String... patterns)
  5. zeroOut(byte[] array)
  6. zeroPrefix(String str, int width)
  7. zeroPrepend(long num, int digits)
  8. ZeroRemover(String[] a)
  9. zeros(int n)