This commit is contained in:
Vesa
2014-11-28 03:19:21 +02:00
parent 13393900d2
commit 7410174c8b
8 changed files with 98 additions and 82 deletions

View File

@@ -49,16 +49,19 @@ Plugin::Descriptor PLUGIN_EXPORT multitapecho_plugin_descriptor =
MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ) :
Effect( &multitapecho_plugin_descriptor, parent, key ),
m_controls( this ),
m_buffer( 20000.0f ),
m_buffer( 20100.0f ),
m_sampleRate( Engine::mixer()->processingSampleRate() ),
m_sampleRatio( 1.0f / m_sampleRate )
{
m_work = new sampleFrame[ Engine::mixer()->framesPerPeriod() ];
m_buffer.reset();
updateFilters( 0, 19 );
}
MultitapEchoEffect::~MultitapEchoEffect()
{
delete m_work;
}
@@ -99,9 +102,6 @@ bool MultitapEchoEffect::processAudioBuffer( sampleFrame * buf, const fpp_t fram
const float dryGain = dbvToAmp( m_controls.m_dryGain.value() );
const bool swapInputs = m_controls.m_swapInputs.value();
// temp processing stackbuffer for lp-filtering
sampleFrame work [frames];
// add dry buffer - never swap inputs for dry
m_buffer.writeAddingMultiplied( buf, 0, frames, dryGain );
@@ -111,8 +111,8 @@ bool MultitapEchoEffect::processAudioBuffer( sampleFrame * buf, const fpp_t fram
float offset = stepLength;
for( int i = 0; i < steps; ++i ) // add all steps swapped
{
runFilter( &work[0], buf, m_filter[i], frames );
m_buffer.writeSwappedAddingMultiplied( &work[0], offset, frames, m_amp[i] );
runFilter( m_work, buf, m_filter[i], frames );
m_buffer.writeSwappedAddingMultiplied( m_work, offset, frames, m_amp[i] );
offset += stepLength;
}
}
@@ -121,19 +121,19 @@ bool MultitapEchoEffect::processAudioBuffer( sampleFrame * buf, const fpp_t fram
float offset = stepLength;
for( int i = 0; i < steps; ++i ) // add all steps swapped
{
runFilter( &work[0], buf, m_filter[i], frames );
m_buffer.writeAddingMultiplied( &work[0], offset, frames, m_amp[i] );
runFilter( m_work, buf, m_filter[i], frames );
m_buffer.writeAddingMultiplied( m_work, offset, frames, m_amp[i] );
offset += stepLength;
}
}
// pop the buffer and mix it into output
m_buffer.pop( &work[0] );
m_buffer.pop( m_work );
for( int f = 0; f < frames; ++f )
{
buf[f][0] = d * buf[f][0] + w * work[f][0];
buf[f][1] = d * buf[f][1] + w * work[f][1];
buf[f][0] = d * buf[f][0] + w * m_work[f][0];
buf[f][1] = d * buf[f][1] + w * m_work[f][1];
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
}

View File

@@ -86,6 +86,8 @@ private:
float m_sampleRate;
float m_sampleRatio;
sampleFrame * m_work;
friend class MultitapEchoControls;

View File

@@ -92,8 +92,8 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con
// switch led
LedCheckBox * swapInputs = new LedCheckBox( "Swap inputs", this, tr( "Swap in" ), LedCheckBox::Green );
swapInputs->move( 180, 240 );
swapInputs->setModel( & controls-> m_swapInputs );
ToolTip::add( swapInputs, tr( "Swap left and right channel for reflections" ) );
LedCheckBox * swapInputs = new LedCheckBox( "Swap inputs", this, tr( "Swap inputs" ), LedCheckBox::Green );
swapInputs->move( 20, 280 );
swapInputs->setModel( & controls->m_swapInputs );
ToolTip::add( swapInputs, tr( "Swap left and right input channel for reflections" ) );
}

View File

@@ -38,7 +38,7 @@ MultitapEchoControls::MultitapEchoControls( MultitapEchoEffect * eff ) :
m_stepLength( 100.0f, 1.0f, 1000.0f, 0.1f, 1000.0f, this, "Step length" ),
m_dryGain( 0.0f, -80.0f, 20.0f, 0.1f, this, "Dry gain" ),
m_swapInputs( false, this, "Swap inputs" ),
m_ampGraph( -100.0f, 0.0f, 16, this ),
m_ampGraph( -60.0f, 0.0f, 16, this ),
m_lpGraph( 0.0f, 3.0f, 16, this )
{
connect( &m_ampGraph, SIGNAL( samplesChanged( int, int ) ), this, SLOT( ampSamplesChanged( int, int ) ) );
@@ -140,6 +140,7 @@ void MultitapEchoControls::ampResetClicked()
void MultitapEchoControls::lpSamplesChanged( int begin, int end )
{
//qDebug( "b/e %d - %d", begin, end );
const float * samples = m_lpGraph.samples();
for( int i = begin; i <= end; ++i )
{
@@ -157,12 +158,18 @@ void MultitapEchoControls::lpResetClicked()
void MultitapEchoControls::lengthChanged()
{
m_ampGraph.setLength( m_steps.value() );
m_lpGraph.setLength( m_steps.value() );
const int len = m_steps.value();
m_ampGraph.setLength( len );
ampSamplesChanged( 0, len - 1 );
m_lpGraph.setLength( len );
lpSamplesChanged( 0, len - 1 );
m_effect->updateFilters( 0, len - 1 );
}
void MultitapEchoControls::sampleRateChanged()
{
m_effect->m_sampleRate = Engine::mixer()->processingSampleRate();
m_effect->m_sampleRatio = 1.0f / m_effect->m_sampleRate;
m_effect->updateFilters( 0, 19 );
}