# FIR filter design and implementation - sample rate and number of taps

I have been designing and using IIR filters to process audio for a while now but want to design some FIR filters for delay equalization. I have done some preliminary work using the following approach:

1. I start with a desired "group delay EQ" curve. This starts at zero, and then has increasing delay at higher (audio) frequencies.

2. I calculate the corresponding phase lag by integrating, using the definition of group delay. This is still on the audio log-frequency grid.

3. In the next step, I interpolate the phase onto the equal-linear-spacing frequency grid that will be used for the discrete transform processing. I use 32768 samples for this step.

4. I then generate the real and imaginary components of the complex number that results for this phase angle, with the magnitude of the response equal to 1.0. I make sure that H(k) = H*(N-k).

5. I take the inverse DFT of the real and imaginary components to transform the response to the time domain. Although the output produces both a real and an imaginary component the imaginary component is essentially zero. The impulse is present in both short positive and negative times (at the beginning and end of the data set) but only spans about 20% of the full data set.

6. I set the imaginary component values all to zero. I manipulate the real component of the time domain response (the impulse), shifting it "to the right" to move the part of the impulse that is at small negative times (at the "end") to positive time. I then apply a rectangular window to the data, setting everything outside the window to zero. From what I understand, the remaining non-zero values are the FIR filter coefficients.

7. To find out what the filter response will look like I perform the forward DFT on the shifted, windowed impulse to bring the data back into the frequency domain. I then calculate and plot the filter magnitude (SPL), the phase, and finally the group delay.

The above procedure seems to give me the FIR filter response that I want to achieve. I can see the tradeoffs in the frequency domain when I set fewer or more taps to zero. So my approach seems to be working. Now on to the implementation and questions:

Because I am new to FIR filtering, I am confused about the data sample rate and number of coefficients calculated above and how that factors in when I want to implement the FIR filter. I may either write my own code or use some existing code or package to perform the correlation between filter and audio data stream.

Questions:

A. How will the number of bins that I use in the inverse DFT (step 5 above) influence the resulting filter? Will using more bins help to fit sharper features and vice versa? Is the number of bins usually optimized when designing a filter to keep the calculation overhead low when the filter is implemented?

B. I performed all the steps above assuming a sample rate of 48kHz. The only time that the sample rate came into play was when I calculated the frequencies of each bin (e.g., df) for the iDFT and DFT calculations. Given my final set of non-zero filter coefficients (obtained in step 6 above) is the filter simply (naively) calculated as y(n) = SUM_over_m[h(m)*x(n-m)] where 'x' is a sample in my audio data stream at the same 48kHz sample rate? That seems too easy/simple... (I understand that a practical FIR filter implementation would not carry out the calculations in this way, but would use FFT, etc.)

What really puzzles me is this: any number of coefficients can be set to zero to approximate the filter, yet you may vary the number of bins in the iDFT/DFT operations (change resolution) and then truncate the resulting filters to the same number of taps. Is it correct that the coefficients would be different even if they are the same in number, and that the coefficient values are the only thing that is "encoding" the sample rate used in the filter design and the resolution that was chosen???