comparison layer/SpectrumLayer.cpp @ 265:a3a54632cd4c

* fixes to spectrum harmonic cursor etc
author Chris Cannam
date Fri, 15 Jun 2007 15:48:11 +0000
parents 7e9e533f1863
children 4ed1446ad604
comparison
equal deleted inserted replaced
264:7e9e533f1863 265:a3a54632cd4c
254 { 254 {
255 return false; 255 return false;
256 } 256 }
257 257
258 float 258 float
259 SpectrumLayer::getXForBin(int bin, int totalBins, float w) const
260 {
261 if (!m_sliceableModel) return SliceLayer::getXForBin(bin, totalBins, w);
262
263 float sampleRate = m_sliceableModel->getSampleRate();
264 float binfreq = (sampleRate * bin) / (totalBins * 2);
265
266 return getXForFrequency(binfreq, w);
267 }
268
269 int
270 SpectrumLayer::getBinForX(float x, int totalBins, float w) const
271 {
272 if (!m_sliceableModel) return SliceLayer::getBinForX(x, totalBins, w);
273
274 float sampleRate = m_sliceableModel->getSampleRate();
275 float binfreq = getFrequencyForX(x, w);
276
277 return int((binfreq * totalBins * 2) / sampleRate);
278 }
279
280 float
259 SpectrumLayer::getFrequencyForX(float x, float w) const 281 SpectrumLayer::getFrequencyForX(float x, float w) const
260 { 282 {
261 float freq = 0; 283 float freq = 0;
262 284
263 int sampleRate = m_sliceableModel->getSampleRate(); 285 int sampleRate = m_sliceableModel->getSampleRate();