OptimalFir.RemezImpulse Method

Overload List

#SignatureDescription
1function RemezImpulse(H: TVec; W: TDoubleArray; FilterType: TFilterType; Gain: Double; FS: Double): Boolean;Design an optimal equiripple FIR filter with Parks-McClellan algorithm.
2function RemezImpulse(H: TVec; W: TDoubleArray; Ripple: Double; FilterType: TFilterType; Gain: Double; FS: Double; EnsureOdd: Boolean): Boolean;Design an optimal equiripple FIR filter with Parks-McClellan algorithm.

Overload 1: function RemezImpulse(H: TVec; W: TDoubleArray; FilterType: TFilterType; Gain: Double; FS: Double): Boolean;

Design an optimal equiripple FIR filter with Parks-McClellan algorithm.

#NameTypeDescription
1HTVecsource TVec
2WTDoubleArray
3FilterTypeTFilterType
4GainDoublescalar
5FSDoublescalar

Returns: Boolean

Remarks:

Required length of the filter must be preset by setting H.Length. H vector holds the impulse response on exit.

See Also: SignalUtils.KaiserImpulse, SignalUtils.SavGolayImpulse, OptimalFir.remez, SignalUtils.FirImpulse

Overload 2: function RemezImpulse(H: TVec; W: TDoubleArray; Ripple: Double; FilterType: TFilterType; Gain: Double; FS: Double; EnsureOdd: Boolean): Boolean;

Design an optimal equiripple FIR filter with Parks-McClellan algorithm.

#NameDescription
1HH vector holds the impulse response on exit.
2RippleThe required linear ripple of the passband and 20*Log10(Ripple) is the required attenuation of the stop band.
3FilterTypeParameter defines the filter type.
4GainSpecifies the gain of the passband.
5EnsureOddResulting filter length will be odd (not divisable by 2), if set to true. Default is true.
6FSThe sampling frequency used to normalize transition band edges defined in the W array. Default value for FS is 2.
7WArray which can hold only 2 (highpass/lowpass definition) or 4(bandpass/bandstop definition) parameters.

Returns: Boolean

Remarks:

The resulting impulse response is placed in H. Length of the filter is automatically estimated from the required Ripple and transition bandwidth. Function returns True, if the filter was succesfully designed. This does not guarantee that filter specifications have been meet.

This routine is a simplified version of Remez and can be used to design: Lowpass, bandpass, bandstop, highpass, differentiators and hilbert transformers.

Note:

RemezImpulse routine designes FIR filters about 10-20% shorter than the KaiserImpulse routine.

Examples
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit, OptimalFIR;

procedure TForm1.Button1Click(Sender: TObject);
var H,Response: Vector;
TransBW, Ripple: Double;
begin
    //Assumed sampling frequency = 2
    TransBW := 0.02; //transition bandwidth in Hz.
    Ripple := 0.001;
    //Lowpass filter
    RemezImpulse(H,[0.3,0.3+TransBW],Ripple, ftLowpass);
    //Highpass filter
    //           RemezImpulse(H,[0.3,0.3+TransBW],Ripple, ftHighpass);
    //Bandpass filter
    //           RemezImpulse(H,[0.3,0.3+TransBW, 0.5-TransBW,0.5],Ripple, ftBandpass);
    //Bandstop filter
    //           RemezImpulse(H,[0.3,0.3+TransBW, 0.5-TransBW,0.5],Ripple, ftBandstop);


    //  Type III Hilbert transformer
    //           RemezImpulse(H,[TransBW,1-TransBW],Ripple, ftHilbertIII);

    //  Type IV Hilbert transformer
    //           RemezImpulse(H,[TransBW,1],Ripple, ftHilbertIV);

    //  Type III linear phase differentiator filter
    //           KaiserImpulse(H,[1-TransBW,1],Ripple, ftDifferentiatorIII);
    //           H.Scale(2);  //Scale by sampling frequency

    //  Type IV linear phase differentiator filter
    //           KaiserImpulse( H,[1-TransBW,1],Ripple, ftDifferentiatorIV);
    //           H.Scale(2);  //Scale by sampling frequency

    //  Type III differentiator filter
    //           RemezImpulse(H,[0,1-TransBW],Ripple, ftDifferentiatorIII);
    //           H.Scale(2);  //Scale by sampling frequency

    //  Type IV differentiator filter
    //           RemezImpulse( H,[0,1-TransBW],Ripple, ftDifferentiatorIV);
    //           H.Scale(2);  //Scale by sampling frequency

    // Type III 2x differentiator filter (remez)
    //           RemezImpulse(H,[0,1-TransBW],Ripple, ftDoubleDifferentiatorIII);
    //           H.Scale(Sqr(2));  //Scale by sampling frequency

    // Type IV 2x differentiator filter (remez)
    //           RemezImpulse(H,[0,1-TransBW],Ripple, ftDoubleDifferentiatorIV);
    //           H.Scale(Sqr(2));  //Scale by sampling frequency

    // Type III integrator  filter (remez).';
    //           RemezImpulse(H,[TransBW,1-TransBW],Ripple, ftIntegratorIII);
    //           H.Scale(1/2);  //Scale by sampling frequency

    // Type IV integrator  filter (remez).';
    //           RemezImpulse(H,[TransBW,1],Ripple, ftIntegratorIV);
    //           H.Scale(1/2);  //Scale by sampling frequency

    //  Type III 2x integrator  filter (remez).';
    //           RemezImpulse(H,[TransBW,1-TransBW],Ripple, ftDoubleIntegratorIII);
    //           H.Scale(Sqr(1/2));  //Scale by sampling frequency

    //  Type IV 2x integrator  filter (remez).';
    //           RemezImpulse(H,[TransBW,1],Ripple, ftDoubleIntegratorIV);
    //           H.Scale(Sqr(1/2));  //Scale by sampling frequency

    FrequencyResponse(h,nil,Response);
    DrawIt(Response);
end;
See Also: OptimalFir.remez