Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ void Song::processNextBuffer()
( tl->loopBegin().getTicks() * 60 * 1000 / 48 ) / getTempo();
m_playPos[m_playMode].setTicks(
tl->loopBegin().getTicks() );
emit updateSampleTracks();
}
}

Expand Down Expand Up @@ -339,14 +338,17 @@ void Song::processNextBuffer()
// if looping-mode is enabled and we have got
// past the looping range, return to the
// beginning of the range
if( m_playPos[m_playMode] == tl->loopEnd() - 1 )
{
emit updateSampleTracks();
}
if( m_playPos[m_playMode] >= tl->loopEnd() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if( m_playPos[m_playMode] >= tl->loopEnd() )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also switch them, as the second one is likely to be true more often.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea. I've changed this.

Copy link
Contributor

@zonkmachine zonkmachine Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just try and move the whole loop one tick earlier. (in if( checkLoop ) )

if( m_playPos[m_playMode] >= tl->loopEnd() )
{
     m_playPos[m_playMode].setTicks( tl->loopBegin().getTicks() );

to something like (pseudocodeish...):

if( m_playPos[m_playMode] >= tl->loopEnd().getTicks() - 1 )
{
     m_playPos[m_playMode].setTicks( tl->loopBegin().getTicks() - 1 );

{
m_playPos[m_playMode].setTicks( tl->loopBegin().getTicks() );

m_elapsedMilliSeconds =
( ( tl->loopBegin().getTicks() ) * 60 * 1000 / 48 ) /
Copy link
Contributor

@redianthus redianthus Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_elapsedMilliSeconds = tl->loopBegin().getTicks() * 1250 / getTempo();

Copy link
Contributor

@redianthus redianthus Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the same thing on lines 269, 326, 409, 574 and 643.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This will make it harder to deduce where 1250 came from in the first place. The compiler does operations on real numbers for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to change code I don't have to touch. I want to have this PR as clean as possible. We can make an extra PR with code cleaning stuff.

getTempo();
emit updateSampleTracks();
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
//else we play the sample to the end but nothing more
f_cnt_t samplePlayLength = tcoFrameLength > sampleBufferLength ? sampleBufferLength : tcoFrameLength;
//we only play within the sampleBuffer limits
if( sampleStart < sTco->sampleBuffer()->frames() )
if( sampleStart < sampleBufferLength )
{
sTco->setSampleStartFrame( sampleStart );
sTco->setSamplePlayLength( samplePlayLength );
Expand Down