Mercurial > hg > svgui
changeset 1523:1ccb64bfb22b
Make the waveform layer do the expected thing when MergeChannels mode (i.e. butterfly mode) is enabled even if there is only 1 channel. This combination isn't actually available in the UI for SV, but it's useful for Sonic Lineup.
author | Chris Cannam |
---|---|
date | Wed, 25 Sep 2019 13:42:17 +0100 |
parents | 872873aa6463 |
children | 4fab699536f9 |
files | layer/WaveformLayer.cpp |
diffstat | 1 files changed, 26 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp Tue Sep 17 12:50:58 2019 +0100 +++ b/layer/WaveformLayer.cpp Wed Sep 25 13:42:17 2019 +0100 @@ -404,7 +404,17 @@ channels = 1; } - merging = (m_channelMode == MergeChannels && rawChannels > 1); + // "Merging" -> "butterfly mode" - use +ve side of "waveform" for + // channel 0 and -ve side for channel 1. If we only have one + // channel, we still do this but just duplicate channel 0 onto + // channel 1 - this is the only way to get a classic-looking + // waveform with meter or db scale from a single-channel file, + // although it isn't currently exposed in the SV UI + merging = (m_channelMode == MergeChannels); + + // "Mixing" -> produce a single waveform from the mean of the + // channels. Unlike merging, this really does only make sense if + // we have >1 channel. mixing = (m_channelMode == MixChannels && rawChannels > 1); // SVDEBUG << "WaveformLayer::getChannelArrangement: min " << min << ", max " << max << ", merging " << merging << ", channels " << channels << endl; @@ -485,11 +495,13 @@ mergingChannels, mixingChannels); if (mergingChannels || mixingChannels) { - RangeSummarisableTimeValueModel::Range otherRange = - model->getSummary(1, rangeStart, rangeEnd - rangeStart); - range.setMax(std::max(range.max(), otherRange.max())); - range.setMin(std::min(range.min(), otherRange.min())); - range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); + if (model->getChannelCount() > 1) { + RangeSummarisableTimeValueModel::Range otherRange = + model->getSummary(1, rangeStart, rangeEnd - rangeStart); + range.setMax(std::max(range.max(), otherRange.max())); + range.setMin(std::min(range.min(), otherRange.min())); + range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); + } } return float(1.0 / std::max(fabs(range.max()), fabs(range.min()))); @@ -688,6 +700,8 @@ ranges.push_back({}); model->getSummaries (1, frame0, frame1 - frame0, ranges[1], blockSize); + } else { + ranges.push_back(ranges[0]); } } } @@ -712,6 +726,12 @@ getOversampledRanges (0, 1, false, frame0, frame1, oversampleBy, ranges); return; + } else { + // call back on self for a single channel, then duplicate + getOversampledRanges + (0, 0, false, frame0, frame1, oversampleBy, ranges); + ranges.push_back(ranges[0]); + return; } }