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.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 8.6 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,
|
||||
@@ -62,6 +63,8 @@ peakControllerEffect::peakControllerEffect(
|
||||
effect( &peakcontrollereffect_plugin_descriptor, _parent, _key ),
|
||||
m_effectId( ++PeakController::s_lastEffectId ),
|
||||
m_peakControls( this ),
|
||||
m_lastSample( 0 ),
|
||||
m_lastRMS( -1 ),
|
||||
m_autoController( NULL )
|
||||
{
|
||||
m_autoController = new PeakController( engine::getSong(), this );
|
||||
@@ -87,15 +90,14 @@ 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
|
||||
|
||||
// This appears to be used for determining whether or not to continue
|
||||
// processing audio with this effect
|
||||
if( !isEnabled() || !isRunning() )
|
||||
{
|
||||
return( FALSE );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// RMS:
|
||||
double sum = 0;
|
||||
for( int i = 0; i < _frames; ++i )
|
||||
@@ -111,12 +113,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,9 +151,9 @@ extern "C"
|
||||
// neccessary for getting instance out of shared lib
|
||||
plugin * PLUGIN_EXPORT lmms_plugin_main( model * _parent, void * _data )
|
||||
{
|
||||
return( new peakControllerEffect( _parent,
|
||||
return new peakControllerEffect( _parent,
|
||||
static_cast<const plugin::descriptor::subPluginFeatures::key *>(
|
||||
_data ) ) );
|
||||
_data ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ private:
|
||||
friend class peakControllerEffectControls;
|
||||
|
||||
float m_lastSample;
|
||||
float m_lastRMS;
|
||||
|
||||
Controller * m_autoController;
|
||||
} ;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* stereomatrix_control_dialog.cpp - control dialog for stereoMatrix-effect
|
||||
* peak_controller_effect_control_dialog.cpp - control dialog for
|
||||
* peakControllerEffect
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
*
|
||||
@@ -30,7 +31,6 @@
|
||||
#include "peak_controller_effect_control_dialog.h"
|
||||
#include "peak_controller_effect_controls.h"
|
||||
#include "knob.h"
|
||||
#include "tempo_sync_knob.h"
|
||||
#include "led_checkbox.h"
|
||||
#include "embed.h"
|
||||
|
||||
@@ -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_decayKnob = new tempoSyncKnob( knobBright_26, this );
|
||||
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 );
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* stereomatrix_control_dialog.h - control dialog for stereoMatrix-effect
|
||||
* peak_controller_effect_control_dialog.h - control dialog for
|
||||
* peakControllerEffect
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
*
|
||||
@@ -36,18 +37,21 @@ class ledCheckBox;
|
||||
class peakControllerEffectControlDialog : public effectControlDialog
|
||||
{
|
||||
public:
|
||||
peakControllerEffectControlDialog( peakControllerEffectControls * _controls );
|
||||
peakControllerEffectControlDialog(
|
||||
peakControllerEffectControls * _controls );
|
||||
virtual ~peakControllerEffectControlDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
knob * m_baseKnob;
|
||||
knob * m_amountKnob;
|
||||
tempoSyncKnob * m_decayKnob;
|
||||
knob * m_attackKnob;
|
||||
knob * m_decayKnob;
|
||||
ledCheckBox * m_muteLed;
|
||||
|
||||
};
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
* stereomatrix_controls.cpp - controls for stereoMatrix-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, 20000.0, 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" ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/*
|
||||
* stereomatrix_controls.h - controls for stereoMatrix-effect
|
||||
* peak_controller_effect_controls.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
|
||||
@@ -35,7 +36,7 @@ class peakControllerEffectControls : public effectControls
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
peakControllerEffectControls( peakControllerEffect( * _eff ) );
|
||||
peakControllerEffectControls( peakControllerEffect * _eff );
|
||||
virtual ~peakControllerEffectControls()
|
||||
{
|
||||
}
|
||||
@@ -44,14 +45,14 @@ public:
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
inline virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "peakcontrollereffectcontrols" );
|
||||
return "peakcontrollereffectcontrols";
|
||||
}
|
||||
|
||||
virtual int getControlCount( void )
|
||||
{
|
||||
return( 1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
virtual effectControlDialog * createView( void )
|
||||
{
|
||||
return new peakControllerEffectControlDialog( this );
|
||||
@@ -63,13 +64,14 @@ private:
|
||||
|
||||
floatModel m_baseModel;
|
||||
floatModel m_amountModel;
|
||||
tempoSyncKnobModel m_decayModel;
|
||||
floatModel m_attackModel;
|
||||
floatModel m_decayModel;
|
||||
boolModel m_muteModel;
|
||||
|
||||
|
||||
friend class peakControllerEffectControlDialog;
|
||||
friend class peakControllerEffect;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user