COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to check the FFT results of a sine wave? 364108

• Email
• Follow

```I have been given an audio file (sine wave) 800Hz as an input to my
FFT algorithm. I have got 8192 power spectrum samples in a array.

What is the best and easiest way to check whether my output is right
or wrong?

If I give a silent audio file then the output is zero for all samples.
In a sine wav the o/p increases from 20 (0th sample) to 26059811
(743rd sample) and decreases gradually to 40.

If I get an idea of the output range then I can prove technically
whether the FFT is working.

Refer to http://stackoverflow.com/questions/4040918/how-to-check-the-fft-results-in-iphone
```
 0

See related articles to this posting

```nagarajan karunakaran <prassan86@gmail.com> wrote:
> I have been given an audio file (sine wave) 800Hz as an input to my
> FFT algorithm. I have got 8192 power spectrum samples in a array.

> What is the best and easiest way to check whether my output
> is right or wrong?

If you really want to know, and you know it is one sine, then
least squares fit.

-- glen
```
 0

```On 28 Okt., 15:00, nagarajan karunakaran <prassa...@gmail.com> wrote:
> I have been given an audio file (sine wave) 800Hz as an input to my
> FFT algorithm. I have got 8192 power spectrum samples in a array.
>
> What is the best and easiest way to check whether my output is right
> or wrong?

Just apply the FFT twice. If your output is the time reversed input
then you have a very good chance that your algorithm is correct.

Cheers,

Andreas
```
 0

```On 10/28/2010 06:00 AM, nagarajan karunakaran wrote:
> I have been given an audio file (sine wave) 800Hz as an input to my
> FFT algorithm. I have got 8192 power spectrum samples in a array.
>
> What is the best and easiest way to check whether my output is right
> or wrong?
>
> If I give a silent audio file then the output is zero for all samples.
> In a sine wav the o/p increases from 20 (0th sample) to 26059811
> (743rd sample) and decreases gradually to 40.
>
> If I get an idea of the output range then I can prove technically
> whether the FFT is working.
>
> Any ideas would be helpful.

Define "gradually".  Define what you mean by "power spectrum samples".
Is your sampling rate such that an integer number of cycles of your
800Hz sine wave fits exactly in your 8192 point input vector?  If so,
and if that's really the only thing in your file, then you've got a problem.

One good test of an FFT algorithm is to present it with sine and cosine
waves at all harmonics of the sampling length.  I.e., if you're taking
your 8192-point sample, then give it cosine and sine waves of frequency
0, 1/8192, 2/8192, 3/8192 ... 4096/8192 (figuring out why you don't need
to go higher is left as an exercise for you).  All the results (except
for f = 0) should have the same amplitude, and you should be able to
figure out what amplitude the f = 0 case should have.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
 0