diff --git a/include/Mixer.h b/include/Mixer.h index bd057753a..743547b0f 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -273,7 +273,13 @@ public: } - void getPeakValues( sampleFrame * _ab, const f_cnt_t _frames, float & peakLeft, float & peakRight ) const; + struct StereoSample + { + StereoSample(sample_t _left, sample_t _right) : left(_left), right(_right) {} + sample_t left; + sample_t right; + }; + StereoSample getPeakValues(sampleFrame * _ab, const f_cnt_t _frames) const; bool criticalXRuns() const; diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index 51e66939a..0e5f200d6 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -170,11 +170,9 @@ void FxChannel::doProcessing() m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput ); - float peakLeft = 0.; - float peakRight = 0.; - Engine::mixer()->getPeakValues( m_buffer, fpp, peakLeft, peakRight ); - m_peakLeft = qMax( m_peakLeft, peakLeft * v ); - m_peakRight = qMax( m_peakRight, peakRight * v ); + Mixer::StereoSample peakSamples = Engine::mixer()->getPeakValues(m_buffer, fpp); + m_peakLeft = qMax( m_peakLeft, peakSamples.left * v ); + m_peakRight = qMax( m_peakRight, peakSamples.right * v ); } else { diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 07a9d592f..f34f9dbbc 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -534,10 +534,10 @@ void Mixer::clearInternal() -void Mixer::getPeakValues( sampleFrame * _ab, const f_cnt_t _frames, float & peakLeft, float & peakRight ) const +Mixer::StereoSample Mixer::getPeakValues(sampleFrame * _ab, const f_cnt_t _frames) const { - peakLeft = 0.0f; - peakRight = 0.0f; + sample_t peakLeft = 0.0f; + sample_t peakRight = 0.0f; for( f_cnt_t f = 0; f < _frames; ++f ) { @@ -553,6 +553,8 @@ void Mixer::getPeakValues( sampleFrame * _ab, const f_cnt_t _frames, float & pea peakRight = absRight; } } + + return StereoSample(peakLeft, peakRight); } diff --git a/src/gui/widgets/VisualizationWidget.cpp b/src/gui/widgets/VisualizationWidget.cpp index 00521f7bc..df0012816 100644 --- a/src/gui/widgets/VisualizationWidget.cpp +++ b/src/gui/widgets/VisualizationWidget.cpp @@ -131,10 +131,8 @@ void VisualizationWidget::paintEvent( QPaintEvent * ) const fpp_t frames = mixer->framesPerPeriod(); - float peakLeft; - float peakRight; - mixer->getPeakValues( m_buffer, frames, peakLeft, peakRight ); - const float max_level = qMax( peakLeft, peakRight ); + Mixer::StereoSample peakValues = mixer->getPeakValues(m_buffer, frames); + const float max_level = qMax( peakValues.left, peakValues.right ); // and set color according to that... if( max_level * master_output < 0.9 )