From 0bb64d39ad84d7ff1e66e8327021c201983c8539 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 2 Oct 2008 21:47:18 +0000 Subject: [PATCH] fetch pointer to LADSPA port descriptor once outside the inner loops - improves performance of ladspaEffect::processAudioBuffer() by 400% git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1727 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 7 +++++ plugins/ladspa_effect/ladspa_effect.cpp | 40 ++++++++++++++----------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index aba8d9a59..8aca03718 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2008-10-02 Tobias Doerffel + * plugins/ladspa_effect/ladspa_effect.cpp: + fetch pointer to LADSPA port descriptor once outside the inner loops - + improves performance of ladspaEffect::processAudioBuffer() by 400% + + * include/types.h: + faster floating point comparison + * data/locale/ru.ts: added updated Russian localization by Alexey Kouznetsov diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index c4639a080..f96d23c3b 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -150,44 +150,45 @@ bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, { for( int port = 0; port < m_portCount; ++port ) { - switch( m_ports[proc][port]->rate ) + port_desc_t * pp = m_ports.at( proc ).at( port ); + switch( pp->rate ) { case CHANNEL_IN: for( fpp_t frame = 0; frame < frames; ++frame ) { - m_ports[proc][port]->buffer[frame] = + pp->buffer[frame] = _buf[frame][channel]; } ++channel; break; case AUDIO_RATE_INPUT: - m_ports[proc][port]->value = + pp->value = static_cast( - m_ports[proc][port]->control->getValue() / - m_ports[proc][port]->scale ); + pp->control->getValue() / + pp->scale ); // This only supports control rate ports, so the audio rates are // treated as though they were control rate by setting the // port buffer to all the same value. for( fpp_t frame = 0; frame < frames; ++frame ) { - m_ports[proc][port]->buffer[frame] = - m_ports[proc][port]->value; + pp->buffer[frame] = + pp->value; } break; case CONTROL_RATE_INPUT: - if( m_ports[proc][port]->control == + if( pp->control == NULL ) { break; } - m_ports[proc][port]->value = + pp->value = static_cast( - m_ports[proc][port]->control->getValue() / - m_ports[proc][port]->scale ); - m_ports[proc][port]->buffer[0] = - m_ports[proc][port]->value; + pp->control->getValue() / + pp->scale ); + pp->buffer[0] = + pp->value; break; case CHANNEL_OUT: case AUDIO_RATE_OUTPUT: @@ -214,7 +215,8 @@ bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, { for( int port = 0; port < m_portCount; ++port ) { - switch( m_ports[proc][port]->rate ) + port_desc_t * pp = m_ports.at( proc ).at( port ); + switch( pp->rate ) { case CHANNEL_IN: case AUDIO_RATE_INPUT: @@ -228,7 +230,7 @@ bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, d * _buf[frame][channel] + w * - m_ports[proc][port]->buffer[frame]; + pp->buffer[frame]; out_sum += _buf[frame][channel] * _buf[frame][channel]; @@ -474,10 +476,11 @@ void ladspaEffect::pluginInstantiation( void ) { for( int port = 0; port < m_portCount; port++ ) { + port_desc_t * pp = m_ports.at( proc ).at( port ); if( !manager->connectPort( m_key, m_handles[proc], port, - m_ports[proc][port]->buffer ) ) + pp->buffer ) ) { QMessageBox::warning( 0, "Effect", "Failed to connect port: " + m_key.second, @@ -515,8 +518,9 @@ void ladspaEffect::pluginDestruction( void ) manager->cleanup( m_key, m_handles[proc] ); for( int port = 0; port < m_portCount; port++ ) { - delete[] m_ports[proc][port]->buffer; - delete m_ports[proc][port]; + port_desc_t * pp = m_ports.at( proc ).at( port ); + delete[] pp->buffer; + delete pp; } m_ports[proc].clear(); }