C
C
cyber_genius2014-02-03 17:53:44
Algorithms
cyber_genius, 2014-02-03 17:53:44

FFT. How to find the main harmonics of a signal?

Need advice or an algorithm for finding the main harmonics of the signal. For example, there is a signal spectrum (see figure), you can see by eye which main hormones are present in the signal, but here's how to do it in such a way that it can be detected programmatically. In other words, you need to get exactly the same buffer, in which there will be only 20Hz harmonics and in what places of the buffer (512 bytes).
8621554b8532479e8c9c3d27dda1b1a3.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Lerg, 2014-02-03
@cyber_genius

Google peak detection algorithm.
In the general case, you need to pass the data through a smoothing filter, correct adjacent peaks, select the fundamental harmonic and use it to search for higher and weaker harmonics.
www.biomedcentral.com/1471-2105/10/4

M
Makeman, 2015-09-30
@Makeman

Some useful lines in C#

// Complex[] fftResultComplexFrame
var y = 0;
var dic = fftResultComplexFrame.ToDictionary(c => y++, c => c);
var tops = dic.OrderByDescending(p => p.Value.Magnitude).Take(20).ToList();

The input is an array of complex values ​​obtained by direct Fourier transform.
From it, we select 20 peaks with the highest amplitude. The result is a dictionary of complex values ​​of the corresponding frequencies (keys).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question