سؤال

I have written fft of 2048 samples of a signal and the result is 1025 frequency values in C.(discarding the other 1025 samples(i.e. >n/2 samples)).

Now I have to take 32 evenly spaced logarithmic bins out of these frequency values that too between 318 to 2000hz.

Any assistance would be appreciated.

هل كانت مفيدة؟

المحلول

This question tells you how to figure out what frequency each result of your FFT represents. Then, figure out which frequencies go into which bin. Then, within each bin, combine the FFT results for the frequencies in that bin. (Often people are interested in the energy represented by a frequency, as represented by the magnitude of the FFT results for that frequency. If so, then compute the magnitude of each result in the bin and add those magnitudes to get a total for the bin.)

If you have n bins spaced logarithmically where the first bin starts at frequency A and the last bin ends at frequency B, then bin i (numbered from 0 to n-1) starts at frequency exp((ln(B)-ln(A))*i/n)*A. That formula:

  • Takes logarithms of B and A.
  • Takes the distance between the logarithms (ln(B)-ln(A)).
  • Divides that distance into intervals (multiplies by i/n for the ith interval).
  • Converts that distance from a logarithm to a frequency (applies exp).
  • Multiplies by A to set the start point (undoes the subtraction of ln(A)).

So this formula gives you the start and end point of each bin, and you can use that to divide up your bins. If you want to start the last bin at 2000 Hz instead of ending it at 2000 Hz or you want to center the start and end bins around 318 Hz and 2000 Hz instead of terminating them exactly on those frequencies, you will have to adjust the formula.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top