In this paper, we have proposed a new algorithm for pitch detection and an idea for harmonic separation based on pitch detection. Firstly, we have introduced the pitch algorithm. It is mainly consisted of five parts: mean value removal, extraction of alternative pitch periods, best pitch transfer path search, accurate pitch period search with time-varying filter and the search of fractional pitch period. Then we have brought in a harmonic separation algorithm based on the pitch detection. The pitch detection algorithm and harmonic separation algorithm proposed in this paper is mutually beneficialExperiments results show that the new pitch detection algorithm can achieve higher accuracy. And compared with some other algorithms, this approach owns a better noise immunity. The harmonic separation algorithm can separate each harmonic signal accurately.