Please see my comment to the question. This problem is quite complex, as far as I can understand it, something like "image recognition", only for music. I tried some software product doing that, and they all worked quite poorly, even when I used a very clear waveform.
So, sorry for not answering your question, it could be a difficult thing. I believe solving such problem should be possible, but I never saw really good solutions.
Before you can even get to the problem, you should first understand how to formulate it. You are not doing it correctly — I tried to provide some hints to understanding why in my comment to the question. Just for figuring out the formulation of the problem, you should better understand how spectrum and Fourier analysis/transform works and what it really means. I'm afraid it's more complex (even for general understanding) than you imagine right now. You can start here:
http://en.wikipedia.org/wiki/Discrete_Fourier_transform[
^],
http://en.wikipedia.org/wiki/Fourier_transform[
^],
http://en.wikipedia.org/w/index.php?title=Special:Search&search=Fourier+analysis&profile=default[
^].
—SA