diff --git a/ChangeLog b/ChangeLog index bc159b83a..3e522af8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2008-05-18 Tobias Doerffel + + * plugins/ladspa_effect/ladspa_effect.cpp: + added "Notch Filter" to blacklist + + * plugins/ladspa_effect/ladspa_effect.h: + * plugins/ladspa_effect/ladspa_effect.cpp: + * plugins/bass_booster/bass_booster.cpp: + * plugins/stereo_matrix/stereo_matrix.cpp: + * plugins/stereo_enhancer/stereo_enhancer.cpp: + - replaced old code with effect::checkGate() call + - various cleanups and minor optimizations + + * src/core/effect_chain.cpp: + added debugging-code for determining buggy effect-plugins at higher + samplerates + + * include/plugin.h: + introduced changable publicName-property + + * include/effect.h: + * src/core/effect.cpp: + added checkGate()-function for reducing redundant code in effect-plugins + 2008-05-17 Tobias Doerffel * plugins/ladspa_effect/ladspa_effect.cpp: diff --git a/include/effect.h b/include/effect.h index ef6252fca..4599d57c5 100644 --- a/include/effect.h +++ b/include/effect.h @@ -171,6 +171,8 @@ public: protected: + void checkGate( double _out_sum ); + virtual pluginView * instantiateView( QWidget * ); // some effects might not be capable of higher sample-rates so they can diff --git a/include/plugin.h b/include/plugin.h index 1757487cc..fa4c3c7f5 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -169,7 +169,13 @@ public: // returns public-name out of descriptor virtual inline QString publicName( void ) const { - return( m_descriptor->public_name ); + return( m_publicName != QString::null ? + m_publicName : m_descriptor->public_name ); + } + + virtual void setPublicName( const QString & _public_name ) + { + m_publicName = _public_name; } // return plugin-type @@ -228,6 +234,7 @@ protected: private: const descriptor * m_descriptor; + QString m_publicName; // pointer to instantiation-function in plugin typedef plugin * ( * instantiationHook )( model *, void * ); diff --git a/plugins/bass_booster/bass_booster.cpp b/plugins/bass_booster/bass_booster.cpp index 09b4a2077..3c6a56f38 100644 --- a/plugins/bass_booster/bass_booster.cpp +++ b/plugins/bass_booster/bass_booster.cpp @@ -85,26 +85,14 @@ bool bassBoosterEffect::processAudioBuffer( sampleFrame * _buf, { sample_t s[2] = { _buf[f][0], _buf[f][1] }; m_bbFX.nextSample( s[0], s[1] ); - for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) - { - _buf[f][ch] = d * _buf[f][ch] + w * s[ch]; - out_sum += _buf[f][ch]*_buf[f][ch]; - } + + _buf[f][0] = d * _buf[f][0] + w * s[0]; + _buf[f][1] = d * _buf[f][1] + w * s[1]; + + out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; } - if( out_sum / _frames <= getGate()+0.000001 ) - { - incrementBufferCount(); - if( getBufferCount() > getTimeout() ) - { - stopRunning(); - resetBufferCount(); - } - } - else - { - resetBufferCount(); - } + checkGate( out_sum / _frames ); return( isRunning() ); } diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index b891b34dc..e5089c4e4 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -64,7 +64,6 @@ ladspaEffect::ladspaEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ) : effect( &ladspaeffect_plugin_descriptor, _parent, _key ), m_controls( NULL ), - m_publicName( "none" ), m_maxSampleRate( 0 ), m_key( ladspaSubPluginFeatures::subPluginKeyToLadspaKey( _key ) ) { @@ -128,13 +127,12 @@ bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, int frames = _frames; sampleFrame * o_buf = NULL; - int sr = m_maxSampleRate; - if( sr < engine::getMixer()->processingSampleRate() ) + if( m_maxSampleRate < engine::getMixer()->processingSampleRate() ) { o_buf = _buf; _buf = new sampleFrame[_frames]; - sampleDown( o_buf, _buf, sr ); - frames = _frames * sr / + sampleDown( o_buf, _buf, m_maxSampleRate ); + frames = _frames * m_maxSampleRate / engine::getMixer()->processingSampleRate(); } @@ -243,25 +241,12 @@ bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, if( o_buf != NULL ) { - sampleBack( _buf, o_buf, sr ); + sampleBack( _buf, o_buf, m_maxSampleRate ); delete[] _buf; } - // Check whether we need to continue processing input. Restart the - // counter if the threshold has been exceeded. - if( out_sum / frames <= getGate()+0.000001 ) - { - incrementBufferCount(); - if( getBufferCount() > getTimeout() ) - { - stopRunning(); - resetBufferCount(); - } - } - else - { - resetBufferCount(); - } + checkGate( out_sum / frames ); + bool is_running = isRunning(); m_pluginMutex.unlock(); @@ -543,14 +528,15 @@ void ladspaEffect::pluginDestruction( void ) -static QMap __buggy_plugins; +static QMap __buggy_plugins; -int ladspaEffect::maxSamplerate( const QString & _name ) +sample_rate_t ladspaEffect::maxSamplerate( const QString & _name ) { if( __buggy_plugins.isEmpty() ) { __buggy_plugins["C * AmpVTS"] = 88200; __buggy_plugins["Chorus2"] = 44100; + __buggy_plugins["Notch Filter"] = 96000; } if( __buggy_plugins.contains( _name ) ) { diff --git a/plugins/ladspa_effect/ladspa_effect.h b/plugins/ladspa_effect/ladspa_effect.h index d326c0746..a4ee04a25 100644 --- a/plugins/ladspa_effect/ladspa_effect.h +++ b/plugins/ladspa_effect/ladspa_effect.h @@ -60,16 +60,6 @@ public: return( m_portControls ); } - virtual inline QString publicName( void ) const - { - return( m_publicName ); - } - - inline void setPublicName( const QString & _name ) - { - m_publicName = _name; - } - private slots: void changeSampleRate( void ); @@ -79,14 +69,13 @@ private: void pluginInstantiation( void ); void pluginDestruction( void ); - static int maxSamplerate( const QString & _name ); + static sample_rate_t maxSamplerate( const QString & _name ); QMutex m_pluginMutex; ladspaControls * m_controls; - QString m_publicName; - int m_maxSampleRate; + sample_rate_t m_maxSampleRate; ladspa_key_t m_key; int m_portCount; diff --git a/plugins/stereo_enhancer/stereo_enhancer.cpp b/plugins/stereo_enhancer/stereo_enhancer.cpp index 69c3bc030..b0b7cafe0 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.cpp +++ b/plugins/stereo_enhancer/stereo_enhancer.cpp @@ -124,32 +124,21 @@ bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, m_seFX.nextSample( s[0], s[1] ); - for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) - { - _buf[f][ch] = d * _buf[f][ch] + w * s[ch]; - out_sum += _buf[f][ch]*_buf[f][ch]; - } - + _buf[f][0] = d * _buf[f][0] + w * s[0]; + _buf[f][1] = d * _buf[f][1] + w * s[1]; + out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; + // Update currFrame m_currFrame += 1; m_currFrame %= DEFAULT_BUFFER_SIZE; } - if( out_sum / _frames <= getGate()+0.00001 ) + checkGate( out_sum / _frames ); + if( !isRunning() ) { - incrementBufferCount(); - if( getBufferCount() > getTimeout() ) - { - stopRunning(); - resetBufferCount(); - clearMyBuffer(); - } - } - else - { - resetBufferCount(); - //clearMyBuffer(); + clearMyBuffer(); } + return( isRunning() ); } diff --git a/plugins/stereo_matrix/stereo_matrix.cpp b/plugins/stereo_matrix/stereo_matrix.cpp index 7572f06b9..f71ddfaee 100644 --- a/plugins/stereo_matrix/stereo_matrix.cpp +++ b/plugins/stereo_matrix/stereo_matrix.cpp @@ -78,7 +78,8 @@ bool stereoMatrixEffect::processAudioBuffer( sampleFrame * _buf, return( FALSE ); } - + double out_sum = 0.0; + for( fpp_t f = 0; f < _frames; ++f ) { const float d = getDryLevel(); @@ -97,10 +98,12 @@ bool stereoMatrixEffect::processAudioBuffer( sampleFrame * _buf, _buf[f][1] += ( m_smControls.m_lrModel.value( f ) * l + m_smControls.m_rrModel.value( f ) * r ) * w; - + out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; } + checkGate( out_sum / _frames ); + return( isRunning() ); } diff --git a/src/core/effect.cpp b/src/core/effect.cpp index f75f6202a..dd16429d8 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -118,6 +118,28 @@ effect * effect::instantiate( const QString & _plugin_name, +void effect::checkGate( double _out_sum ) +{ + // Check whether we need to continue processing input. Restart the + // counter if the threshold has been exceeded. + if( _out_sum <= getGate()+0.000001 ) + { + incrementBufferCount(); + if( getBufferCount() > getTimeout() ) + { + stopRunning(); + resetBufferCount(); + } + } + else + { + resetBufferCount(); + } +} + + + + pluginView * effect::instantiateView( QWidget * _parent ) { return( new effectView( this, _parent ) ); diff --git a/src/core/effect_chain.cpp b/src/core/effect_chain.cpp index f77ebccd8..1f3e10781 100644 --- a/src/core/effect_chain.cpp +++ b/src/core/effect_chain.cpp @@ -31,6 +31,7 @@ #include "engine.h" #include "automatable_model_templates.h" #include "track.h" +#include "debug.h" @@ -190,9 +191,22 @@ bool effectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) } bool more_effects = FALSE; for( effectList::iterator it = m_effects.begin(); - it != m_effects.end(); it++ ) + it != m_effects.end(); ++it ) { more_effects |= ( *it )->processAudioBuffer( _buf, _frames ); +#ifdef LMMS_DEBUG + for( int f = 0; f < _frames; ++f ) + { + if( fabs( _buf[f][0] ) > 5 || fabs( _buf[f][1] ) > 5 ) + { + it = m_effects.end()-1; + printf( "numerical overflow after processing " + "plugin \"%s\"\n", ( *it )-> + publicName().toAscii().constData() ); + break; + } + } +#endif } return( more_effects ); }