Tuesday, March 21, 2017

matlab - Distribution of energy in frequency bands



On my wav-file (music), I do a short-time Fourier transform (STFT). I have spectrum, which spans from $0\textrm{ Hz}$ to $f_s/2$. I took out the range between $1$ and $1000\textrm{ Hz}$, which I divided in $3$ frequency bands. My STFT is performed every $50\textrm{ ms}$ so I can see the changes over the time.


At this point I am not quite sure, if i am right or wrong. I want to get the overall performance of my frequency band every $50\textrm{ ms}$. Which means, I get $3$ values every $50\textrm{ ms}$ because I have $3$ frequency bands.


I think I need to calculate the bins of my frequency band to do that. Any idea? Btw, my code is in MATLAB.




I see. In my code, i did a full stft, for which i have defined a frequency vector. It looks like this:


f=0:1:fftlen-1;
f=f/(fftlen-1)*fs;

fftlen is 4096 and fs is 44100. I have written it so, that i took out 0-1000Hz and divided it up in 3 frequency bands, which for exmaple is a


lowband=(1:200); 


and then defined a frequency vector for my lowband, otherwise it wouldn't have worked.(Maybe there is another simpler solution...) which looks like this:


fL = 1:1:200;

I am not sure if i can see the connection behind this, but fs/fftlen = 10.76660156.... This must mean that 19th bin is about 204.56..., which is close to my predefined frequency vector (200Hz) of my lower band. I got this value by doing 200/(44100/4096), which is 18.5759.. by rounding it off, the 19th bin. Afterwards i multiplied 19 with 10.7666..., which is 204.56..


If i am right then i will simply take all values from the first bin to the 18th bin. And make a arithmetical mean of it. Is my calculation then correct?




No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...