-1
$\begingroup$

What wavelet-based peak finding functions are there for C++?

I'm looking for something similar to: http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.signal.find_peaks_cwt.html. Preferably something that produces the same exact results.

Have tried: https://github.com/xuphys/peakdetect, but this does not operate on floats (but shorts) and gives different results (either because of shorts or if it's not wavelet-based). The difference produced is around 20%.

My signals are audio signals and I'm doing $f_0$ estimation from an autocorrelation (ACF) signal (can be noisy, can be polyphonic).

Also, how does one in general interpret, whether the algorithm produces "the right peaks"? Just by plotting?

$\endgroup$
  • $\begingroup$ peakdetect is a completely different approach than the one offered by Python so you will not get the same results. Depends on your application you might want to glue the Python code to our C++ code. Please note that find_peaks_cwt is veeery slooow... $\endgroup$ – jojek May 31 '15 at 14:28
  • $\begingroup$ What's the reason behind having these mixed results? A peak should be a peak right? If there are many ways to find peaks (and different types of peaks), at least it would make sense to specify them. $\endgroup$ – mavavilj May 31 '15 at 14:40
  • 1
    $\begingroup$ I guess that you understand that all methods will perform differently for various signals, unless you are detecting a single peak without any noise. Also various methods have different parameters which are not necessarily related. Would you say that all methods for the detection of fundamental frequency should produce same result, cause "$f_0$ should be $f_0$? I guess not. $\endgroup$ – jojek May 31 '15 at 14:45
  • $\begingroup$ If "f0" is known (e.g. can be pointed by listening to the signal in the case of audio signal), then of course all peak finders should attempt to find the same f0, if they're peak finders for f0. $\endgroup$ – mavavilj May 31 '15 at 14:48
  • $\begingroup$ But obviously won't, do you agree? Enough of meaningless chat. We have no idea what is the signal you are dealing with, therefore I cannot address that problem in the greater detail. $\endgroup$ – jojek May 31 '15 at 14:49
1
$\begingroup$

If you're already satisfied with the scipy version, you could use Cython to translate it to C code. Of course, Cython will not generate super nice C code by default, but that can be changed by compiler directives.

However, there might be a better approach than peak detection. If you show us some plots, we might be able to point you in the better direction.

As for "the right peaks" question, if you were able to mathematically define what you mean by that (e.g. statistical distribution of values, noise or frequency characteristic), then you could use that to construct a perfect detector in the first place. It is usually very hard to define the characteristics of "the right peak", so it is often much simpler to use one of the most advanced detectors: our eyes and our mind.

$\endgroup$
  • $\begingroup$ Thanks for the Cython tip. Haven't used Python much so didn't know that was possible. The discussion about the (pitch detection) algorithm would belong to another thread. $\endgroup$ – mavavilj May 31 '15 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.