comparison layer/ScrollableMagRangeCache.cpp @ 1143:c53ed1a6fcbd spectrogram-minor-refactor

Fixes to phase display and colour scale for it; tidy up some debug output
author Chris Cannam
date Fri, 05 Aug 2016 14:31:16 +0100
parents 9ff838a64461
children f2f43802718b
comparison
equal deleted inserted replaced
1142:8f4634b82e36 1143:c53ed1a6fcbd
15 #include "ScrollableMagRangeCache.h" 15 #include "ScrollableMagRangeCache.h"
16 16
17 #include <iostream> 17 #include <iostream>
18 using namespace std; 18 using namespace std;
19 19
20 #define DEBUG_SCROLLABLE_MAG_RANGE_CACHE 1 20 //#define DEBUG_SCROLLABLE_MAG_RANGE_CACHE 1
21 21
22 void 22 void
23 ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v, 23 ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v,
24 sv_frame_t newStartFrame) 24 sv_frame_t newStartFrame)
25 { 25 {
74 newRanges.insert(newRanges.begin(), 74 newRanges.insert(newRanges.begin(),
75 m_ranges.begin() + dx, m_ranges.end()); 75 m_ranges.begin() + dx, m_ranges.end());
76 m_ranges = newRanges; 76 m_ranges = newRanges;
77 } 77 }
78 78
79 #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
79 cerr << "maxes (" << m_ranges.size() << ") now: "; 80 cerr << "maxes (" << m_ranges.size() << ") now: ";
80 for (int i = 0; in_range_for(m_ranges, i); ++i) { 81 for (int i = 0; in_range_for(m_ranges, i); ++i) {
81 cerr << m_ranges[i].getMax() << " "; 82 cerr << m_ranges[i].getMax() << " ";
82 } 83 }
83 cerr << endl; 84 cerr << endl;
85 #endif
84 } 86 }
85 87
86 MagnitudeRange 88 MagnitudeRange
87 ScrollableMagRangeCache::getRange(int x, int count) const 89 ScrollableMagRangeCache::getRange(int x, int count) const
88 { 90 {
107 } else { 109 } else {
108 m_ranges[column].sample(r); 110 m_ranges[column].sample(r);
109 } 111 }
110 } 112 }
111 113
112 //!!! unneeded?
113 void
114 ScrollableMagRangeCache::sampleColumn(const LayerGeometryProvider *v,
115 sv_frame_t frame,
116 const MagnitudeRange &r)
117 {
118 int x = (v->getXForFrame(frame) -
119 v->getXForFrame(m_startFrame));
120
121 if (!in_range_for(m_ranges, x)) {
122 cerr << "WARNING: ScrollableMagRangeCache::sampleColumn: column " << x
123 << " arising from frame " << frame << " is out of range for cache "
124 << "of width " << m_ranges.size()
125 << " (with start frame " << m_startFrame << ")" << endl;
126 throw logic_error("column out of range");
127 } else {
128 sampleColumn(x, r);
129 }
130 }
131