# Implementation of halfband pass filter

I need to interpolate a complex valued bandlimited periodic function using local interpolation.

I can have the signal sampled at any frequency I want over at equispace intervals.

I am aware that for bandlimited periodic functions the best interpolation method is global interpolation (FFT).

However, for this project I need to use local interpolation. I managed to perform the interpolation using Lagrange polynomials of order 10 but I require an oversampling of 2 to achieve the desired results. My goal is to reduce oversampling to any extend even if I need a longer interpolator.

I recently read as much as I could about FIR filters but somethings are not clear to me.

Since the interpolation factor is of the order of 2, I am planning to use a halfband pass interpolator (many books say this is the best since one gets a cheap interpolator due to the zeros in the impulse response).

My questions are:

• How do I design a halfband pass filter? In Matlab there are nice functions in the dsp package that allow directly to construct such filters, unfortunately I have to do this implementation in C. I searched and I found that the remez() function from Octave to compute the coefficients is available in C and is the one I am planning to use.
Designing a low pass filter with the Parks-Mclellan algorithm is it by default a halfband pass filter (provided I set up correctly the frequency bands) or do I have to enforce the time domain constraints?

• Regarding the linear phase of the FIR filter, what I understand is that my signal will be shifted by some samples, how do I compensate to remove the shifting? What comes to my mind is to apply the corresponding shifting on the opposite direction, is this necessary?

• If you could provide an working example of an interpolation of a periodic function (e.g. sum of sines) using a FIR I would be very grateful.
• Reading more about this topic, I found out that for my project I require zero-phase filters since this is an "offline" application. Commented May 23, 2018 at 19:00
• It's an advantage of offline signal processing that non-causal filters can be used, and hence, zero-phase filtering is possible. It's not a necessity. Commented Apr 27, 2019 at 17:08
• and no, "global interpolation (FFT)" (what's that?) is not inherently the "best" option; I think you might be thinking of padding the FFT of the original signal with zeros and then transforming it back. That has very serious problems! Commented Apr 27, 2019 at 17:11
• For remez half-band filters that has almost half of the coefficients zero-valued, see my answer to FIR Filter design: Window vs Parks-McClellan and Least-Squares. Commented Apr 27, 2019 at 17:57
• @MarcusMüller, when the signal is periodic, bandlimited, and you have a complete period, what kind of interpolation is better than global interpolation using trigonometric polynomials and implemented with the FFT? What are the problems you refer to? Commented Apr 29, 2019 at 6:29

The impulse response and frequency response of a length N zero-phase FIR lowpass filter can be designed using the Remez exchange algorithm.

N = 11; % filter length - must be odd

b = [0 0.1 0.2 0.5]*2; % band edges

M = [1 1 0 0 ]; % desired band values

h = remez(N-1,b,M); % Remez multiple exchange design

The impulse response h is returned in linear-phase form, so it must be left-shifted (N-1)/2 = 5 samples to make it zero-phase. Answer taken from https://www.researchgate.net/post/How_can_I_design_a_null_phase_FIR_filter.

I implemented this solution some time ago and still works very well in my code.

• I do not understand why this answer is marked as not useful. It solved the question and works very well. Commented Apr 29, 2019 at 6:07