diff options
author | Wohlstand <admin@wohlnet.ru> | 2017-11-07 17:52:49 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2017-11-07 17:52:49 +0300 |
commit | e3fa4e69e09f8a475a5fcca6916532014e5b2338 (patch) | |
tree | a0898ad17da844351dbea843a7cb4ea556f5e5aa /src | |
parent | 7ff6d5ee9d0049f165ff6d2792855b81873da5b9 (diff) | |
download | libADLMIDI-e3fa4e69e09f8a475a5fcca6916532014e5b2338.tar.gz libADLMIDI-e3fa4e69e09f8a475a5fcca6916532014e5b2338.tar.bz2 libADLMIDI-e3fa4e69e09f8a475a5fcca6916532014e5b2338.zip |
Fix a bug which overrides loopStart with seek destination position
Diffstat (limited to 'src')
-rw-r--r-- | src/adlmidi_load.cpp | 1 | ||||
-rw-r--r-- | src/adlmidi_midiplay.cpp | 22 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 3 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp index 9b28810..3eea1b7 100644 --- a/src/adlmidi_load.cpp +++ b/src/adlmidi_load.cpp @@ -387,7 +387,6 @@ bool MIDIplay::LoadMIDI(MIDIplay::fileReader &fr) cmf_percussion_mode = false; opl.Reset(m_setup.PCM_RATE); - trackStart = true; atEnd = false; loopStart = true; invalidLoop = false; diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index d5731a5..3d8f88c 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -533,7 +533,10 @@ bool MIDIplay::buildTrackData() } fullSongTimeLength += postSongWaitDelay; + //Set begin of the music trackBeginPositionNew = CurrentPositionNew; + //Initial loop position will begin at begin of track until passing of the loop point + LoopBeginPositionNew = CurrentPositionNew; /********************************************************************************/ @@ -642,7 +645,6 @@ MIDIplay::MIDIplay(): loopStartTime(-1.0), loopEndTime(-1.0), tempoMultiplier(1.0), - trackStart(false), atEnd(false), loopStart(false), loopEnd(false), @@ -752,6 +754,7 @@ void MIDIplay::seek(double seconds) s = seconds;//m_setup.delay < m_setup.maxdelay ? m_setup.delay : m_setup.maxdelay; bool loopFlagState = m_setup.loopingIsEnabled; + // Turn loop pooints off because it causes wrong position rememberin on a quick seek m_setup.loopingIsEnabled = false; /* @@ -761,8 +764,16 @@ void MIDIplay::seek(double seconds) * - All sustaining notes must be killed * - Ignore Note-On events */ - rewind(); + + /* + * Set "loop Start" to false to prevent overwrite of loopStart position with + * seek destinition position + * + * TODO: Detect & set loopStart position on load time to don't break loop while seeking + */ + loopStart = false; + while((CurrentPositionNew.absTimePosition < seconds) && (CurrentPositionNew.absTimePosition < fullSongTimeLength)) { @@ -821,11 +832,11 @@ void MIDIplay::rewind() { Panic(); KillSustainingNotes(-1, -1); - CurrentPositionNew = trackBeginPositionNew; - trackStart = true; + CurrentPositionNew = trackBeginPositionNew; atEnd = false; loopStart = true; - invalidLoop = false; + loopEnd = false; + //invalidLoop = false;//No more needed here as this flag is set on load time } void MIDIplay::setTempo(double tempo) @@ -1582,7 +1593,6 @@ bool MIDIplay::ProcessEventsNew(bool isSeek) #endif CurrentPositionNew.wait += t.value(); - //if(shortest > 0) UI.PrintLn("Delay %ld (%g)", shortest, (double)t.valuel()); if(loopStart) { diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index dbea5e6..37e0d25 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -762,8 +762,7 @@ public: fraction<uint64_t> InvDeltaTicks, Tempo; //! Tempo multiplier double tempoMultiplier; - bool trackStart, - atEnd, + bool atEnd, loopStart, loopEnd, invalidLoop; /*Loop points are invalid (loopStart after loopEnd or loopStart and loopEnd are on same place)*/ |