comparison layer/WaveformLayer.cpp @ 76:45ba0b381c5d

* Fix long-standing off-by-1 bug in WaveFileModel that was getting us the wrong values for almost all audio data when merging channels (channel == -1) * Implement cut, copy and paste * Make draw mode work properly in time value layer * Minor fixes to CSV import
author Chris Cannam
date Fri, 07 Apr 2006 17:50:33 +0000
parents 72fa239a4880
children 19bf27e4fb29
comparison
equal deleted inserted replaced
75:dfdbf336bb37 76:45ba0b381c5d
890 if (ch == 0) label = tr("Left:"); 890 if (ch == 0) label = tr("Left:");
891 else if (ch == 1) label = tr("Right:"); 891 else if (ch == 1) label = tr("Right:");
892 else label = tr("Channel %1").arg(ch + 1); 892 else label = tr("Channel %1").arg(ch + 1);
893 } 893 }
894 894
895 int min = int(range.min * 1000); 895 bool singleValue = false;
896 int max = int(range.max * 1000); 896 float min, max;
897
898 if (fabs(range.min) < 0.01) {
899 min = range.min;
900 max = range.max;
901 singleValue = (min == max);
902 } else {
903 int imin = int(range.min * 1000);
904 int imax = int(range.max * 1000);
905 singleValue = (imin == imax);
906 min = float(imin)/1000;
907 max = float(imax)/1000;
908 }
909
897 int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min), 910 int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min),
898 fabsf(range.max))) 911 fabsf(range.max)))
899 * 100); 912 * 100);
900 913
901 if (min != max) { 914 if (!singleValue) {
902 text += tr("\n%1\t%2 - %3 (%4 dB peak)") 915 text += tr("\n%1\t%2 - %3 (%4 dB peak)")
903 .arg(label).arg(float(min)/1000).arg(float(max)/1000).arg(float(db)/100); 916 .arg(label).arg(min).arg(max).arg(float(db)/100);
904 } else { 917 } else {
905 text += tr("\n%1\t%2 (%3 dB peak)") 918 text += tr("\n%1\t%2 (%3 dB peak)")
906 .arg(label).arg(float(min)/1000).arg(float(db)/100); 919 .arg(label).arg(min).arg(float(db)/100);
907 } 920 }
908 } 921 }
909 922
910 return text; 923 return text;
911 } 924 }