From 2418ea32eeef9fb3287cb196ceedac5cc148e66e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 3 Apr 2008 22:50:40 +0000 Subject: [PATCH] made song-length being cached and only updated upon changed length or position of TCOs git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@880 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 18 ++++++++++++++++++ include/song.h | 11 +++++++---- src/core/song.cpp | 11 +++++++---- src/gui/export_project_dialog.cpp | 4 ++-- src/gui/song_editor.cpp | 2 +- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4a813f9f..c589e5979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2008-04-03 Tobias Doerffel + * include/song.h: + * src/core/song.cpp: + * src/gui/export_project_dialog.cpp: + * src/gui/song_editor.cpp: + made song-length being cached and only updated upon changed length or + position of TCOs + + * src/core/track.cpp: + optimized track::length()-method + + * src/core/mixer.cpp: + great improvements on multithreading - one global job-queue protected by + a simple mutex where threads pull their jobs from + + * src/core/engine.cpp: + delete LADSPA-manager after mixer and FX-mixer as LADSPA-effects in + FX-mixer access LADSPA-manger at destruction + * plugins/ladspa_effect/ladspa_effect.cpp: * plugins/ladspa_effect/ladspa_effect.h: * plugins/bass_booster/bass_booster.cpp: diff --git a/include/song.h b/include/song.h index 86e7d1286..e5152404f 100644 --- a/include/song.h +++ b/include/song.h @@ -112,8 +112,7 @@ public: inline bool exportDone( void ) const { return( m_exporting == TRUE && - m_playPos[Mode_PlaySong].getTact() >= - lengthInTacts() + 1 ); + m_playPos[Mode_PlaySong].getTact() >= length() + 1 ); } inline PlayModes playMode( void ) const @@ -126,7 +125,11 @@ public: return( m_playPos[_pm] ); } - tact lengthInTacts( void ) const; + void updateLength( void ); + tact length( void ) const + { + return( m_length ); + } bpm_t getTempo( void ); @@ -211,7 +214,6 @@ private: return( m_playPos[m_playMode].getTact() ); } - midiTime length( void ) const; inline tact64th currentTact64th( void ) const { return( m_playPos[m_playMode].getTact64th() ); @@ -240,6 +242,7 @@ private: PlayModes m_playMode; playPos m_playPos[Mode_Count]; + tact m_length; track * m_trackToPlay; pattern * m_patternToPlay; diff --git a/src/core/song.cpp b/src/core/song.cpp index 4f6c9a1ae..184254937 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -538,15 +538,18 @@ void song::playPattern( pattern * _patternToPlay, bool _loop ) -tact song::lengthInTacts( void ) const +void song::updateLength( void ) { - tact len = 0; + m_length = 0; const QList & ctl = tracks(); for( int i = 0; i < ctl.size(); ++i ) { - len = tMax( ctl[i]->length(), len ); + const tact cur = ctl[i]->length(); + if( cur > m_length ) + { + m_length = cur; + } } - return( len ); } diff --git a/src/gui/export_project_dialog.cpp b/src/gui/export_project_dialog.cpp index 0946b24d8..cd95643cf 100644 --- a/src/gui/export_project_dialog.cpp +++ b/src/gui/export_project_dialog.cpp @@ -370,8 +370,8 @@ void exportProjectDialog::exportBtnClicked( void ) && !m_deleteFile ) { dev->processNextBuffer(); - int pval = pp * 100 / - ( ( engine::getSong()->lengthInTacts() + 1 ) * 64 ); + const int pval = pp * 100 / + ( ( engine::getSong()->length() + 1 ) * 64 ); m_exportProgressBar->setValue( pval ); if( engine::getMainWindow() ) { diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index de293bd25..5ac71683b 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -378,7 +378,7 @@ songEditor::~songEditor() void songEditor::paintEvent( QPaintEvent * _pe ) { - m_leftRightScroll->setMaximum( m_s->lengthInTacts() ); + m_leftRightScroll->setMaximum( m_s->length() ); trackContainerView::paintEvent( _pe ); }