PeakController: initial work on attack- and decay-support
The decay knob didn't actually do anything before. Now it's useful
together with newly introduced attack knob. One can do much better
sidechaining now without disturbing artifacts due to too responsive
volume changes.
(cherry picked from commit 9615ceabd5)
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 6.2 KiB |
@@ -2,7 +2,8 @@
|
||||
* peak_controller_effect.cpp - PeakController effect plugin
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
*
|
||||
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -39,7 +40,7 @@ Plugin::Descriptor PLUGIN_EXPORT peakcontrollereffect_plugin_descriptor =
|
||||
STRINGIFY( PLUGIN_NAME ),
|
||||
"Peak Controller",
|
||||
QT_TRANSLATE_NOOP( "pluginBrowser",
|
||||
"Plugin for controlling knobs with sound peaks" ),
|
||||
"Plugin for controlling knobs with sound peaks" ),
|
||||
"Paul Giblock <drfaygo/at/gmail.com>",
|
||||
0x0100,
|
||||
Plugin::Effect,
|
||||
@@ -61,6 +62,8 @@ PeakControllerEffect::PeakControllerEffect(
|
||||
const Descriptor::SubPluginFeatures::Key * _key ) :
|
||||
Effect( &peakcontrollereffect_plugin_descriptor, _parent, _key ),
|
||||
m_peakControls( this ),
|
||||
m_lastSample( 0 ),
|
||||
m_lastRMS( -1 ),
|
||||
m_autoController( NULL )
|
||||
{
|
||||
m_autoController = new PeakController( engine::getSong(), this );
|
||||
@@ -91,10 +94,9 @@ bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
// audio with this effect
|
||||
if( !isEnabled() || !isRunning() )
|
||||
{
|
||||
return( FALSE );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// RMS:
|
||||
double sum = 0;
|
||||
for( int i = 0; i < _frames; ++i )
|
||||
@@ -110,12 +112,33 @@ bool PeakControllerEffect::processAudioBuffer( sampleFrame * _buf,
|
||||
}
|
||||
}
|
||||
|
||||
m_lastSample = c.m_baseModel.value() + c.m_amountModel.value() *
|
||||
sqrtf( sum / _frames );
|
||||
float curRMS = sqrtf( sum / _frames );
|
||||
const float origRMS = curRMS;
|
||||
if( m_lastRMS < 0 )
|
||||
{
|
||||
m_lastRMS = curRMS;
|
||||
}
|
||||
const float v = ( curRMS >= m_lastRMS ) ?
|
||||
c.m_attackModel.value() :
|
||||
c.m_decayModel.value();
|
||||
const float a = sqrtf( sqrtf( v ) );
|
||||
curRMS = (1-a)*curRMS + a*m_lastRMS;
|
||||
|
||||
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
|
||||
// replay a certain number of passes so the LP state is as if it was
|
||||
// updated N times with buffer-size 1/N
|
||||
const int timeOversamp = (4*_frames) / DEFAULT_BUFFER_SIZE-1;
|
||||
for( int i = 0; i < timeOversamp; ++i )
|
||||
{
|
||||
m_lastRMS = (1-a)*origRMS + a*m_lastRMS;
|
||||
}
|
||||
|
||||
//checkGate( out_sum / _frames );
|
||||
|
||||
return( isRunning() );
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,8 +151,7 @@ extern "C"
|
||||
Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data )
|
||||
{
|
||||
return new PeakControllerEffect( _parent,
|
||||
static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>(
|
||||
_data ) );
|
||||
static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( _data ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
PeakControllerEffectControls m_peakControls;
|
||||
|
||||
float m_lastSample;
|
||||
float m_lastRMS;
|
||||
|
||||
Controller * m_autoController;
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog(
|
||||
PeakControllerEffectControls * _controls ) :
|
||||
EffectControlDialog( _controls )
|
||||
{
|
||||
setAutoFillBackground( TRUE );
|
||||
setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( backgroundRole(),
|
||||
PLUGIN_NAME::getIconPixmap( "artwork" ) );
|
||||
setPalette( pal );
|
||||
setFixedSize( 120, 104 );
|
||||
setFixedSize( 144, 110 );
|
||||
|
||||
QVBoxLayout * tl = new QVBoxLayout( this );
|
||||
tl->addSpacing( 25 );
|
||||
@@ -61,13 +61,19 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog(
|
||||
m_amountKnob->setModel( &_controls->m_amountModel );
|
||||
m_amountKnob->setHintText( tr( "Modulation amount:" ) + " ", "" );
|
||||
|
||||
m_attackKnob = new knob( knobBright_26, this );
|
||||
m_attackKnob->setLabel( tr( "ATTACK" ) );
|
||||
m_attackKnob->setModel( &_controls->m_attackModel );
|
||||
m_attackKnob->setHintText( tr( "Attack:" ) + " ", "" );
|
||||
|
||||
m_decayKnob = new knob( knobBright_26, this );
|
||||
m_decayKnob->setLabel( tr( "DECAY" ) );
|
||||
m_decayKnob->setModel( &_controls->m_decayModel );
|
||||
m_decayKnob->setHintText( tr( "Release decay (not implemented):" ) + " ", "" );
|
||||
m_decayKnob->setHintText( tr( "Release:" ) + " ", "" );
|
||||
|
||||
l->addWidget( m_baseKnob );
|
||||
l->addWidget( m_amountKnob );
|
||||
l->addWidget( m_attackKnob );
|
||||
l->addWidget( m_decayKnob );
|
||||
tl->addLayout( l );
|
||||
|
||||
|
||||
@@ -42,13 +42,15 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
knob * m_baseKnob;
|
||||
knob * m_amountKnob;
|
||||
knob * m_attackKnob;
|
||||
knob * m_decayKnob;
|
||||
ledCheckBox * m_muteLed;
|
||||
|
||||
};
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* peak_controller_effect_controls.cpp - controls for PeakController effect
|
||||
* peak_controller_effect_controls.cpp - controls for peakController effect
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -36,8 +37,9 @@ PeakControllerEffectControls( PeakControllerEffect * _eff ) :
|
||||
m_effect( _eff ),
|
||||
m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
|
||||
m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Modulation amount" ) ),
|
||||
m_decayModel( 0.1, 0.01, 5.0, 0.0001, this, tr( "Release decay" ) ),
|
||||
m_muteModel( FALSE, this, tr( "Mute output" ) )
|
||||
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" ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* peak_controller_EffectControls.h - controls for peakController effect
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
*
|
||||
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -44,12 +45,12 @@ public:
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
inline virtual QString nodeName() const
|
||||
{
|
||||
return( "peakcontrollereffectcontrols" );
|
||||
return "peakcontrollereffectcontrols";
|
||||
}
|
||||
|
||||
virtual int controlCount()
|
||||
{
|
||||
return( 1 );
|
||||
return 1;
|
||||
}
|
||||
virtual EffectControlDialog * createView()
|
||||
{
|
||||
@@ -62,6 +63,7 @@ private:
|
||||
|
||||
FloatModel m_baseModel;
|
||||
FloatModel m_amountModel;
|
||||
FloatModel m_attackModel;
|
||||
FloatModel m_decayModel;
|
||||
BoolModel m_muteModel;
|
||||
|
||||
@@ -71,4 +73,4 @@ private:
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user