Thank you for your response. I still have to read the link you send more thoroughly to understand it properly, but I think I found another bug.

I generated the input for the FFT like this:

Code:

sin(i * 2.0 * M_PI / 98)

So the wave has a period of 98 samples, at 44100 Hz, so it should generate an output of 450 Hz.

Code:

0.944744 on frequency 0
0.953641 on frequency 43.0664
0.981347 on frequency 86.1328
1.03121 on frequency 129.199
1.11001 on frequency 172.266
1.23057 on frequency 215.332
1.41819 on frequency 258.398
1.72835 on frequency 301.465
2.30799 on frequency 344.531
3.71084 on frequency 387.598
11.4264 on frequency 430.664 <-- Obvious peek
8.90731 on frequency 473.73
3.03495 on frequency 516.797
1.77379 on frequency 559.863
1.22751 on frequency 602.93
0.924448 on frequency 645.996
** Lots of lines **
0.00590028 on frequency 21963.9
0.00590019 on frequency 22006.9

This looks OK to me (although I'm really unexperienced with audio processing, this is the first thing I'm doing). Even though the other frequencies show up a bit, it's easy to see around 450 Hz is most present.

When I change the function to 947.461 Hz, using:

Code:

sin(i * 2.0 * M_PI / 46.545451475);

And the output is quite good:

Code:

1.42468e-07 on frequency 0
1.7196e-07 on frequency 43.0664
2.40527e-07 on frequency 86.1328
** Lots of lines ***
1.10611e-05 on frequency 861.328
2.26838e-05 on frequency 904.395
16 on frequency 947.461 <-- Obvious peek
2.37334e-05 on frequency 990.527
1.21123e-05 on frequency 1033.59
** Lots of lines ***
1.42481e-07 on frequency 21963.9
1.42479e-07 on frequency 22006.9

So they both look good to me. However, now I try to combine them using the following function:

Code:

sin(i * 2.0 * M_PI / 46.545451475)*sin(i * 2.0 * M_PI / 98)

I would think this should output peeks at the frequencies 450 and 947.461. However, what I receive is this:

Code:

0.0940861 on frequency 0
0.100144 on frequency 43.0664
0.11747 on frequency 86.1328
** Lots of lines **
0.831364 on frequency 387.598
1.46475 on frequency 430.664
4.40354 on frequency 473.73
5.7609 on frequency 516.797 <-- Peek
1.90085 on frequency 559.863
1.19735 on frequency 602.93
0.905608 on frequency 645.996
0.748753 on frequency 689.062
** Lots of lines **
0.509344 on frequency 904.395
0.503752 on frequency 947.461
0.507132 on frequency 990.527
** Lots of lines **
0.889341 on frequency 1248.93
1.17847 on frequency 1291.99
1.87924 on frequency 1335.06
5.73641 on frequency 1378.12 <-- Peek
4.43105 on frequency 1421.19
1.49541 on frequency 1464.26
0.865353 on frequency 1507.32
0.592714 on frequency 1550.39
** Lots of lines **
0.000333131 on frequency 21963.9
0.00033312 on frequency 22006.9

This output just doesn't seem right to me. So, am I doing something completely wrong here? Or is my algorithm wrong? I programmed it with some help of a tutorial and bit of the tutorials code at

http://www.relisoft.com/Science/Physics/sampling.html

I'm pretty sure that code produces the same output.

So, any idea what I'm doing wrong? Or is the error in the FFT algorithm?

Thanks,

EVOEx