From 14fe11f4d4a3011a9d7c1dd8881937001ff38684 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 7 Oct 2018 10:29:58 -0400 Subject: [PATCH] Bug2008: There was error in stereo Contrast calculation, at aee4005 --- src/effects/Contrast.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index b3006670c..a24715ff7 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -62,7 +62,8 @@ bool ContrastDialog::GetDB(float &dB) return false; } - for ( auto t : TrackList::Channels( *range.begin() ) ) { + const auto channels = TrackList::Channels( *range.begin() ); + for ( auto t : channels ) { wxASSERT(mT0 <= mT1); // Ignore whitespace beyond ends of track. @@ -94,7 +95,9 @@ bool ContrastDialog::GetDB(float &dB) } // TODO: This works for stereo, provided the audio clips are in both channels. // We should really count gaps between clips as silence. - rms = (meanSq > 0.0)? sqrt(meanSq/(double)numberSelectedTracks) : 0.0; + rms = (meanSq > 0.0) + ? sqrt( meanSq/static_cast( channels.size() ) ) + : 0.0; // Gives warning C4056, Overflow in floating-point constant arithmetic // -INFINITY is intentional here.