Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 1524:4fab699536f9
Merge
author | Chris Cannam |
---|---|
date | Wed, 25 Sep 2019 14:11:42 +0100 |
parents | 1ccb64bfb22b |
children | 10fe8124dc17 |
comparison
equal
deleted
inserted
replaced
1522:d5ef91dc2ea7 | 1524:4fab699536f9 |
---|---|
402 max = m_channel; | 402 max = m_channel; |
403 rawChannels = 1; | 403 rawChannels = 1; |
404 channels = 1; | 404 channels = 1; |
405 } | 405 } |
406 | 406 |
407 merging = (m_channelMode == MergeChannels && rawChannels > 1); | 407 // "Merging" -> "butterfly mode" - use +ve side of "waveform" for |
408 // channel 0 and -ve side for channel 1. If we only have one | |
409 // channel, we still do this but just duplicate channel 0 onto | |
410 // channel 1 - this is the only way to get a classic-looking | |
411 // waveform with meter or db scale from a single-channel file, | |
412 // although it isn't currently exposed in the SV UI | |
413 merging = (m_channelMode == MergeChannels); | |
414 | |
415 // "Mixing" -> produce a single waveform from the mean of the | |
416 // channels. Unlike merging, this really does only make sense if | |
417 // we have >1 channel. | |
408 mixing = (m_channelMode == MixChannels && rawChannels > 1); | 418 mixing = (m_channelMode == MixChannels && rawChannels > 1); |
409 | 419 |
410 // SVDEBUG << "WaveformLayer::getChannelArrangement: min " << min << ", max " << max << ", merging " << merging << ", channels " << channels << endl; | 420 // SVDEBUG << "WaveformLayer::getChannelArrangement: min " << min << ", max " << max << ", merging " << merging << ", channels " << channels << endl; |
411 | 421 |
412 return channels; | 422 return channels; |
483 | 493 |
484 (void)getChannelArrangement(minChannel, maxChannel, | 494 (void)getChannelArrangement(minChannel, maxChannel, |
485 mergingChannels, mixingChannels); | 495 mergingChannels, mixingChannels); |
486 | 496 |
487 if (mergingChannels || mixingChannels) { | 497 if (mergingChannels || mixingChannels) { |
488 RangeSummarisableTimeValueModel::Range otherRange = | 498 if (model->getChannelCount() > 1) { |
489 model->getSummary(1, rangeStart, rangeEnd - rangeStart); | 499 RangeSummarisableTimeValueModel::Range otherRange = |
490 range.setMax(std::max(range.max(), otherRange.max())); | 500 model->getSummary(1, rangeStart, rangeEnd - rangeStart); |
491 range.setMin(std::min(range.min(), otherRange.min())); | 501 range.setMax(std::max(range.max(), otherRange.max())); |
492 range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); | 502 range.setMin(std::min(range.min(), otherRange.min())); |
503 range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); | |
504 } | |
493 } | 505 } |
494 | 506 |
495 return float(1.0 / std::max(fabs(range.max()), fabs(range.min()))); | 507 return float(1.0 / std::max(fabs(range.max()), fabs(range.min()))); |
496 } | 508 } |
497 | 509 |
686 throw std::logic_error("Internal error: min & max channels should be 0 when merging or mixing all channels"); | 698 throw std::logic_error("Internal error: min & max channels should be 0 when merging or mixing all channels"); |
687 } else if (model->getChannelCount() > 1) { | 699 } else if (model->getChannelCount() > 1) { |
688 ranges.push_back({}); | 700 ranges.push_back({}); |
689 model->getSummaries | 701 model->getSummaries |
690 (1, frame0, frame1 - frame0, ranges[1], blockSize); | 702 (1, frame0, frame1 - frame0, ranges[1], blockSize); |
703 } else { | |
704 ranges.push_back(ranges[0]); | |
691 } | 705 } |
692 } | 706 } |
693 } | 707 } |
694 | 708 |
695 void | 709 void |
709 if (model->getChannelCount() > 1) { | 723 if (model->getChannelCount() > 1) { |
710 // call back on self for the individual channels with | 724 // call back on self for the individual channels with |
711 // mixingOrMerging false | 725 // mixingOrMerging false |
712 getOversampledRanges | 726 getOversampledRanges |
713 (0, 1, false, frame0, frame1, oversampleBy, ranges); | 727 (0, 1, false, frame0, frame1, oversampleBy, ranges); |
728 return; | |
729 } else { | |
730 // call back on self for a single channel, then duplicate | |
731 getOversampledRanges | |
732 (0, 0, false, frame0, frame1, oversampleBy, ranges); | |
733 ranges.push_back(ranges[0]); | |
714 return; | 734 return; |
715 } | 735 } |
716 } | 736 } |
717 | 737 |
718 // These frame values, tail length, etc variables are at the model | 738 // These frame values, tail length, etc variables are at the model |