Re: Magnitudes drop when adding more
- From: "overgaard" <jorgen@xxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 13:28:30 -0600
>
>"overgaard" <jorgen@xxxxxxxxxxxxx> wrote in message
>news:rISdnc0GibpOXUHeRVn-qQ@xxxxxxxxxxxxxxx
>> Hi,
>>
>> I've just "restarted" my interest in DSP and mainly FFT.
>> I'm using FFTW which I think is absolutely amazingly good! :)
>>
>> I was playing around with FFT a few years back and I think I
>> remember stumbled on this problem back then too. The sad
>> part is - I don't remember if I solved it or not back then.
>> (what good memory, eh? hehe)
>>
>> Anyway, I'm troubled with something I quite can't figure out.
>> I've done a test application that generates sinewaves and stores them
>> to a WAV-file. When I open the WAV-file and run FFTW on it and plot
>> a spectrum of it, it looks fine on frequency. BUT the magnitudes are
>> behaving strangely. If I have a single tone, lets say at 1000 Hz
>> it show up at full scale. If I add one more tone, they BOTH drop in
>> magnitude. To doublecheck I opened the WAV file i Audacity and looked
att
>> the spectrum there. It looks fine there even if I add three tones or
>> more.
>> But in my application, the more tones I add, the lower they ALL get.
>> Why is this? (ripping the hair of my head)
>>
>> I'm using real to complex FFTW, eg. fftw_plan_dft_r2c_1d
>> and I am calculating the magnitudes with
>>
sqrt((in_complex[i][0]*in_complex[i][0])+(in_complex[i][1]*in_complex[i][1]))*Normalize
>>
>> which should translate to
>>
>> Magnitude = sqrt(re^2 + im^2) * Normalize
>>
>> My normalizing is
>>
>> Normalize = (sqrt(1.0/FFT_SIZE)) * (sqrt(1.0/FFT_SIZE));
>>
>> I've tried a lot of "normalizers" (searched Comp.DSP) but I'm not a
100
>> percent sure this is the "right" normalizing.
>>
>> Anyone has any idea why the magnitudes drop the more tones I add?
>> And of course, please tell me something about how to normalize
correctly.
>> If I have a sine at 1000 Hz which peaks(-1.0 to 1.0) it would be
>> nice to get the spectrum to show about 1.0 in magnitude at the bin
>> for 1000 Hz.
>>
>> Best regards // Jörgen
>
>Jörgen,
>
>First of all, the normalization is up to you really.
>The most common normalization in DSP is NO normalization in the FFT and
1/N
>normalization in the IFFT.
>FFTW doesn't do that for you as I recall.
>1/sqrt(N) in both directions is more typically used by physicists I
believe.
>Another variation is 1/N in the FFT.
>
>For one unit cosine of some integer number of periods in the temporal
epoch,
>what you should get are a *pair* of real frequency samples of magnitude
N/2
>each if there is no scaling in the FFT. So, if you want to see
magnitudes
>of 1.0 for each frequency sample of a unit cosine in time, you should
>multiply the fft by 2/N and the ifft by N/2 (assuming that it is already
>normalized by 1/N) or by 1/2 if it's not scaled that way.
>
>In other words:
>Scale the FFTW IFFT by 1/N as a "normal thing" in order to switch from
one
>transform space to another without worries - unless you're changing the
>value of N in there somewhere.
>
>Then, if you want to have some other normalization "on top" of that,
>normalize in both directions (inversely) according to what you want.
>So, that would be 2/N for the fft and N/2 for the ifft if you want unit
>cosines to have each sample in frequency of mangitude 1.0.
>
>For a sum of one unit cosines of some integer number of periods each in
the
>temporal epoch, there will be no change to the above. That is, unless
you
>change N and the scaling changes accordingly!
>
>Fred
>
>
>
Hi Fred and thanks for answering my "call"! :)
Very interresting information you supplied me with. Much appreciated! =)
Normalization with (2.0/N) does it perfectly now! Finally, Yes!
Again, thanks for your reply!
Best regards // Jörgen
.
- References:
- Magnitudes drop when adding more
- From: overgaard
- Re: Magnitudes drop when adding more
- From: Fred Marshall
- Magnitudes drop when adding more
- Prev by Date: Re: Help regarding identification of modulation(GMSK) type of a signal
- Next by Date: Re: help! how do I formulate this sampling system and analyze it?
- Previous by thread: Re: Magnitudes drop when adding more
- Next by thread: Re: Magnitudes drop when adding more
- Index(es):
Relevant Pages
|