{
public:
void EnterBlock();
+ void SaveTime();
+ void RestoreTime();
void PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev);
void SortEvents();
const std::vector<AbsoluteMIDIEvent>& GetEvents() const;
std::vector<AbsoluteMIDIEvent> m_Events;
int m_BaseTimeForCurrentBlock = 0;
int m_LastEventTime = 0;
+ int m_PrevLastEventTime = 0;
};
class IIR2MIDICompiler
m_BaseTimeForCurrentBlock = m_LastEventTime;
}
+void TrackCompilerContext::SaveTime()
+{
+ m_PrevLastEventTime = m_LastEventTime;
+}
+
+void TrackCompilerContext::RestoreTime()
+{
+ m_LastEventTime = m_PrevLastEventTime;
+}
+
void TrackCompilerContext::PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev)
{
m_LastEventTime = m_BaseTimeForCurrentBlock + relativeTime;
- m_Events.push_back(AbsoluteMIDIEvent{m_BaseTimeForCurrentBlock + relativeTime, ev});
+ m_Events.push_back(AbsoluteMIDIEvent{m_LastEventTime, ev});
}
void TrackCompilerContext::SortEvents()
CheckForUnprocessedAttributes(i.Attributes);
EnsureTrackInitialized(i.Number);
+ GetTrackContext(i.Number).SaveTime();
+ }
+
+ for (auto&& i : ir.Tracks)
+ {
+ GetTrackContext(i.Number).RestoreTime();
+
for (auto&& j : i.Items)
{
CheckForUnprocessedAttributes(j.Attributes);
+ GetTrackContext(i.Number).EnterBlock();
CompileBlock(i.Number, j.Block);
}
}
void IR2MIDICompiler::CompileBlock(int trackNumber, IR::BlockReference blockRef)
{
- GetTrackContext(trackNumber).EnterBlock();
-
const auto& block = m_IR.Blocks.at(blockRef.ID);
CheckForUnprocessedAttributes(block.Attributes);