From 9cb52ccf0d84b31945b86cbf419db854c0d91204 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 18 Jan 2014 14:00:09 +0100 Subject: [PATCH] Revert "Extensions for peak controller. Fulfills request 144." The change breaks existing projects that use PeakController (i.e. they sound completely different which is not acceptable) as there's no sane default value for the new amount multiply model (why do we need it at all BTW instead of just advancing the range of the existing amount model?) and the changed math results in calculation of completely different RMS values. This reverts commit 5e8dbb615728b89775a2ca6252f83623d4251e86. --- .../peak_controller_effect.cpp | 37 +++---------------- .../peak_controller_effect.h | 1 - .../peak_controller_effect_control_dialog.cpp | 29 ++------------- .../peak_controller_effect_control_dialog.h | 4 -- .../peak_controller_effect_controls.cpp | 13 +------ .../peak_controller_effect_controls.h | 3 -- 6 files changed, 11 insertions(+), 76 deletions(-) diff --git a/plugins/peak_controller_effect/peak_controller_effect.cpp b/plugins/peak_controller_effect/peak_controller_effect.cpp index a9fa562861..0d62c39331 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect.cpp @@ -64,7 +64,6 @@ PeakControllerEffect::PeakControllerEffect( m_peakControls( this ), m_lastSample( 0 ), m_lastRMS( -1 ), - m_lastRMSavail(false), m_autoController( NULL ) { m_autoController = new PeakController( engine::getSong(), this ); @@ -84,19 +83,13 @@ PeakControllerEffect::~PeakControllerEffect() } } -//! returns 1.0f if val > 0.0f, -1.0 else -inline float my_sign(float val) { return -1.0f + 2.0f * (val > 0.0f); } -//! if val >= 0.0f, returns sqrtf(val), else: -sqrtf(-val) -inline float sqrt_neg(float val) { - return sqrtf(fabs(val)) * my_sign(val); -} bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { PeakControllerEffectControls & c = m_peakControls; - + // This appears to be used for determining whether or not to continue processing // audio with this effect if( !isEnabled() || !isRunning() ) @@ -108,12 +101,7 @@ bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf, double sum = 0; for( int i = 0; i < _frames; ++i ) { - float sign_0 = (c.m_absModel.value()) - ? 1.0f : my_sign(_buf[i][0]); - float sign_1 = (c.m_absModel.value()) - ? 1.0f : my_sign(_buf[i][1]); - sum += _buf[i][0]*_buf[i][0]*sign_0 - + _buf[i][1]*_buf[i][1]*sign_1; + sum += _buf[i][0]*_buf[i][0] + _buf[i][1]*_buf[i][1]; } if( c.m_muteModel.value() ) @@ -124,22 +112,19 @@ bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf, } } - float curRMS = sqrt_neg( sum / _frames ); + float curRMS = sqrtf( sum / _frames ); const float origRMS = curRMS; - - if( !m_lastRMSavail ) + if( m_lastRMS < 0 ) { - m_lastRMSavail = true; m_lastRMS = curRMS; } const float v = ( curRMS >= m_lastRMS ) ? c.m_attackModel.value() : c.m_decayModel.value(); - const float a = sqrt_neg( sqrt_neg( v ) ); + const float a = sqrtf( sqrtf( v ) ); curRMS = (1-a)*curRMS + a*m_lastRMS; - const float amount = c.m_amountModel.value() * c.m_amountMultModel.value(); - m_lastSample = c.m_baseModel.value() + amount*curRMS; + m_lastSample = c.m_baseModel.value() + c.m_amountModel.value()*curRMS; m_lastRMS = curRMS; // on greater buffer sizes our LP is updated less frequently, therfore @@ -153,16 +138,6 @@ bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf, //checkGate( out_sum / _frames ); - // finally, mute the output if wanted - // TODO: avoid clips? - if( c.m_muteOutputModel.value() ) - { - for( int i = 0; i < _frames; ++i ) - { - _buf[i][0] = _buf[i][1] = 0.0f; - } - } - return isRunning(); } diff --git a/plugins/peak_controller_effect/peak_controller_effect.h b/plugins/peak_controller_effect/peak_controller_effect.h index 06e241f21c..56a81c58a1 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.h +++ b/plugins/peak_controller_effect/peak_controller_effect.h @@ -55,7 +55,6 @@ private: float m_lastSample; float m_lastRMS; - bool m_lastRMSavail; Controller * m_autoController; diff --git a/plugins/peak_controller_effect/peak_controller_effect_control_dialog.cpp b/plugins/peak_controller_effect/peak_controller_effect_control_dialog.cpp index d38bb93e56..b16f666e71 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_control_dialog.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_control_dialog.cpp @@ -44,11 +44,10 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - setFixedSize( 288, 110 ); + setFixedSize( 144, 110 ); QVBoxLayout * tl = new QVBoxLayout( this ); tl->addSpacing( 25 ); - tl->addStretch(); QHBoxLayout * l = new QHBoxLayout; @@ -62,13 +61,8 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( m_amountKnob->setModel( &_controls->m_amountModel ); m_amountKnob->setHintText( tr( "Modulation amount:" ) + " ", "" ); - m_amountMultKnob = new knob( knobBright_26, this ); - m_amountMultKnob->setLabel( tr( "MULT" ) ); - m_amountMultKnob->setModel( &_controls->m_amountMultModel ); - m_amountMultKnob->setHintText( tr( "Amount Multiplicator:" ) + " ", "" ); - m_attackKnob = new knob( knobBright_26, this ); - m_attackKnob->setLabel( tr( "ATTCK" ) ); + m_attackKnob->setLabel( tr( "ATTACK" ) ); m_attackKnob->setModel( &_controls->m_attackModel ); m_attackKnob->setHintText( tr( "Attack:" ) + " ", "" ); @@ -79,30 +73,15 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( l->addWidget( m_baseKnob ); l->addWidget( m_amountKnob ); - l->addWidget( m_amountMultKnob ); l->addWidget( m_attackKnob ); l->addWidget( m_decayKnob ); - l->addStretch(); // expand, so other widgets have minimum width tl->addLayout( l ); - l = new QHBoxLayout; // = 2nd hbox - - m_muteLed = new ledCheckBox( "Mute Effect", this ); + m_muteLed = new ledCheckBox( "Mute", this ); m_muteLed->setModel( &_controls->m_muteModel ); - m_absLed = new ledCheckBox( "Abs Value", this ); - m_absLed->setModel( &_controls->m_absModel ); - - m_muteOutputLed = new ledCheckBox( "Mute Output", this ); - m_muteOutputLed->setModel( &_controls->m_muteOutputModel ); - tl->addSpacing( 5 ); - - l->addWidget( m_muteLed ); - l->addWidget( m_absLed ); - l->addWidget( m_muteOutputLed ); - l->addStretch(); // expand, so other widgets have minimum width - tl->addLayout( l ); + tl->addWidget( m_muteLed ); setLayout( tl ); } diff --git a/plugins/peak_controller_effect/peak_controller_effect_control_dialog.h b/plugins/peak_controller_effect/peak_controller_effect_control_dialog.h index 40e7abc1f4..5e95bd6547 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_control_dialog.h +++ b/plugins/peak_controller_effect/peak_controller_effect_control_dialog.h @@ -50,10 +50,6 @@ protected: knob * m_decayKnob; ledCheckBox * m_muteLed; - ledCheckBox * m_absLed; - knob * m_amountMultKnob; - ledCheckBox * m_muteOutputLed; - } ; diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index 69c8f15b95..a07d52358f 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -39,10 +39,7 @@ PeakControllerEffectControls( PeakControllerEffect * _eff ) : m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Modulation amount" ) ), m_attackModel( 0, 0, 0.999, 0.001, this, tr( "Attack" ) ), m_decayModel( 0, 0, 0.999, 0.001, this, tr( "Release" ) ), - m_muteModel( false, this, tr( "Mute output" ) ), - m_absModel( true, this, tr("Abs Value") ), - m_amountMultModel( 1.0, 0, 32, 0.2, this, tr("Amount Multiplicator") ), - m_muteOutputModel( false, this, tr("Mute Output") ) + m_muteModel( false, this, tr( "Mute output" ) ) { } @@ -57,10 +54,6 @@ void PeakControllerEffectControls::loadSettings( const QDomElement & _this ) m_attackModel.loadSettings( _this, "attack" ); m_decayModel.loadSettings( _this, "decay" ); - m_absModel.loadSettings( _this, "abs" ); - m_amountMultModel.loadSettings( _this, "amountmult" ); - m_muteOutputModel.loadSettings( _this, "muteout" ); - int effectId = _this.attribute( "effectId" ).toInt(); if( effectId > PeakController::s_lastEffectId ) { @@ -89,10 +82,6 @@ void PeakControllerEffectControls::saveSettings( QDomDocument & _doc, m_attackModel.saveSettings( _doc, _this, "attack" ); m_decayModel.saveSettings( _doc, _this, "decay" ); - - m_absModel.saveSettings( _doc, _this, "abs" ); - m_amountMultModel.saveSettings( _doc, _this, "amountmult" ); - m_muteOutputModel.saveSettings( _doc, _this, "muteout" ); } diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.h b/plugins/peak_controller_effect/peak_controller_effect_controls.h index 4a4de0401a..7a81117959 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.h +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.h @@ -66,9 +66,6 @@ private: FloatModel m_attackModel; FloatModel m_decayModel; BoolModel m_muteModel; - BoolModel m_absModel; - FloatModel m_amountMultModel; - BoolModel m_muteOutputModel; friend class PeakControllerEffectControlDialog; friend class PeakControllerEffect;