From 8856216d861a71ce67bf847d843e12623240b86a Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 26 Sep 2013 22:54:06 -0700 Subject: [PATCH] Timeline: Fix normalization of multi-channel regions. --- timeline/src/Audio_Region.C | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/timeline/src/Audio_Region.C b/timeline/src/Audio_Region.C index f734b8d..d70ed37 100644 --- a/timeline/src/Audio_Region.C +++ b/timeline/src/Audio_Region.C @@ -912,9 +912,19 @@ Audio_Region::normalize ( void ) const nframes_t npeaks = _loop ? _loop : length(); + if ( _clip->read_peaks( npeaks, offset(), offset() + npeaks, &peaks, &pbuf, &channels ) && peaks ) - _scale = pbuf->normalization_factor(); + { + _scale = 1000.0f; + + for ( int i = 0; i < channels; i++ ) + { + float f = (pbuf + i)->normalization_factor(); + if ( f < _scale ) + _scale = f; + } + } /* FIXME: wrong place for this? */ sequence()->handle_widget_change( start(), length() );