<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi, <br><br>I'm using CLAM to develop an automated music transcription system for my MSc project. I'm using the SpectralAnalysis and the SpectralPeakDetection classes to produce an array of frequency peaks and their relative strengths. At the moment the output of my system looks something like this for a 3000 sample chunk of piano at C5 (44100Hz Sample rate):<br><br>Number of peaks = 56<br>1.  Mag  = 1   Freq = 527.066   Note = C5<br>2.  Mag  = 0.433355   Freq = 1106.62   Note = C#6<br>3.  Mag  = 0.234237   Freq = 2495.64   Note = D#7<br>4.  Mag  = 0.0988229   Freq = 2956.98   Note = F#7<br>5.  Mag  = 0.127852   Freq = 3501.44   Note = A6<br>6.  Mag  = 0.121919   Freq = 3885.22   Note = B7<br>7.  Mag  = 0.149638   Freq = 4367.42   Note = C#8<br>8.  Mag  = 0.157781   Freq = 5109.65   Note = D#8<br>9.  Mag  = 0.0964647   Freq = 5422.36   Note = E8<br><br>This is almost correct, having checked it against spectra produced by various audio applications but I have only managed to acheive this after spending ages configuring the window size manually:<br><br>//STFT method, performs the STFT on a <br>//chunk of Audio and puts the data into a <br>//CLAM::Spectrum object<br>void AMTPeakDetect::STFT()<br>{<br>  SpectralAnalysisConfig config;<br>  cout << "Enter Size:";<br>  int size;<br>  cin >> size;<br>  audioData.SetSize(size);<br>  int windowSize = 679; <br>  int spectrumSize = 513; <br>  config.SetSamplingRate(audioData.GetSampleRate());<br>  config.SetWindowSize(windowSize);<br>  spectrum.SetSize(spectrumSize);<br>  spectrum.SetScale(EScale::eLog);<br>  SpectralAnalysis(sa);<br>  sa.Configure(config);<br>  sa.Start();<br>  sa.Do(audioData, spectrum);<br>  sa.Stop();<br>}<br><br><br>Is there a way of setting the window size automatically to a value which produces a correct result? If not how would one calculate the optimum window size to choose. I've also tried using various different window types. Any help on this matter will be greatly appreciated.<br><br>Thanks<br><br>Patrick<br><br /><hr />Get Messenger on your Mobile! <a href='http://clk.atdmt.com/UKM/go/101719964/direct/01/' target='_new'>Get it now!</a></body>
</html>