Implementation of perucssive harmonic detection function in C++