Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 585:f4960f8ce798 debug-output
Convert many cerrs to DEBUGs
author | Chris Cannam |
---|---|
date | Mon, 16 May 2011 17:19:25 +0100 |
parents | 1fe7951a61e8 |
children | 4806715f7a19 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Thu May 12 17:31:43 2011 +0100 +++ b/layer/SpectrogramLayer.cpp Mon May 16 17:19:25 2011 +0100 @@ -578,10 +578,10 @@ const View *v = i->first; #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::invalidateImageCaches(" + DEBUG << "SpectrogramLayer::invalidateImageCaches(" << startFrame << ", " << endFrame << "): view range is " << v->getStartFrame() << ", " << v->getEndFrame() - << std::endl; + << endl; std::cerr << "Valid area was: " << i->second.validArea.x() << ", " << i->second.validArea.y() << " " @@ -598,7 +598,7 @@ } int x = v->getXForFrame(startFrame); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "clipping from 0 to " << x-1 << std::endl; + DEBUG << "clipping from 0 to " << x-1 << endl; #endif if (x > 1) { i->second.validArea &= @@ -615,8 +615,8 @@ } int x = v->getXForFrame(endFrame); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "clipping from " << x+1 << " to " << v->width() - << std::endl; + DEBUG << "clipping from " << x+1 << " to " << v->width() + << endl; #endif if (x < v->width()) { i->second.validArea &= @@ -638,7 +638,7 @@ void SpectrogramLayer::preferenceChanged(PropertyContainer::PropertyName name) { - std::cerr << "SpectrogramLayer::preferenceChanged(" << name << ")" << std::endl; + DEBUG << "SpectrogramLayer::preferenceChanged(" << name << ")" << endl; if (name == "Window Type") { setWindowType(Preferences::getInstance()->getWindowType()); @@ -764,8 +764,8 @@ void SpectrogramLayer::setGain(float gain) { -// std::cerr << "SpectrogramLayer::setGain(" << gain << ") (my gain is now " -// << m_gain << ")" << std::endl; +// DEBUG << "SpectrogramLayer::setGain(" << gain << ") (my gain is now " +// << m_gain << ")" << endl; if (m_gain == gain) return; @@ -805,7 +805,7 @@ { if (m_minFrequency == mf) return; -// std::cerr << "SpectrogramLayer::setMinFrequency: " << mf << std::endl; +// DEBUG << "SpectrogramLayer::setMinFrequency: " << mf << endl; invalidateImageCaches(); invalidateMagnitudes(); @@ -826,7 +826,7 @@ { if (m_maxFrequency == mf) return; -// std::cerr << "SpectrogramLayer::setMaxFrequency: " << mf << std::endl; +// DEBUG << "SpectrogramLayer::setMaxFrequency: " << mf << endl; invalidateImageCaches(); invalidateMagnitudes(); @@ -951,8 +951,8 @@ void SpectrogramLayer::setNormalizeVisibleArea(bool n) { - std::cerr << "SpectrogramLayer::setNormalizeVisibleArea(" << n - << ") (from " << m_normalizeVisibleArea << ")" << std::endl; + DEBUG << "SpectrogramLayer::setNormalizeVisibleArea(" << n + << ") (from " << m_normalizeVisibleArea << ")" << endl; if (m_normalizeVisibleArea == n) return; @@ -975,8 +975,8 @@ if (dormant) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::setLayerDormant(" << dormant << ")" - << std::endl; + DEBUG << "SpectrogramLayer::setLayerDormant(" << dormant << ")" + << endl; #endif if (isLayerDormant(v)) { @@ -1020,7 +1020,7 @@ SpectrogramLayer::cacheInvalid() { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::cacheInvalid()" << std::endl; + DEBUG << "SpectrogramLayer::cacheInvalid()" << endl; #endif invalidateImageCaches(); @@ -1031,7 +1031,7 @@ SpectrogramLayer::cacheInvalid(size_t from, size_t to) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::cacheInvalid(" << from << ", " << to << ")" << std::endl; + DEBUG << "SpectrogramLayer::cacheInvalid(" << from << ", " << to << ")" << endl; #endif invalidateImageCaches(from, to); @@ -1046,7 +1046,7 @@ bool allDone = true; #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::fillTimerTimedOut: have " << m_fftModels.size() << " FFT models associated with views" << std::endl; + DEBUG << "SpectrogramLayer::fillTimerTimedOut: have " << m_fftModels.size() << " FFT models associated with views" << endl; #endif for (ViewFFTMap::iterator i = m_fftModels.begin(); @@ -1060,7 +1060,7 @@ size_t fill = model->getFillExtent(); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::fillTimerTimedOut: extent for " << model << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << std::endl; + DEBUG << "SpectrogramLayer::fillTimerTimedOut: extent for " << model << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << endl; #endif if (fill >= lastFill) { @@ -1629,13 +1629,13 @@ if (m_fftModels.find(v) != m_fftModels.end()) { if (m_fftModels[v].first == 0) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::getFFTModel(" << v << "): Found null model" << std::endl; + DEBUG << "SpectrogramLayer::getFFTModel(" << v << "): Found null model" << endl; #endif return 0; } if (m_fftModels[v].first->getHeight() != fftSize / 2 + 1) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::getFFTModel(" << v << "): Found a model with the wrong height (" << m_fftModels[v].first->getHeight() << ", wanted " << (fftSize / 2 + 1) << ")" << std::endl; + DEBUG << "SpectrogramLayer::getFFTModel(" << v << "): Found a model with the wrong height (" << m_fftModels[v].first->getHeight() << ", wanted " << (fftSize / 2 + 1) << ")" << endl; #endif delete m_fftModels[v].first; m_fftModels.erase(v); @@ -1643,7 +1643,7 @@ m_peakCaches.erase(v); } else { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::getFFTModel(" << v << "): Found a good model of height " << m_fftModels[v].first->getHeight() << std::endl; + DEBUG << "SpectrogramLayer::getFFTModel(" << v << "): Found a good model of height " << m_fftModels[v].first->getHeight() << endl; #endif return m_fftModels[v].first; } @@ -1764,7 +1764,7 @@ int s0 = int(std::min(s00, s10) + 0.0001); 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; +// DEBUG << "SpectrogramLayer::updateViewMagnitudes: x0 = " << x0 << ", x1 = " << x1 << ", s00 = " << s00 << ", s11 = " << s11 << " s0 = " << s0 << ", s1 = " << s1 << endl; if (int(m_columnMags.size()) <= s1) { m_columnMags.resize(s1 + 1); @@ -1777,8 +1777,8 @@ } #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::updateViewMagnitudes returning from cols " - << s0 << " -> " << s1 << " inclusive" << std::endl; + DEBUG << "SpectrogramLayer::updateViewMagnitudes returning from cols " + << s0 << " -> " << s1 << " inclusive" << endl; #endif if (!mag.isSet()) return false; @@ -1802,7 +1802,7 @@ Profiler profiler("SpectrogramLayer::paint", false); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << std::endl; + DEBUG << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << endl; std::cerr << "rect is " << rect.x() << "," << rect.y() << " " << rect.width() << "x" << rect.height() << std::endl; #endif @@ -1816,7 +1816,7 @@ } if (isLayerDormant(v)) { - std::cerr << "SpectrogramLayer::paint(): Layer is dormant, making it undormant again" << std::endl; + DEBUG << "SpectrogramLayer::paint(): Layer is dormant, making it undormant again" << endl; } // Need to do this even if !isLayerDormant, as that could mean v @@ -1837,14 +1837,14 @@ ImageCache &cache = m_imageCaches[v]; #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint(): image cache valid area " << cache. - -validArea.x() << ", " << cache.validArea.y() << ", " << cache.validArea.width() << "x" << cache.validArea.height() << std::endl; + DEBUG << "SpectrogramLayer::paint(): image cache valid area " << cache. + +validArea.x() << ", " << cache.validArea.y() << ", " << cache.validArea.width() << "x" << cache.validArea.height() << endl; #endif #ifdef DEBUG_SPECTROGRAM_REPAINT bool stillCacheing = (m_updateTimer != 0); - std::cerr << "SpectrogramLayer::paint(): Still cacheing = " << stillCacheing << std::endl; + DEBUG << "SpectrogramLayer::paint(): Still cacheing = " << stillCacheing << endl; #endif int zoomLevel = v->getZoomLevel(); @@ -2202,7 +2202,7 @@ bool runOutOfData = false; if (w == 0) { - std::cerr << "*** NOTE: w == 0" << std::endl; + DEBUG << "*** NOTE: w == 0" << endl; } #ifdef DEBUG_SPECTROGRAM_REPAINT @@ -2363,18 +2363,18 @@ if (recreateWholeImageCache) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "Recreating image cache: width = " << v->width() - << ", height = " << h << std::endl; + DEBUG << "Recreating image cache: width = " << v->width() + << ", height = " << h << endl; #endif cache.image = QImage(v->width(), h, QImage::Format_ARGB32_Premultiplied); } if (w > 0) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "Painting " << w << "x" << h + DEBUG << "Painting " << w << "x" << h << " from draw buffer at " << 0 << "," << 0 << " to " << w << "x" << h << " on cache at " - << x0 << "," << 0 << std::endl; + << x0 << "," << 0 << endl; #endif QPainter cachePainter(&cache.image); @@ -2383,13 +2383,13 @@ int scaledLeft = v->getXForFrame(leftBoundaryFrame); int scaledRight = v->getXForFrame(rightBoundaryFrame); #ifdef DEBUG_SPECTROGRAM_REPAINT - cerr << "Rescaling image from " << bufwid + DEBUG << "Rescaling image from " << bufwid << "x" << h << " to " << scaledRight-scaledLeft << "x" << h << endl; #endif Preferences::SpectrogramXSmoothing xsmoothing = Preferences::getInstance()->getSpectrogramXSmoothing(); -// cerr << "xsmoothing == " << xsmoothing << endl; +// DEBUG << "xsmoothing == " << xsmoothing << endl; QImage scaled = m_drawBuffer.scaled (scaledRight - scaledLeft, h, Qt::IgnoreAspectRatio, @@ -2398,7 +2398,7 @@ int scaledLeftCrop = v->getXForFrame(leftCropFrame); int scaledRightCrop = v->getXForFrame(rightCropFrame); #ifdef DEBUG_SPECTROGRAM_REPAINT - cerr << "Drawing image region of width " << scaledRightCrop - scaledLeftCrop << " to " + DEBUG << "Drawing image region of width " << scaledRightCrop - scaledLeftCrop << " to " << scaledLeftCrop << " from " << scaledLeftCrop - scaledLeft << endl; #endif cachePainter.drawImage @@ -2419,9 +2419,9 @@ QRect pr = rect & cache.validArea; #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "Painting " << pr.width() << "x" << pr.height() + DEBUG << "Painting " << pr.width() << "x" << pr.height() << " from cache at " << pr.x() << "," << pr.y() - << " to window" << std::endl; + << " to window" << endl; #endif paint.drawImage(pr.x(), pr.y(), cache.image, @@ -2439,8 +2439,8 @@ if (cache.validArea.x() > 0) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint() updating left (0, " - << cache.validArea.x() << ")" << std::endl; + DEBUG << "SpectrogramLayer::paint() updating left (0, " + << cache.validArea.x() << ")" << endl; #endif v->update(0, 0, cache.validArea.x(), h); } @@ -2448,12 +2448,12 @@ if (cache.validArea.x() + cache.validArea.width() < cache.image.width()) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint() updating right (" + DEBUG << "SpectrogramLayer::paint() updating right (" << cache.validArea.x() + cache.validArea.width() << ", " << cache.image.width() - (cache.validArea.x() + cache.validArea.width()) - << ")" << std::endl; + << ")" << endl; #endif v->update(cache.validArea.x() + cache.validArea.width(), 0, @@ -2472,7 +2472,7 @@ illuminateLocalFeatures(v, paint); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint() returning" << std::endl; + DEBUG << "SpectrogramLayer::paint() returning" << endl; #endif if (!m_synchronous) { @@ -2707,7 +2707,7 @@ if (sx != psx) { if (fft) { #ifdef DEBUG_SPECTROGRAM_REPAINT - cerr << "Retrieving column " << sx << " from fft directly" << endl; + DEBUG << "Retrieving column " << sx << " from fft directly" << endl; #endif if (m_colourScale == PhaseColourScale) { fft->getPhasesAt(sx, autoarray, minbin, maxbin - minbin + 1); @@ -2718,7 +2718,7 @@ } } else { #ifdef DEBUG_SPECTROGRAM_REPAINT - cerr << "Retrieving column " << sx << " from peaks cache" << endl; + DEBUG << "Retrieving column " << sx << " from peaks cache" << endl; #endif c = sourceModel->getColumn(sx); if (m_normalizeColumns) { @@ -2900,7 +2900,7 @@ size_t completion = m_fftModels[v].first->getCompletion(); #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; + DEBUG << "SpectrogramLayer::getCompletion: completion = " << completion << endl; #endif return completion; } @@ -2933,7 +2933,7 @@ min = getEffectiveMinFrequency(); max = getEffectiveMaxFrequency(); -// std::cerr << "SpectrogramLayer::getDisplayExtents: " << min << "->" << max << std::endl; +// DEBUG << "SpectrogramLayer::getDisplayExtents: " << min << "->" << max << endl; return true; } @@ -2942,7 +2942,7 @@ { if (!m_model) return false; -// std::cerr << "SpectrogramLayer::setDisplayExtents: " << min << "->" << max << std::endl; +// DEBUG << "SpectrogramLayer::setDisplayExtents: " << min << "->" << max << endl; if (min < 0) min = 0; if (max > m_model->getSampleRate()/2) max = m_model->getSampleRate()/2; @@ -3551,7 +3551,7 @@ defaultStep = mapper.getPositionForValue(initialMax) - minStep; -// std::cerr << "SpectrogramLayer::getVerticalZoomSteps: " << maxStep - minStep << " (" << maxStep <<"-" << minStep << "), default is " << defaultStep << " (from initial max freq " << initialMax << ")" << std::endl; +// DEBUG << "SpectrogramLayer::getVerticalZoomSteps: " << maxStep - minStep << " (" << maxStep <<"-" << minStep << "), default is " << defaultStep << " (from initial max freq " << initialMax << ")" << endl; return maxStep - minStep; } @@ -3566,7 +3566,7 @@ SpectrogramRangeMapper mapper(m_model->getSampleRate(), m_fftSize); int n = mapper.getPositionForValue(dmax - dmin); -// std::cerr << "SpectrogramLayer::getCurrentVerticalZoomStep: " << n << std::endl; +// DEBUG << "SpectrogramLayer::getCurrentVerticalZoomStep: " << n << endl; return n; } @@ -3632,7 +3632,7 @@ newmax = mmax; } -// std::cerr << "SpectrogramLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << std::endl; +// DEBUG << "SpectrogramLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; setMinFrequency(lrintf(newmin)); setMaxFrequency(lrintf(newmax)); @@ -3654,7 +3654,7 @@ int y1 = y0; if (r.endY > 0.0) y1 = getYForFrequency(v, r.endY); -// std::cerr << "SpectrogramLayer::updateMeasureRectYCoords: start " << r.startY << " -> " << y0 << ", end " << r.endY << " -> " << y1 << std::endl; +// DEBUG << "SpectrogramLayer::updateMeasureRectYCoords: start " << r.startY << " -> " << y0 << ", end " << r.endY << " -> " << y1 << endl; r.pixrect = QRect(r.pixrect.x(), y0, r.pixrect.width(), y1 - y0); } @@ -3668,7 +3668,7 @@ } else { r.endY = getFrequencyForY(v, y); } -// std::cerr << "SpectrogramLayer::setMeasureRectYCoord: start " << r.startY << " <- " << y << ", end " << r.endY << " <- " << y << std::endl; +// DEBUG << "SpectrogramLayer::setMeasureRectYCoord: start " << r.startY << " <- " << y << ", end " << r.endY << " <- " << y << endl; } @@ -3744,13 +3744,13 @@ size_t minFrequency = attributes.value("minFrequency").toUInt(&ok); if (ok) { - std::cerr << "SpectrogramLayer::setProperties: setting min freq to " << minFrequency << std::endl; + DEBUG << "SpectrogramLayer::setProperties: setting min freq to " << minFrequency << endl; setMinFrequency(minFrequency); } size_t maxFrequency = attributes.value("maxFrequency").toUInt(&ok); if (ok) { - std::cerr << "SpectrogramLayer::setProperties: setting max freq to " << maxFrequency << std::endl; + DEBUG << "SpectrogramLayer::setProperties: setting max freq to " << maxFrequency << endl; setMaxFrequency(maxFrequency); }