cheers,

oli

]]>_

johan

>

> feeling a bit braindead this morning. can anyone explain to me how

> to convert the left output of cartopol to linear amplitude in the

> range 0-1 for a given FFT size?

hi oli,

for an input signal with amplitude 1.0 and a frequency that lies on

the centre of an FFT bin (has an integral number of cycles over N

input samples), the magnitude of the corresponding FFT bin will be N/

2 (where N is the FFT size).

this is true for a real FFT (with real input signal) using a

rectangular window.

(exeptions are the first and last bin of an FFT frame).

as you might know, the selected window function has a big impact on

this scaling factor,

where e.g. a hanning window would be something close to N/4.

but in the end, i think, the choice of a scaling factor depends on

what you want to do with the data.

hth,

volker.

i had seen the text in tutorial 26, but i’m struggling to understand it:

>(FFT size / (sqrt(sum of points in the window/hop size))

i am confused by “sum of points in the window”. does that mean the sum of all the magnitude values?

how does this number 362 come about:

“So, when using a 512-point FFT with a square window with an overlap of 2, the maximum possible amplitude value will be roughly 362″

FYI, i am building a spectrum analyser. I would like to show the amplitude of the bins on a log scale (eventually)

cheers,

oli

]]>> i had seen the text in tutorial 26, but i’m struggling to understand it:

>

> >(FFT size / (sqrt(sum of points in the window/hop size))

>

> i am confused by “sum of points in the window”. does that mean the sum of all the magnitude values?

>

> how does this number 362 come about:

>

> “So, when using a 512-point FFT with a square window with an overlap of 2, the maximum possible amplitude value will be roughly 362″

sum of points in the window for a square window of 512 points is equal to 512 (every points at 1). So this gives you this:

512/sqrt(512/256) = 362.something

Best

]]>so what about for the different windows? I looked on wikipedia for constants to work out the sum of points in the window, but so far my figures don’t match the ones in tutorial 26, arg!

i am using a hanning window, but i’d like to understand how to do it for other windows too

oli

]]>—————————————————-

> thanks ej,

>

> so what about for the different windows? I looked on wikipedia for constants to work out the sum of points in the window, but so far my figures don’t match the ones in tutorial 26, arg!

>

> i am using a hanning window, but i’d like to understand how to do it for other windows too

Hmmmm. This is a difficult one. I wrote the below based on the old pfft~, but it seems to have changed, as you’ll see at the bottom…..

FWIW my opinion on what pfft does is that it’s actually not ideal, because the scaling for both input and output window are combined and split between fftin~ and fftout~. The compensation for the overlap is also split between the two and it makes normalising the values inside pfft a bit of a nightmare. It would in my opinion be preferable to have the values inside the pfft compensated for input window gain (in which case peaks of size N would be expected for a 0dB peak sinewave on a bin) and for the overlap and output window gain and anything else (FFT algorithm gain for instance) to be compensated in fftout~. Unfortunately the way it works is not like that.

The following is based on how pfft~ (or in fact fftin~ and fftout~) *definitely* used to work:

1 – It is usual to sqrt the magnitude values in a window for an overlap of 2 (but not 4 or more). This means you need to use the sqrt of each magnitude value for a 2x overlap (obviously this doesn’t affect the result for a square window)

2 – Because we are windowing twice it’s actually the sum of the squares that you need, not just the sum of the points. Again this wouldn’t affect the square window case, which explains why the maths above seems to work fine.

This also means I would expect that for an overlap of 2 case you would have got the right vals as step 1 and step 2 would cancel out.

———— max 5 situation ————

In addition to all this, just now doing some quick experiments in max 5 I don’t get different values for different overlaps, which means that it’s pretty hard to figure out what is going on here, because clearly if the formula was right the scaling would change. Hopefully someone’s sorted out the scaling, but I can’t quite figure out what they have done. The quickest way to get the value for a specific case (I’d say) would be an empirical method. A programmatic approach would be a lot nicer, but it’s just a bit tough to work out what is actually happening. I believe the tutorial may be out of date.

A square window with 512 points is giving me a value of 256 right now for any overlap – vonn hann about 128 and hamming about 140 – go figure. If anyone comes up with a formula be good to hear it – I’d guess it’s not going to involve a sqrt, or an overlap term.

Regards,

Alex

]]>thanks,

oli

]]>-&e->

-&e->can anyone from C74 comment on this? is the text in tutorial 26 out

-&e->of date? In any case, i think the paragraph quoted above is not very

-&e->helpful for non-engineers trying to make sense of the FFT! It is not

-&e->clear how you derive the figures imo.

Most likely easier and more accurate to derive experimentally. Run a

couple different clean sine waves into that thing, at frequencies of

SamplingFrequency / #ofBins @ amplitude=1 and see what you get. Run white

noise through it and capture maximum bin amplitude. See what happens.

andyw

]]>