[CLAM] problem using pitch detection. especially: spectrumAnalysis

Martijn Bosma M.Bosma at ai.rug.nl
Tue Feb 24 08:56:16 PST 2004


Hello,

I try to use clam for pitch detection in a wave file. I have downloaded 
clam -0.5.7. There are many example programs that show very clearly how to 
do some actions  in clam, but I couldn't find an example that shows how to do pitch detection.
My first question is:

1) Is there (somewhere) an example that shows how to do pitch detection?
	(or can someone give me one?)



Because I couldn't find it I tried it myself. 
To get a spectrum out of the audio object I use: 		SpectralAnalysis.
To get a SpectralPeakArray I use:  				SpectralPeakDetect.
Finally, to get a list of candidate frequencies I use:  	FundFreqDetect .

When I use the SpectralAnalysis Do(audio, spectrum)  function I get the 
following exception breakpoint:


"
ASSERTION FAILED
spectrum.cxx line 647:
Spectrum::GetSize(): Complex size and Size mismatch.
"


When I look  in the code of the spectrum object I find that the size of 
the complex array is not equal to size.


"
	if(HasComplexArray() && GetComplexArray().Size())                                    
		CLAM_ASSERT(GetComplexArray().Size() == size,
		           "Spectrum::GetSize(): Complex size and Size mismatch.");
"


But I cannot find out  where in the program these sizes are set, and why 
they are not equal. Maybe I initialized / configured the spectrum or the spectrum 
analysis object in the wrong way, so my second question is:

2) how do I have to configure the spectrum and the spectrumAnalysis object 
   to do first spectrum analysis and in the end  pitch detection? 


Because I couldn't really solve the error, I tried cheating. I make both 
sizes equal just before the check. The code on the same place in the spectrum object looks now like this:


"
	if(HasComplexArray() && GetComplexArray().Size())                                    
	{											
		GetComplexArray().Resize(size);					
		GetComplexArray().SetSize(size);
		CLAM_ASSERT(GetComplexArray().Size() == size,
		           "Spectrum::GetSize(): Complex size and Size 
mismatch.");
	}
"


Now I am sure that both sizes are always equal when checked. 
The program works, but I don't detect the right frequencies yet. 
This can have several causes. One of them can be my lines of "cheat-code". 
Question three is:

3) Does it harm the resulting spectrum when I add these two lines of 
   cheat-code?


So far my questions and the description of my problem.
I hope someone can provide the answers.

Regards
Martijn 






More information about the clam-users mailing list