0
$\begingroup$

Suppose I want to perform Spectral shaping on a signal, i.e, modify the gains in a band of frequencies. Would there be any difference if I do that using the following two methods? -

  1. Use a band pass filter to apply the gain in the band.
  2. Calculate the bin numbers corresponding to the band, and apply the gain in those bins.

I'm interested to know if the second method is a valid approach, if not, why is it discouraged?

$\endgroup$
  • $\begingroup$ sounds like 2. is an FFT. is your entire signal being read into the FFT or are you putting blocks of your signal into the FFT? $\endgroup$ – robert bristow-johnson Apr 30 at 5:26
  • $\begingroup$ Yes, 2. is an FFT. I will be putting blocks of the signal into the FFT. $\endgroup$ – Naveen Apr 30 at 5:31
2
$\begingroup$

The second method is the "Frequency Sampling" method of filter design, where the filter coefficients (the impulse response) are determined using the Inverse Discrete Fourier Transform of the sampled frequency response desired. It is extremely simple to implement but for most cases it is a poor choice as the result will be an exact match at the frequency bins selected, but excessive ripple in between (compared to other filter design algorithms such as Windowing, or Parks-McLellan and Least-Squares). Therefore much longer filter lengths are required over those optimized approaches mentioned.

The Frequency Sampling approach can be compared to (preferred) windowing design approaches in that for windowing approaches, the desired impulse response is determined from the Inverse Discrete Time Fourier Transform (IDTFT) in contrast to the Inverse Discrete Fourier Transform (IDFT) for Frequency Sampling. The IDTFT has a time domain that extends to infinity, while the IDFT is time limited and thus an aliasing of the coefficient values results for filters with long impulse responses (time aliasing when the desired frequency response is under-sampled).

Below compares the DTFT and DFT for an arbitrary waveform of the same time duration for non-zero values, but shows in this case that the DTFT has specific zeros assumed for time extending to infinity (and is therefore aperiodic), and results in a continuous function in frequency (we can approximate the DTFT by zero-padding the FFT for example). In contrast the DFT is time limited to N samples; I show it as periodic as we could get the same result if we continued time to infinity but repeated the waveform in each time slot (similar to the Fourier Series Expansion, where the time domain waveform from 0 to T is reconstructed from integer multiples of frequency harmonics--- if you continued the waveform beyond the time 0 to T, the waveform would be periodic in time). The key point is we see that the DFT is sampled in frequency while the DTFT is continuous. Sampling in one domain causes aliasing in the other when the number of samples over the duration is not sufficient. This is what drives a longer filter length than what we could achieve with the other approaches to meet similar performance.

DTFT

DFT

For additional information on windowing vs frequency sampling, see this post:

Difference between frequency sampling and windowing method

My go-to approach for designing bandpass digital filters prototypes would be the least-squares (firls in Matlab/Octave, scipy.signal.firls in Python) and Parks-McClellan (firpm in Matlab, remez in Octave, scipy.signal.remez in Python) algorithms.

Matt L had great comments at this post FIR Filter design: Window vs Parks-McClellan and Least-Squares on the continued merits of Windowing design approaches when resources for filter computation are limited (such as possible beamforming applications where the coefficients may need to be computed on the fly).

$\endgroup$
2
$\begingroup$

then you'll be doing either "Overlap-add" (OLA) or "Overlap-save" (OLS) which is sometimes more clearly called "Overlap-scrap". you need to read up about this.

then simply "apply[ing] gain in those bins" is multiplication in the frequency domain, which means convolution in the time domain. if your frequency domain function is a rectangle function (some number for "those bins" and another number, like 1, for the other bins). then you need to compute the impulse response that goes with it and make sure that FIR impulse response is not too long for your OLA or OLS. do you have a good book that describes OLA or OLS?

but a bandpass filter in the time-domain (your option 1.) is simple and can be implemented simply. maybe more difficult to design your IIR or FIR bandpass filter.

$\endgroup$
  • $\begingroup$ I don't currently have a book that describes them. Would you happen to have any recommendations, Robert? $\endgroup$ – Naveen Apr 30 at 6:16
  • 1
    $\begingroup$ @Naveen the wikipedia article on overlap-add is pretty OK $\endgroup$ – Marcus Müller Apr 30 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.