I am writing a C++ program to use to analyse oscillations and create a power spectrum. I am using FFTW3.
To test the system, I am using a perfect sine function.
But no matter what parameters I try, I run into the same problem. I find the correct frequency, but also many 'overtones'.
First I assumed the problem was my way of chopping up the signal or how I calculate the running mean. But the problem is there when I just have all data in a single big window, bypassing my suspect code, still creating the pattern in the pictures.
I then assumed it was an aliasing problem, but even 1024 datapoints in a period, and they don't go away. They just lose shape and appear randomly. I assumed it was too little periods in my window. But more periods per window and they just become less frequent and stronger. Then I assumed it may be spectral leakage, so I assumed I may need to use a windowing function like a Hamming, but that creates an odd slant. Is that the trade-off?
Or do I just set everything that is small enough to zero? I was just expecting a single strong point peak and the remainder to be so near zero, the log is -6 or lower everywhere else uniformly.
If I can't figure out how to get the right parameters for the best signal-to-noise ratio, I am not sure how I will achieve that when I start to work with the actual data.
I assumed it would be simple to pick a window that contains 32 periods with 32 discrete points in each period, use Welch's method and be done with it.
I am not an engineer who took many many classes on this kind of stuff. So I just don't have the proper training. I am working on a project of 4 weeks. There is so much info out there, it is confusing, but I don't know where to start as I don't have the time to learn stuff properly.
It can't be caused by the limited numbers of decimals of the input sine values, right?