From 26e1c3a5cf91a63e6a93324b94aac8d016f618e3 Mon Sep 17 00:00:00 2001 From: Javier Serrano Polo Date: Sun, 17 Sep 2006 20:22:41 +0000 Subject: [PATCH] fixed looping when processing the audio buffer git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@399 0778d3d1-df1d-0410-868b-ea421aaaa00d --- src/core/song_editor.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index a1004a911..90265434c 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -961,9 +961,11 @@ void songEditor::processNextBuffer( void ) // check for looping-mode and act if neccessary timeLine * tl = m_playPos[m_playMode].m_timeLine; - if( tl != NULL && m_exporting == FALSE && tl->loopPointsEnabled() && - !( m_playMode == PLAY_PATTERN && - m_patternToPlay->freezing() == TRUE ) ) + bool check_loop = tl != NULL && m_exporting == FALSE && + tl->loopPointsEnabled() && + !( m_playMode == PLAY_PATTERN && + m_patternToPlay->freezing() == TRUE ); + if( check_loop ) { if( m_playPos[m_playMode] < tl->loopBegin() || m_playPos[m_playMode] >= tl->loopEnd() ) @@ -972,8 +974,6 @@ void songEditor::processNextBuffer( void ) tl->loopBegin().getTact() ); m_playPos[m_playMode].setTact64th( tl->loopBegin().getTact64th() ); - // force reset of current-frame-var afterwards - m_playPos[m_playMode].setCurrentFrame( 0 ); } } @@ -1030,6 +1030,18 @@ void songEditor::processNextBuffer( void ) } } m_playPos[m_playMode].setTact64th( tact64th % 64 ); + + if( check_loop ) + { + if( m_playPos[m_playMode] >= tl->loopEnd() ) + { + m_playPos[m_playMode].setTact( + tl->loopBegin().getTact() ); + m_playPos[m_playMode].setTact64th( + tl->loopBegin().getTact64th() ); + } + } + current_frame = fmodf( current_frame, frames_per_tact64th ); m_playPos[m_playMode].setCurrentFrame( current_frame );