Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function RemezImpulse(H: TVec; W: TDoubleArray; FilterType: TFilterType; Gain: Double; FS: Double): Boolean; | Design an optimal equiripple FIR filter with Parks-McClellan algorithm. |
| 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. |
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.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | H | TVec | source TVec |
| 2 | W | TDoubleArray | |
| 3 | FilterType | TFilterType | |
| 4 | Gain | Double | scalar |
| 5 | FS | Double | scalar |
Returns: Boolean
Required length of the filter must be preset by setting H.Length. H vector holds the impulse response on exit.
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.
| # | Name | Description |
|---|---|---|
| 1 | H | H vector holds the impulse response on exit. |
| 2 | Ripple | The required linear ripple of the passband and 20*Log10(Ripple) is the required attenuation of the stop band. |
| 3 | FilterType | Parameter defines the filter type. |
| 4 | Gain | Specifies the gain of the passband. |
| 5 | EnsureOdd | Resulting filter length will be odd (not divisable by 2), if set to true. Default is true. |
| 6 | FS | The sampling frequency used to normalize transition band edges defined in the W array. Default value for FS is 2. |
| 7 | W | Array which can hold only 2 (highpass/lowpass definition) or 4(bandpass/bandstop definition) parameters. |
Returns: Boolean
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.
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;