comparison layer/SliceLayer.cpp @ 254:a2ae3d93c645

* bit of work on harmonic cursor in spectrum
author Chris Cannam
date Mon, 11 Jun 2007 12:14:52 +0000
parents 28c8e8e3c537
children b9380f679f70
comparison
equal deleted inserted replaced
253:1b1e6947c124 254:a2ae3d93c645
34 m_energyScale(dBScale), 34 m_energyScale(dBScale),
35 m_samplingMode(SampleMean), 35 m_samplingMode(SampleMean),
36 m_plotStyle(PlotSteps), 36 m_plotStyle(PlotSteps),
37 m_binScale(LinearBins), 37 m_binScale(LinearBins),
38 m_normalize(false), 38 m_normalize(false),
39 m_bias(false),
40 m_gain(1.0), 39 m_gain(1.0),
41 m_currentf0(0), 40 m_currentf0(0),
42 m_currentf1(0) 41 m_currentf1(0)
43 { 42 {
44 } 43 }
227 } 226 }
228 227
229 void 228 void
230 SliceLayer::paint(View *v, QPainter &paint, QRect rect) const 229 SliceLayer::paint(View *v, QPainter &paint, QRect rect) const
231 { 230 {
232 if (!m_sliceableModel) return; 231 if (!m_sliceableModel || !m_sliceableModel->isOK() ||
232 !m_sliceableModel->isReady()) return;
233 233
234 paint.save(); 234 paint.save();
235 paint.setRenderHint(QPainter::Antialiasing, false); 235 paint.setRenderHint(QPainter::Antialiasing, false);
236 236
237 if (v->getViewManager() && v->getViewManager()->shouldShowScaleGuides()) { 237 if (v->getViewManager() && v->getViewManager()->shouldShowScaleGuides()) {
285 f1 = (col1 + 1) * m_sliceableModel->getResolution() - 1; 285 f1 = (col1 + 1) * m_sliceableModel->getResolution() - 1;
286 286
287 m_currentf0 = f0; 287 m_currentf0 = f0;
288 m_currentf1 = f1; 288 m_currentf1 = f1;
289 289
290 BiasCurve curve;
291 getBiasCurve(curve);
292 size_t cs = curve.size();
293
290 for (size_t col = col0; col <= col1; ++col) { 294 for (size_t col = col0; col <= col1; ++col) {
291 for (size_t bin = 0; bin < mh; ++bin) { 295 for (size_t bin = 0; bin < mh; ++bin) {
292 float value = m_sliceableModel->getValueAt(col, bin); 296 float value = m_sliceableModel->getValueAt(col, bin);
293 if (m_bias) value *= bin + 1; 297 if (bin < cs) value *= curve[bin];
294 if (m_samplingMode == SamplePeak) { 298 if (m_samplingMode == SamplePeak) {
295 if (value > m_values[bin]) m_values[bin] = value; 299 if (value > m_values[bin]) m_values[bin] = value;
296 } else { 300 } else {
297 m_values[bin] += value; 301 m_values[bin] += value;
298 } 302 }