# 4-phase FIR LPF in MATLAB

I'm trying to create a low pass FIR filter using the coefficients I found in ITU 1770-3 on page 18. This is the last piece of the puzzle for an audio loudness metering algorithm I'm working on. I'm not super familiar with digital filters in general, but so far I've been able to create them using numerator and denominator coefficients. From there I can use filter(b,a,input) to process the audio.

But I'm not quite sure what to do with these 4 sets of coefficients. Am I supposed to get a set of numerators/denominators out of them somehow? What can I do to create an LPF out of these coefficients?

UPDATE: With some sage advice from @DanBoschen I have modeled the filter. Here is the response chart: • Hi! It would be super well if you could also upload a sufficient amount of MATLAB / OCTAVE snippet... – Fat32 Sep 27 '18 at 20:58
• Hi @Fat32, the rest of my MATLAB script is kind of unrelated to this filter so I thought it might just add clutter. So far the script basically just reads an audio file and measures ungated and gated loudness. This LPF here is supposed to be the pre-filter for the true peak measurement portion, which I'm just starting. All I have done so far to create this LPF is store these coefficients in vectors p0, p1, p2, and p3 for each phase listed here. Just need to figure out what to do next to create a filter and then I can put that in with the rest of my script. – Avid Pro Tool Sep 27 '18 at 21:10
• Yes of course the whole code would indeed be a clutter, but you can isolate the rest of it as an emulated interface and provide only the portion related with your problem. That's what the snippet is ;-) – Fat32 Sep 27 '18 at 21:30
• Not sure what you mean by an emulated interface, forgive me I'm pretty new at this. Unfortunately, I don't really have any code to show that's related to this problem, other than the 4 vectors storing the coefficients listed above. I figured if I typed out "p0= [0.0017089843750 0.0109863281250....]; p1=[....]..." that wouldn't add much to it. I think there's just a broader concept about digital filters I'm missing here and can't seem to find the answer online. – Avid Pro Tool Sep 27 '18 at 22:06

These appear to be the coefficients of a linear phase (due to the even symmetry of the coefficients) 48 tap low pass filter arranged in polyphase structure and given the words interpolator in the title, for purpose of upsampling the input signal by a factor of 4.

I have detailed the approach to designing a polyphase interpolator from the FIR coefficients in this post: How to implement Polyphase filter? , with the image copied below that specifically shows how a traditional FIR structure is mapped to a polyphase structure for interpolation using to row to column mappings of the coefficients: In the case of this specific 48 tap implementation in this post given as four 12 tap polyphase filters, the signal would first be upsampled with a zero insert just as done in the diagram I posted above (so insert 3 zero's in between each input sample resulting in a 4x increase in the sample rate). The low pass filter is designed to pass the signal of interest and reject the images that the zero-insert creates. (I have more details on that specifically but that's more detail than necessary to answer the question so will lean slightly toward brevity--- if anyone wants that added, please indicate in the comments). In this case given the completed design, a 48 tap filter was determined to be sufficient by the designer, and this was then mapped into four 12 tap poly-phase filter structures (instead of four 2 tap filters in my image above) as follows:

For FIR filter with taps h, h, h.... h

This is mapped into four poly-phase filters as:

Filter 1: h h h h ... h

Filter 2: h h h h .... h

Filter 3: h h h h .... h

Filter 4: h h h h .... h

The columns given by the OP are the taps for each of the four filters as detailed above. To view the filter response, read the coefficients back in order from each row as listed and then can use the freqz command available in Matlab, Octave or Python (SciPy) to view the response.

• Thank you very much for your detailed response! Trying to catch up, this is great info. So far I am able to arrange these coefficients in a single vector (I've called it "p"), and the freqz() function will show me something that looks like a LPF. Now I'm trying to figure out how to run my input signal through that filter. The input signal came from a .wav file using the audioread() function. I've tried filter(p,input) and filter(p,input,1/192000) (since it'll be at 192kHz) but I get an error saying the first two arguments must be vectors. I think it's expecting numerator/denominator vectors. – Avid Pro Tool Sep 27 '18 at 23:28
• use filter(p, 1, input) – Dan Boschen Sep 27 '18 at 23:29
• The filter assumes a rate that is four times faster than the given input, so to model the actual implementation with the interpolation, first do the zero insert by first adding three zeros in between every (do you know what I mean by that?) and then follow that with filter(p, 1, newInput) – Dan Boschen Sep 27 '18 at 23:31
• The polyphase structure is just an efficient way to implement the same thing, but the above approach will match your inputs and outputs exactly so is a precise model. Can you add the frequency response as an update to the bottom of your question? (Just would like to see what the filter is and didn't want to transcribe all your coefficients). – Dan Boschen Sep 27 '18 at 23:32
• yes I've used the upsample() function for that. This filter was the last missing piece, thank you for taking the time to help me out! – Avid Pro Tool Sep 27 '18 at 23:33