Declaration: CalcSincHPKernel(KLength, Windowing: integer; CutOffFQ: double; var FilterKernel: TDoubleArray): integer;
Calculates the coefficients of a highpass sinc filter. The coefficients which are returned in the array FilterKernel can be used by the functions KFilterSpectra and KFilterSpectraEdgeSpecial to apply a highpass filter to a signal. The open array FilterKernel is automatically resized to contain KLength elements.

The parameter KLength determines the roll-off of the filter. As a rule of thumb the transition bandwidth BW can be estimated by

BW = 4/KLength.

The parameter CutOffFQ controls the cutoff frequency, which is specified as a fraction of the sampling rate. Thus the CutOffFQ parameter may assume values between 0 and 0.500. The following figure shows the influence of the kernel length on the roll-off at a fixed cutoff frequency (left diagram, fc = 0.2) and the roll-off of different cutoff frequencies using the same kernel length (right diagram, KLength = 41).

The parameter Windowing determines the type of windowing applied to the filter kernel. Currently the following windowing modes are supported:

0 ... no windowing
1 ... Hamming window
2 ... Blackman window

The function returns the following error codes:

 0 ... everything is ok
-1 ... KLength must be odd
-2 ... KLength is out of range (valid: 3 to 999)
-3 ... invalid Windowing
-4 ... cutoff frequency is out of range

Hint: Please note that the computation time of a filter is directly proportional to the length of the filter kernel.

Last Update: 2018-Apr-12