NPH fix: prevent offsets from going over period limit

This commit is contained in:
Vesa
2014-07-14 23:47:41 +03:00
parent 921943bce1
commit fcf3242b7e

View File

@@ -76,6 +76,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ),
m_origin( origin )
{
qDebug( "offset %d", _offset );
if( hasParent() == false )
{
m_baseDetuning = new BaseDetuning( detuning() );
@@ -187,6 +188,13 @@ void NotePlayHandle::play( sampleFrame * _working_buffer )
{
return;
}
// if the note offset falls over to next period, then don't start playback yet
if( offset() >= engine::mixer()->framesPerPeriod() )
{
setOffset( offset() - engine::mixer()->framesPerPeriod() );
return;
}
// number of frames that can be played this period
f_cnt_t framesThisPeriod = m_totalFramesPlayed == 0