comparison layer/WaveformLayer.cpp @ 680:ced5f158eda7 tonioni

Merge from default branch
author Chris Cannam
date Fri, 22 Nov 2013 10:40:51 +0000
parents b5d3dea6d869
children 26c5f7fd4807 1a0dfcbffaf1
comparison
equal deleted inserted replaced
670:47735c9518e7 680:ced5f158eda7
668 668
669 m_model->getSummaries(ch, frame0, frame1 - frame0, 669 m_model->getSummaries(ch, frame0, frame1 - frame0,
670 *ranges, modelZoomLevel); 670 *ranges, modelZoomLevel);
671 671
672 #ifdef DEBUG_WAVEFORM_PAINT 672 #ifdef DEBUG_WAVEFORM_PAINT
673 std::cerr << ranges->size() << " ranges from " << frame0 << " to " << frame1 << std::endl; 673 std::cerr << "channel " << ch << ": " << ranges->size() << " ranges from " << frame0 << " to " << frame1 << " at zoom level " << modelZoomLevel << std::endl;
674 #endif 674 #endif
675 675
676 if (mergingChannels || mixingChannels) { 676 if (mergingChannels || mixingChannels) {
677 if (m_model->getChannelCount() > 1) { 677 if (m_model->getChannelCount() > 1) {
678 if (!otherChannelRanges) { 678 if (!otherChannelRanges) {
842 if (meanBottom > meanTop) --meanBottom; 842 if (meanBottom > meanTop) --meanBottom;
843 else drawMean = false; 843 else drawMean = false;
844 } 844 }
845 845
846 if (x != x0 && prevRangeBottom != -1) { 846 if (x != x0 && prevRangeBottom != -1) {
847 if (prevRangeBottom > rangeBottom && 847 if (prevRangeBottom > rangeBottom + 1 &&
848 prevRangeTop > rangeBottom) { 848 prevRangeTop > rangeBottom + 1) {
849 // paint->setPen(midColour); 849 // paint->setPen(midColour);
850 paint->setPen(baseColour); 850 paint->setPen(baseColour);
851 paint->drawLine(x-1, prevRangeTop, x, rangeBottom); 851 paint->drawLine(x-1, prevRangeTop, x, rangeBottom + 1);
852 paint->setPen(prevRangeTopColour); 852 paint->setPen(prevRangeTopColour);
853 paint->drawPoint(x-1, prevRangeTop); 853 paint->drawPoint(x-1, prevRangeTop);
854 } else if (prevRangeBottom < rangeTop && 854 } else if (prevRangeBottom < rangeTop - 1 &&
855 prevRangeTop < rangeTop) { 855 prevRangeTop < rangeTop - 1) {
856 // paint->setPen(midColour); 856 // paint->setPen(midColour);
857 paint->setPen(baseColour); 857 paint->setPen(baseColour);
858 paint->drawLine(x-1, prevRangeBottom, x, rangeTop); 858 paint->drawLine(x-1, prevRangeBottom, x, rangeTop - 1);
859 paint->setPen(prevRangeBottomColour); 859 paint->setPen(prevRangeBottomColour);
860 paint->drawPoint(x-1, prevRangeBottom); 860 paint->drawPoint(x-1, prevRangeBottom);
861 } 861 }
862 } 862 }
863 863
872 } else { 872 } else {
873 paint->setPen(midColour); 873 paint->setPen(midColour);
874 } 874 }
875 875
876 #ifdef DEBUG_WAVEFORM_PAINT 876 #ifdef DEBUG_WAVEFORM_PAINT
877 std::cerr << "range " << rangeBottom << " -> " << rangeTop << std::endl; 877 std::cerr << "range " << rangeBottom << " -> " << rangeTop << ", means " << meanBottom << " -> " << meanTop << ", raw range " << range.min() << " -> " << range.max() << std::endl;
878 #endif 878 #endif
879 879
880 if (rangeTop == rangeBottom) { 880 if (rangeTop == rangeBottom) {
881 paint->drawPoint(x, rangeTop); 881 paint->drawPoint(x, rangeTop);
882 } else { 882 } else {
988 if (fabs(range.min()) < 0.01) { 988 if (fabs(range.min()) < 0.01) {
989 min = range.min(); 989 min = range.min();
990 max = range.max(); 990 max = range.max();
991 singleValue = (min == max); 991 singleValue = (min == max);
992 } else { 992 } else {
993 int imin = int(range.min() * 1000); 993 int imin = lrint(range.min() * 10000);
994 int imax = int(range.max() * 1000); 994 int imax = lrint(range.max() * 10000);
995 singleValue = (imin == imax); 995 singleValue = (imin == imax);
996 min = float(imin)/1000; 996 min = float(imin)/10000;
997 max = float(imax)/1000; 997 max = float(imax)/10000;
998 } 998 }
999 999
1000 int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()), 1000 int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()),
1001 fabsf(range.max()))) 1001 fabsf(range.max())))
1002 * 100); 1002 * 100);