Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove peak value references from Mixer::getPeakValues #4513

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ class LMMS_EXPORT Mixer : public QObject
}


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;
Expand Down
8 changes: 3 additions & 5 deletions src/core/FxMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 5 additions & 3 deletions src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -553,6 +553,8 @@ void Mixer::getPeakValues( sampleFrame * _ab, const f_cnt_t _frames, float & pea
peakRight = absRight;
}
}

return StereoSample(peakLeft, peakRight);
}


Expand Down
6 changes: 2 additions & 4 deletions src/gui/widgets/VisualizationWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>( peakLeft, peakRight );
Mixer::StereoSample peakValues = mixer->getPeakValues(m_buffer, frames);
const float max_level = qMax<float>( peakValues.left, peakValues.right );

// and set color according to that...
if( max_level * master_output < 0.9 )
Expand Down