Mercurial > hg > svgui
diff layer/ScrollableMagRangeCache.cpp @ 1122:94370157b265 spectrogram-minor-refactor
Fixes and debug output for mag range calculations
author | Chris Cannam |
---|---|
date | Fri, 22 Jul 2016 13:56:24 +0100 |
parents | 65cdaf8d6b50 |
children | 745a868f0abf |
line wrap: on
line diff
--- a/layer/ScrollableMagRangeCache.cpp Fri Jul 22 12:17:55 2016 +0100 +++ b/layer/ScrollableMagRangeCache.cpp Fri Jul 22 13:56:24 2016 +0100 @@ -22,12 +22,7 @@ void ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v, sv_frame_t newStartFrame) -{ - if (m_startFrame == newStartFrame) { - // haven't moved - return; - } - +{ int dx = (v->getXForFrame(m_startFrame) - v->getXForFrame(newStartFrame)); @@ -35,6 +30,11 @@ cerr << "ScrollableMagRangeCache::scrollTo: start frame " << m_startFrame << " -> " << newStartFrame << ", dx = " << dx << endl; #endif + + if (m_startFrame == newStartFrame) { + // haven't moved + return; + } m_startFrame = newStartFrame; @@ -61,7 +61,7 @@ auto newRanges = vector<MagnitudeRange>(-dx); newRanges.insert(newRanges.end(), - m_ranges.begin(), m_ranges.begin() + w + dx); + m_ranges.begin(), m_ranges.begin() + (w + dx)); m_ranges = newRanges; } else { @@ -75,6 +75,25 @@ m_ranges.begin() + dx, m_ranges.end()); m_ranges = newRanges; } + + cerr << "maxes now: "; + for (int i = 0; in_range_for(m_ranges, i); ++i) { + cerr << m_ranges[i].getMax() << " "; + } + cerr << endl; +} + +MagnitudeRange +ScrollableMagRangeCache::getRange(int x, int count) const +{ + MagnitudeRange r; +#ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE + cerr << "ScrollableMagRangeCache::getRange(" << x << ", " << count << ")" << endl; +#endif + for (int i = 0; i < count; ++i) { + r.sample(m_ranges.at(x + i)); + } + return r; } void @@ -90,6 +109,7 @@ } } +//!!! unneeded? void ScrollableMagRangeCache::sampleColumn(const LayerGeometryProvider *v, sv_frame_t frame,