Harmonics count in a music sample

To determine the saturation of the sound, I would like to determine the number of harmonics in the sample music. To do this, I use Processing using the Minim library, which gives me the full spectrum with FFT . I'm wondering how to count all the peaks in the spectrum produced by the FFT , I'm not even interested in the main frequency.

+7
source share
1 answer

There are many ways to do this, depending on your needs.

If you want to count each peak, you must go through all the frequencies in the spectrum, remembering whether the intensity increased or decreased. Each time you notice a change in direction from increasing to decreasing, you increase the peak counter. Please note, however, that this will include very weak peaks, which may or may not be what you need. You can set a minimum limit on how much the increase and decrease should be for the registered peak.

Alternatively, you can find the baseline for signal strength (using the average in the simplest case), and then count the number of positive spikes (with some configurable minimum deviation from the baseline). You will probably get better results if you change this approach to using a frequency-dependent baseline and minimum to allow for a gradual decrease in intensity at higher frequencies (again, it depends on your particular signal and the need for it to be useful ) One simple way to do this is to divide your spectrum into bands (small enough to be able to accept a more or less flat energy distribution throughout the group) and use different base and minimum values ​​for each band.

+3
source

All Articles