Fixed MIDI looping
parent
00c13ec061
commit
b28705d5d9
|
@ -54,7 +54,7 @@ bool MIDIPlayer::Load(const midi_container & midi_file, unsigned subsong, unsign
|
||||||
|
|
||||||
uLoopMode = loop_mode;
|
uLoopMode = loop_mode;
|
||||||
|
|
||||||
uTimeEnd = midi_file.get_timestamp_end( subsong, true ) + 1000;
|
uTimeEnd = midi_file.get_timestamp_end( subsong, true ) + 1000;
|
||||||
|
|
||||||
if (uLoopMode & loop_mode_enable)
|
if (uLoopMode & loop_mode_enable)
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,11 @@ bool MIDIPlayer::Load(const midi_container & midi_file, unsigned subsong, unsign
|
||||||
uLoopMode |= loop_mode_force;
|
uLoopMode |= loop_mode_force;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( uTimeLoopStart == ~0UL )
|
||||||
|
uTimeLoopStart = 0;
|
||||||
|
if ( uTimeLoopEnd == ~0UL )
|
||||||
|
uTimeLoopEnd = uTimeEnd - 1000;
|
||||||
|
|
||||||
if ((uLoopMode & loop_mode_force))
|
if ((uLoopMode & loop_mode_force))
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
@ -84,9 +89,10 @@ bool MIDIPlayer::Load(const midi_container & midi_file, unsigned subsong, unsign
|
||||||
note_on [ ch * 128 + note ] = ( note_on [ ch * 128 + note ] & ~bit ) | ( bit * on );
|
note_on [ ch * 128 + note ] = ( note_on [ ch * 128 + note ] & ~bit ) | ( bit * on );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned long uSavedEndTime = ( i < mStream.size() ) ? mStream[ i ].m_timestamp : mStream[ mStream.size() - 1 ].m_timestamp + 1;
|
|
||||||
mStream.resize( i );
|
mStream.resize( i );
|
||||||
uTimeEnd = mStream[ i - 1 ].m_timestamp;
|
uTimeEnd = uTimeLoopEnd - 1;
|
||||||
|
if ( uTimeEnd < mStream[ i - 1 ].m_timestamp )
|
||||||
|
uTimeEnd = mStream[ i - 1 ].m_timestamp;
|
||||||
for ( unsigned long j = 0; j < 128 * 16; j++ )
|
for ( unsigned long j = 0; j < 128 * 16; j++ )
|
||||||
{
|
{
|
||||||
if ( note_on[ j ] )
|
if ( note_on[ j ] )
|
||||||
|
@ -100,7 +106,7 @@ bool MIDIPlayer::Load(const midi_container & midi_file, unsigned subsong, unsign
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uTimeEnd = uSavedEndTime;
|
uTimeEnd = uTimeLoopEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue