From 5ed8f7063353ffc06ac439311ab1ff4656d7d96a Mon Sep 17 00:00:00 2001 From: Vesa Date: Mon, 14 Jul 2014 21:49:34 +0300 Subject: [PATCH] Mixer: optimize peak value measuring functions --- src/core/Mixer.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index c9fd9b83c..7006c5c5c 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -518,14 +518,7 @@ float Mixer::peakValueLeft( sampleFrame * _ab, const f_cnt_t _frames ) float p = 0.0f; for( f_cnt_t f = 0; f < _frames; ++f ) { - if( _ab[f][0] > p ) - { - p = _ab[f][0]; - } - else if( -_ab[f][0] > p ) - { - p = -_ab[f][0]; - } + p = qMax( p, qAbs( _ab[f][0] ) ); } return p; } @@ -538,14 +531,7 @@ float Mixer::peakValueRight( sampleFrame * _ab, const f_cnt_t _frames ) float p = 0.0f; for( f_cnt_t f = 0; f < _frames; ++f ) { - if( _ab[f][1] > p ) - { - p = _ab[f][1]; - } - else if( -_ab[f][1] > p ) - { - p = -_ab[f][1]; - } + p = qMax( p, qAbs( _ab[f][1] ) ); } return p; }