Mercurial > hg > svgui
changeset 673:b5d3dea6d869
Fix strange pixel offset in waveform rendering; round values in labels rather than flooring them
author | Chris Cannam |
---|---|
date | Wed, 09 Oct 2013 14:55:49 +0100 |
parents | ee99f5c0050c |
children | d8bd193ad17d |
files | layer/WaveformLayer.cpp |
diffstat | 1 files changed, 12 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp Wed Oct 09 14:52:09 2013 +0100 +++ b/layer/WaveformLayer.cpp Wed Oct 09 14:55:49 2013 +0100 @@ -670,7 +670,7 @@ *ranges, modelZoomLevel); #ifdef DEBUG_WAVEFORM_PAINT - std::cerr << ranges->size() << " ranges from " << frame0 << " to " << frame1 << std::endl; + std::cerr << "channel " << ch << ": " << ranges->size() << " ranges from " << frame0 << " to " << frame1 << " at zoom level " << modelZoomLevel << std::endl; #endif if (mergingChannels || mixingChannels) { @@ -844,18 +844,18 @@ } if (x != x0 && prevRangeBottom != -1) { - if (prevRangeBottom > rangeBottom && - prevRangeTop > rangeBottom) { + if (prevRangeBottom > rangeBottom + 1 && + prevRangeTop > rangeBottom + 1) { // paint->setPen(midColour); paint->setPen(baseColour); - paint->drawLine(x-1, prevRangeTop, x, rangeBottom); + paint->drawLine(x-1, prevRangeTop, x, rangeBottom + 1); paint->setPen(prevRangeTopColour); paint->drawPoint(x-1, prevRangeTop); - } else if (prevRangeBottom < rangeTop && - prevRangeTop < rangeTop) { + } else if (prevRangeBottom < rangeTop - 1 && + prevRangeTop < rangeTop - 1) { // paint->setPen(midColour); paint->setPen(baseColour); - paint->drawLine(x-1, prevRangeBottom, x, rangeTop); + paint->drawLine(x-1, prevRangeBottom, x, rangeTop - 1); paint->setPen(prevRangeBottomColour); paint->drawPoint(x-1, prevRangeBottom); } @@ -874,7 +874,7 @@ } #ifdef DEBUG_WAVEFORM_PAINT - std::cerr << "range " << rangeBottom << " -> " << rangeTop << std::endl; + std::cerr << "range " << rangeBottom << " -> " << rangeTop << ", means " << meanBottom << " -> " << meanTop << ", raw range " << range.min() << " -> " << range.max() << std::endl; #endif if (rangeTop == rangeBottom) { @@ -990,11 +990,11 @@ max = range.max(); singleValue = (min == max); } else { - int imin = int(range.min() * 1000); - int imax = int(range.max() * 1000); + int imin = lrint(range.min() * 10000); + int imax = lrint(range.max() * 10000); singleValue = (imin == imax); - min = float(imin)/1000; - max = float(imax)/1000; + min = float(imin)/10000; + max = float(imax)/10000; } int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()),