comparison layer/SpectrogramLayer.cpp @ 45:25a2915d351d

* Continue MainWindow refactoring by making MainWindow actually use the new Document class -- still somewhat unstable * Fix crash in spectrogram layer * Rename tonalestimator to TonalEstimator and add to project file
author Chris Cannam
date Fri, 03 Mar 2006 16:56:20 +0000
parents ad214997dddb
children 2e2ad8510e52
comparison
equal deleted inserted replaced
44:ad214997dddb 45:25a2915d351d
1684 { 1684 {
1685 // Profiler profiler("SpectrogramLayer::paint", true); 1685 // Profiler profiler("SpectrogramLayer::paint", true);
1686 #ifdef DEBUG_SPECTROGRAM_REPAINT 1686 #ifdef DEBUG_SPECTROGRAM_REPAINT
1687 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << ", pixmap cache invalid " << m_pixmapCacheInvalid << std::endl; 1687 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << ", pixmap cache invalid " << m_pixmapCacheInvalid << std::endl;
1688 #endif 1688 #endif
1689 1689
1690 m_candidateFillStartFrame = v->getStartFrame(); 1690 long sf = v->getStartFrame();
1691 if (sf < 0) m_candidateFillStartFrame = 0;
1692 else m_candidateFillStartFrame = sf;
1691 1693
1692 if (!m_model || !m_model->isOK() || !m_model->isReady()) { 1694 if (!m_model || !m_model->isOK() || !m_model->isReady()) {
1693 return; 1695 return;
1694 } 1696 }
1695 1697
1881 } 1883 }
1882 1884
1883 int s0i = int(s0 + 0.001); 1885 int s0i = int(s0 + 0.001);
1884 int s1i = int(s1); 1886 int s1i = int(s1);
1885 1887
1888 if (s1i >= m_cache->getWidth()) {
1889 if (s0i >= m_cache->getWidth()) {
1890 m_mutex.unlock();
1891 continue;
1892 } else {
1893 s1i = s0i;
1894 }
1895 }
1896
1886 for (size_t q = minbin; q < bins; ++q) { 1897 for (size_t q = minbin; q < bins; ++q) {
1887 1898
1888 float f0 = (float(q) * sr) / m_windowSize; 1899 float f0 = (float(q) * sr) / m_windowSize;
1889 float f1 = (float(q + 1) * sr) / m_windowSize; 1900 float f1 = (float(q + 1) * sr) / m_windowSize;
1890 1901
1891 float y0 = 0, y1 = 0; 1902 float y0 = 0, y1 = 0;
1892 1903
1893 if (m_binDisplay != PeakFrequencies || 1904 if (m_binDisplay != PeakFrequencies) {
1894 s1i >= int(m_cache->getWidth())) {
1895 y0 = v->getYForFrequency(f1, minFreq, maxFreq, logarithmic); 1905 y0 = v->getYForFrequency(f1, minFreq, maxFreq, logarithmic);
1896 y1 = v->getYForFrequency(f0, minFreq, maxFreq, logarithmic); 1906 y1 = v->getYForFrequency(f0, minFreq, maxFreq, logarithmic);
1897 } 1907 }
1898 1908
1899 for (int s = s0i; s <= s1i; ++s) { 1909 for (int s = s0i; s <= s1i; ++s) {