Distribute the values from fft() logarithmically - not plotting

조회 수: 10 (최근 30일)
Conrad
Conrad 2012년 10월 12일
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!

답변 (3개)

Conrad
Conrad 2012년 10월 13일
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 2012년 10월 13일
If your frequency bins falls on frequency bins of an FFT, you can try Goertzel algorithm
  댓글 수: 1
Conrad
Conrad 2012년 10월 13일
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?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2012년 10월 13일
Possibly histc() passing binEdges as the second argument
  댓글 수: 1
Conrad
Conrad 2012년 10월 13일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by