5
$\begingroup$

Is there any way to take advantage of the frequency domain to make a clean/nice sampling rate reduction effect ? and how ?

Basically, deducted from my tests:

  • if I set to 0 the magnitude uppon a certain threshold I only get a filter(quite obvious...)
  • if I set to 0 one sample over 2 before the buffer transfrom it's not at all some freq domain processing ( if I do the same on the transformed buffers it's also a filter)

Is it possible to make SR reduction in the freq domain ? (actually I have some overlapped phase and magnitude arrays...)

$\endgroup$
4
$\begingroup$

If you multiply a frequency spectrum by a low-pass filter frequency response, this could leave an area in the resulting spectrum around Fs/2 zero, or nearly so, depending on the filter response. Don't use a low-pass filter with a rectangular frequency response by just zeroing FFT bins, as this frequency response has severe ripples in both the stop band and pass band.

When working with the frequency response from a DFT/FFT, after you have filtered a sufficient number of bins around Fs/2 to zero, or nearly so (down to your desired noise level), you can shorten the FFT vector by removing those bins symmetrically around Fs/2. Given a shorter complex vector in the frequency domain, an IFFT of this vector will produce a shorter vector in the time domain, equivalent to a lower sample rate over the same time period. The lower the cutoff of the low-pass filter, the shorter the truncated vectors can be, the more you can lower the sample rate.

If the frequency response is already sufficiently low-pass, or you don't care about severe ripple in the resulting frequency response, you can just reduce the size of the FFT vector and IFFT to reduce the sample rate.

$\endgroup$
  • $\begingroup$ ok I see, so basically If I have a 512 samples fft: (1) I transform, (2) I set the half upper part of the bins to 0, (3) I make a 256 samples ifft instead of the expected 512 samples inverse transform. $\endgroup$ – az01 Oct 10 '11 at 23:45
  • $\begingroup$ Set the bins around Fs/2 to zero, e.g. bins [128..383] out of [0..511]. Is that what you mean by "upper part"? That will halve the sample rate. But pre-filtering with a suitable low-pass function will make this sample rate reduction less noisy. $\endgroup$ – hotpaw2 Oct 10 '11 at 23:49
  • $\begingroup$ I want to note that this approach is not equivalent to the typical time-domain implementation of a lowpass filter followed by a downsampler. The exactly equivalent (up to the limits of numerical precision) operation is described in the other answer, where you sum in the residual stopband energy that aliases into the passband after downsampling. It seems that the truncation approach described here would be equivalent to cascading your proposed lowpass filter with a brick-wall filter that eliminates the frequency bins that are being thrown out. I think that could cause time-domain ringing. $\endgroup$ – Jason R Oct 11 '11 at 0:49
  • $\begingroup$ @Jason : Yes, this will cause ringing if the brick wall filter is around or lower than the transition frequency of the low pass filter. But if the stop band attenuation is low enough, the values that should have been "stack-and-added" will be in the noise floor. $\endgroup$ – hotpaw2 Oct 11 '11 at 2:52
  • $\begingroup$ @hotpaw2: The problem with this approach (as I understand it) is to reduce the time-aliasing distortion that is introduced when manipulating the FFT bins (by e.g. zeroing out some of the bins). The implied circular convolution can lead to a noisy result. Proper zero-padding in the time-domain (before FFT) and careful smoothing of the FFT bins may lead to less noisy result. $\endgroup$ – niaren Oct 11 '11 at 6:13
7
$\begingroup$

Yes, you can do what you're looking for. Think about what happens in the frequency domain when you downsample a signal in the time domain: the spectrum "folds over" on top of itself and sums, the well-known aliasing effect. If your signal is already sufficiently bandlimited, then you can obtain the downsampled time-domain signal without computing the samples that you would subsequently throw out.

Given a signal $x[n], n = 0, 1, \ldots , N-1 $ that has DFT $X[k], k = 0, 1, \ldots , N-1$, a new signal $x_d[n]$ that is $x[n]$ decimated by a factor $D$ can be generated by:

$$ X_d[k'] = \sum_{d=0}^{D-1} X[k' + d\frac{N}{D}], k' = 0, 1, \ldots , \frac{N}{D} - 1 $$

$$ x_d[n] = IDFT(X_d[k']) $$

The inverse DFT (and subsequently $x_d[n]$) is of length $\frac{N}{D}$. This method is sometimes referred to as "stack and add".

$\endgroup$
  • $\begingroup$ What is the length of Xd[k] here?... Shouldnt it be of length N/D, and so therefore cannot have k as an index? (Since k is from 0 to N-1)? $\endgroup$ – Spacey Oct 14 '11 at 16:10
  • $\begingroup$ Good catch of the sloppy notation. I fixed it. $\endgroup$ – Jason R Oct 14 '11 at 16:36
  • $\begingroup$ no problem - however the "k" is supposed to be a "k'" in the new equation too. :-) $\endgroup$ – Spacey Oct 14 '11 at 17:17
  • $\begingroup$ We should be good now. $\endgroup$ – Jason R Oct 14 '11 at 18:25

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.