diff layer/SpectrogramLayer.cpp @ 203:258af0c4dc28

* Fix crash in short spectrogram paint * Fix incorrect apparent end point for waveforms
author Chris Cannam
date Wed, 14 Feb 2007 17:52:06 +0000
parents 45e995ed84d9
children b6af2eb00780
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Feb 09 11:32:34 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Feb 14 17:52:06 2007 +0000
@@ -1629,11 +1629,18 @@
     int x0 = 0, x1 = v->width();
     float s00 = 0, s01 = 0, s10 = 0, s11 = 0;
     
-    getXBinRange(v, x0, s00, s01);
-    getXBinRange(v, x1, s10, s11);
+    if (!getXBinRange(v, x0, s00, s01)) {
+        s00 = s01 = m_model->getStartFrame() / getWindowIncrement();
+    }
+
+    if (!getXBinRange(v, x1, s10, s11)) {
+        s10 = s11 = m_model->getEndFrame() / getWindowIncrement();
+    }
 
     int s0 = int(std::min(s00, s10) + 0.0001);
-    int s1 = int(std::max(s01, s11));
+    int s1 = int(std::max(s01, s11) + 0.0001);
+
+//    std::cerr << "SpectrogramLayer::updateViewMagnitudes: x0 = " << x0 << ", x1 = " << x1 << ", s00 = " << s00 << ", s11 = " << s11 << " s0 = " << s0 << ", s1 = " << s1 << std::endl;
 
     if (m_columnMags.size() <= s1) {
         m_columnMags.resize(s1 + 1);
@@ -2081,6 +2088,12 @@
 
             if (mag.isSet()) {
 
+
+                if (s >= m_columnMags.size()) {
+                    std::cerr << "INTERNAL ERROR: " << s << " >= "
+                              << m_columnMags.size() << " at SpectrogramLayer.cpp:2087" << std::endl;
+                }
+
                 m_columnMags[s].sample(mag);
 
                 if (overallMag.sample(mag)) {