This paper gives a spectrum analyzer using the multirate filter bank technique. The basic idea of the paper is that STFT can be interpretated as a uniform DFT filter bank. But the baseband filter of DFT filter bank has strong sidelobes. So it tries to design a prototype filter with better passband and stopband response by increasing the prototype filter length.

The basic implementation diagram, as given by the paper, is depicted as follows

enter image description here

Based on the diagram, I try to simulate using pure sinusoid. The Matlab code is

 close all;
 %% filter design
 fs = 1;
 M = 1000;
 Noverlap = M*0.5;
 D = (M-Noverlap);
 N = M*100-1;
 protoFilterCutOff = fs/(2*M);
 protoFilter = fir1(N,protoFilterCutOff/(fs/2),'low');
 %% check filter response
 hold on
 polyFilter = zeros((N+1)/M,M);
 for k = 1:M
     polyFilter(:,k) = protoFilter(k:M:end);

 %% generate test signal
x = zeros(10^6,1);
t = [0:length(x)-1]/fs;
f1 = 0.399;
f2 = 0.4006;
x = sin(2*pi*f1*t) + 0*sin(2*pi*f2*t) + 0*randn(size(t));

%% filter
segNum = length(x(M:D:end));
y = zeros(segNum,M);
for k = 1:M
   y(:,k) = M/D*D*filter(upsample(polyFilter(:,k),M/D),1,x(M-k+1:D:segNum*D+M-k)');    
P = zeros(size(y));
for k = 1:segNum
   P(k,:) = abs(fft(flipud(y(k,:)))/M).^2;
P = P(:,1:M/2);
axis xy; axis tight; colormap('jet'); view(0,90);  

The result of the above code is

enter image description here

enter image description here

It shows the spectrogram with multirate filter bank is worse than the traditional spectrogram (obtained with Matlab function "spectrogram").

Besides, the magnitude of the two results are also different. With the first being 17dB and the second being 27dB.

What may be the problem with my code? Hope you can help.

Besides, how do you comment on this method since it increases computation load a lot?


1 Answer 1


The reason the spectrogram looks so "clean" in this case is because the waveform used is circularly continuous over the $M$ samples. Below is a plot of the first 1000 samples of the test waveform in the time domain, notice if we circularly continued, the very first samples are the exact samples we would expect in the next block.

Time domain

The FFT (and the continuous time Fourier Transform as well) over a fixed time interval will produce the same result for the non-zero samples as the same waveform if it was continued back to back out to positive and negative infinity. Thus when the waveform is not circularly continuous the effect is equivalent to a discontinuity at the transition in the time domain, which results in many other frequency components: what we refer to as "spectral leakage". Below shows the result of the FFT for the time domain waveform above:

fft result

The spectrogram as the OP has used it (with a rectangular window) is this plot repeated as we move through the waveform in time with the same block length, overlapping the blocks by 50%. No matter what start and stop we use for this given waveform, it will be circularly continuous over the 1000 samples and therefore every block processed will have a magnitude result as I have shown in the plot above.

If we, for example, changed M to be 1200 instead of 1000- we would then see the more general case of spectral leakage due to using a rectangular window:

fft result with larger M

Increasing the FFT length alone is not the best solution for reducing sidelobes, since the sidelobes of the rectangular window go down as the inverse of frequency offset. When the concern is with dynamic range, improved windows are used where frequency resolution is traded for dynamic range or sidelobe suppression. The OP has used a Hamming window in the construction of the filter bank, which will result in an improved performance over the rectangular window (except in the narrow cases where the waveform is circularly continuous, which cannot be counted on when we are using the spectrogram to evaluate an unknown signal). The Kaiser window is an excellent choice for this application, superior to the Hamming window, and it has a parameter $\beta$ that can be adjusted to the desired suppression. With that, the length can then be increased to achieve both the frequency resolution and sidelobe suppression desired.

Below demonstrates windowing of the OP's test waveform over the original 1000 samples, using the Hamming window (as used in the OP's filterbank construction) to the Kaiser window (using $\beta=18$). The Kaiser window has more loss in the mainlobe, and a wider mainlobe that we can't make out at this scale, but in return a significant increase in sidelobe suppression (dynamic range). Note from the vertical scale compared to the plot with the rectangular window when we don't have the convenience of circular continuity how much of a significant improvement we get even with using the Hamming window. Bottom line- if sidelobes are a concern, we should always window.

Hamming vs Kaiser

  • $\begingroup$ Thank for your answer. Follow your idea, I understand the reason for the difference between the spectrogram results. Since the traditional spectrogram uses a rectangular window, there is no spectral leakage. The filter bank implementation, though has better sidelobe performance, still suffers spectral leakage. $\endgroup$
    – ecook
    Commented Dec 17, 2022 at 13:34
  • $\begingroup$ As for the adavantages of using filter bank implementation of STFT, I think it can achieve better frequency resolution. But its disadvantages are larger computation, transient response in each of the polyphase filter output (as can be seen from the spectrogram) and lower time resolution. So my conclusion is that this method can only be used in limited applications. $\endgroup$
    – ecook
    Commented Dec 17, 2022 at 13:38
  • $\begingroup$ @ecook, not quite. There is significant detrimental spectral leakage with a rectangular window in all but this unrealistic case you provided where the signal is circularly continuous. But you can use a window (and should for the reasons you see) in the spectrogram as well. Also the Filter Bank structure evolves nicely into forms using the IFFT so is quite efficient. $\endgroup$ Commented Dec 17, 2022 at 13:40
  • $\begingroup$ (My second plot is showing (the worst) spectral leakage when I changed your M from 1000 to 1200 samples--- in general an arbitrary waveform will not fit so nicely as your test case within your sampling interval such that it stops right where it starts--- you have to assume in general the spectral leakage for the rectangular window will be really bad) $\endgroup$ Commented Dec 17, 2022 at 13:47
  • $\begingroup$ Yes, I see. The key point here is the frequency of the test signal lies exactly on one of the frequency bin of the FFT. For other frequencies, the spectral leakage is rather severe, as your figure shows. As for the filter bank implementation, I don't think it is efficient. Given such small performance improvement, for N=100M, the filtering computation is 100 times that of traditional STFT. (Maybe my code can be optimized so that it can compute faster?) $\endgroup$
    – ecook
    Commented Dec 17, 2022 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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