fft bins

Beep's icon

hello all, I recently finished a really useful patch that analyzes an audio signal using fft~. The problem is that I only need the information contained within a relatively small frequency range, not the whole spectrum, so there are a lot of bins not doing anything and the analysis resolution of the section I need is wastefully low. What I want to do is perform analysis on a specified frequency range using all of the FFT's bins. Is this even possible with FFT in max? Anyone got any ideas? Many thanks.

Jean-Francois Charles's icon
Beep's icon

yeah I am fully aware of this limitation in conventional fft. I was told in a brief conversation I once had with Dr Barry Moon that there was a technique that allowed you to vary the size and so the frequency band covered by each fft bin. He suggested that this technique still meant that the whole frequency spectrum was covered but that you could control the 'density' of the bins. I was pissed at the time so this valuable bit of information might be blurred.

Eric Lyon's icon

You could downsample your input sound and run the analysis at a lower sampling rate, but the same number of bins. That would improve the frequency resolution of each bin. If the frequency band of interest is too high up, you could shift it down to near zero Hz, then downsample and analyze.

Eric

Beep's icon

many thanks for the reply eric, could you elaborate on that a little I'm having a bit of trouble getting my head around it!

Eric Lyon's icon

Quote: brokenman wrote on Wed, 29 November 2006 20:45
----------------------------------------------------
> many thanks for the reply eric, could you elaborate on that a little I'm having a bit of trouble getting my head around it!
----------------------------------------------------

Sure thing. First let's suppose all of the sound you're interested in is between 0Hz to 5000 Hz. Let's also assume you're at a sampling rate of 44100 and using an FFT size of 1024. The analysis fundamental frequency is SR/N or in this case roughly 43.066Hz. (You can think of it this way: the analysis fundamental frequency is the reciprocal of the analysis period. The analysis period is simply the number of samples you're analyzing divided by the sampling rate.) So 43.066Hz is more or less the bandwidth for each bin considered as a filter. Now bring your sampling rate down to 10000 Hz (2 x highest frequency you need to analyze). Your analysis fundamental is now 10000/1024 or about 9.76 Hz. See how that improves your frequency resolution?

Actually though, I was wrong about transposing the spectrum down if you have a limited bandwidth, say are only interested in frequencies from 1000-2000Hz. If you transpose that down to 100-200Hz and divide your sampling rate by 10, you still get the same number of relevant analysis bins, since the resolution of the DFT/FFT is lower in the low range of the spectrum. But the advantage of downsampling listed above is significant. Just run MaxMSP at a lower sampling rate, or inside a downsampled poly~. Disclaimer: I haven't actually tested this on MaxMSP so do let us all know how it works for you.

Eric

Stefan Tiedje's icon
lawrence casserley's icon

Alternatively you could use a linear frequency shifter (eg a Hilbert
Transform based single sideband modulator) to subtract 1000Hz from
the signal - your range is now 0 - 1000Hz. your analysis fundamental
can now be 2000/1024 = 1.953Hz. Also, interpreting the data is easy
because you just have to add 1000Hz to each to get the real frequencies.

Best

L

On 29 Nov 2006, at 21:26, Eric Lyon wrote:

>
> Actually though, I was wrong about transposing the spectrum down if
> you have a limited bandwidth, say are only interested in
> frequencies from 1000-2000Hz. If you transpose that down to
> 100-200Hz and divide your sampling rate by 10, you still get the
> same number of relevant analysis bins, since the resolution of the
> DFT/FFT is lower in the low range of the spectrum. But the
> advantage of downsampling listed above is significant. Just run
> MaxMSP at a lower sampling rate, or inside a downsampled poly~.
> Disclaimer: I haven't actually tested this on MaxMSP so do let us
> all know how it works for you.
>

Lawrence Casserley - lawrence@lcasserley.co.uk
Lawrence Electronic Operations - www.lcasserley.co.uk
Colourscape Music Festivals - www.colourscape.org.uk

Eric Lyon's icon

Quote: lawrence casserley wrote on Thu, 30 November 2006 12:45
----------------------------------------------------
> Alternatively you could use a linear frequency shifter (eg a Hilbert
> Transform based single sideband modulator) to subtract 1000Hz from
> the signal - your range is now 0 - 1000Hz. your analysis fundamental
> can now be 2000/1024 = 1.953Hz. Also, interpreting the data is easy
> because you just have to add 1000Hz to each to get the real frequencies.
>

Nice one, Lawrence. That should about double the available bins for that frequency range.

Eric

Jean-Francois Charles's icon
Beep's icon

Having a good timing resolution is integral to my project which is why I didn't opt for a large fft size. whats the math behind sampling rates and and window length in ms?

Jean-Francois Charles's icon
Owen Green's icon

>From what I heard about wavelets (and that is not much):

Me neither, but I'm not sure this is true:

> moreover the grid is not of a fixed and known shape before the
> analysis

I was fiddling with the CNMAT object earlier this week, and as far as I can tell the nature of the resulting analysis windows is predictable in size and shape (in this case).

Wavelet~ uses the GNU scientific library for the number crunching, and the docs for that explain the output format
http://www.gnu.org/software/gsl//manual/html_node/DWT-in-one-dimension.html

or

So, you're gurranteed that the analysed data is as long as the input data, that you can determine the number of 'bins' in relation to the analysis length, and that the bins will be laid out in a certain way.

What on earth to do with the data still eludes me :)

--
Owen