Distribute the values from fft() logarithmically - not plotting

6 views (last 30 days)
Hi all,
When I use fft(signal) on a music signal, I get linearly spaced power spectrum of length(signal) representing frequencies up to 44100hz. I want to distribute them on a log scale. If I semilogx(fft(abs(signal))) I can see what I want, but I want to be able to work with the values!
I think the best way to explain exactly what I want to do is explain what I want to achieve on a slightly higher level:
I want to sum the differences on the power spectrum of a music signal from one window to another. However for later purposes I want the (say) 20 frequency bins to be spaced logarithmically up to only 20000Hz.
I hope that explains my problem, please let me know if I should provide more detail. I have looked on google and had a search of this forum. Closest was this question with no answer http://www.mathworks.com.au/matlabcentral/answers/27211-audio-processing
I have:
binEdges = logspace(log10(20), log10(20000), numBins+1);
which defines the bins, but then I don't know how to test for the frequencies in the returned fft array.
Thanks very much for any help!

Answers (3)

Conrad
Conrad on 13 Oct 2012
did the fourier transform 'myself':
N=441; % length of sample
numBins=20;
F_min = 20;
F_max = 20000;
f_frac = logspace( log10(F_min/Fs), log10(F_max/Fs), numBins);
W = exp(-1j * (0:N*2-1)' * 2 * pi * f_frac );
logbinned = sample * W
And this seems to go fine! I end up with a numBins long vector with the magnitudes of the frequency bins. (I think?!) It looks a bit different when plotted to semilogx(abs(fft(sample))) but I guess that's just because they can end up being computed different. Speed is good enough for me at the moment.
Does anyone see any problems with this?

Honglei Chen
Honglei Chen on 13 Oct 2012
If your frequency bins falls on frequency bins of an FFT, you can try Goertzel algorithm
  1 Comment
Conrad
Conrad on 13 Oct 2012
I guess the problem here is that it will calculate the magnitudes at the frequencies, rather than across a bin? Unless I'm understanding this wrong?

Sign in to comment.


Walter Roberson
Walter Roberson on 13 Oct 2012
Possibly histc() passing binEdges as the second argument
  1 Comment
Conrad
Conrad on 13 Oct 2012
my old solution involved this. But that doesn't help too much as the fft has still been calculated in a linear space, and trying to map it afterward results in a loss of data or a necessity for too many samples

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!