OSDN Git Service

フレーズの最後の休符が無視されていたのを修正
authorstarg <starg@users.osdn.me>
Tue, 23 Aug 2016 20:56:47 +0000 (05:56 +0900)
committerstarg <starg@users.osdn.me>
Tue, 23 Aug 2016 20:59:23 +0000 (05:59 +0900)
include/ir/event.hpp
include/ir2midi/context.hpp
src/ast2ir/phrase2ir.cpp
src/ir2midi/context.cpp
src/ir2midi/ir2midi.cpp

index 1104f30..c7d66fa 100644 (file)
@@ -15,6 +15,8 @@ namespace IR
 
 class Rest final
 {
+public:
+    int Duration;
 };
 
 class PolyphonicAftertouch final
index dc414a3..e122e0e 100644 (file)
@@ -25,6 +25,7 @@ public:
     void EnterBlock();
     void SaveTime();
     void RestoreTime();
+    void UpdateTime(int relativeTime);
     void PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev);
     void SortEvents();
     const std::vector<AbsoluteMIDIEvent>& GetEvents() const;
index cbed111..e6cf511 100644 (file)
@@ -220,9 +220,7 @@ std::vector<IR::Block::EventType> Phrase2IRCompiler::operator()(const AST::NoteR
 std::vector<IR::Block::EventType> Phrase2IRCompiler::operator()(const AST::Rest& ast, int duration)
 {
     static_cast<void>(ast);
-    static_cast<void>(duration);
-
-    return {IR::Event{m_RelativeTime, IR::Rest{}}};
+    return {IR::Event{m_RelativeTime, IR::Rest{duration}}};
 }
 
 std::vector<IR::Block::EventType> Phrase2IRCompiler::operator()(const AST::NoteNumber& ast, int duration)
index 8734a22..7362803 100644 (file)
@@ -24,9 +24,14 @@ void TrackCompilerContext::RestoreTime()
     m_LastEventTime = m_PrevLastEventTime;
 }
 
-void TrackCompilerContext::PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev)
+void TrackCompilerContext::UpdateTime(int relativeTime)
 {
     m_LastEventTime = m_BaseTimeForCurrentBlock + relativeTime;
+}
+
+void TrackCompilerContext::PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev)
+{
+    UpdateTime(relativeTime);
     m_Events.push_back(AbsoluteMIDIEvent{m_LastEventTime, ev});
 }
 
index 7d6d861..debc350 100644 (file)
@@ -31,8 +31,9 @@ public:
         m_Context.PushEvent(m_RelativeTime + ev.Duration, MIDI::NoteOff{m_Channel, ev.Number, ev.OffVelocity});
     }
 
-    void operator()(const IR::Rest&)
+    void operator()(const IR::Rest& ev)
     {
+        m_Context.UpdateTime(m_RelativeTime + ev.Duration);
     }
 
     void operator()(const IR::PolyphonicAftertouch& ev)