OSDN Git Service

曲の先頭以外にコマンドがあるとタイミングがずれていたのを修正
[yamml/yamml-git.git] / include / ir2midi / context.hpp
1
2 #pragma once
3
4 #include <string>
5 #include <vector>
6
7 #include <midi/event.hpp>
8
9 namespace YAMML
10 {
11
12 namespace IR2MIDI
13 {
14
15 class AbsoluteMIDIEvent final
16 {
17 public:
18     int AbsoluteTime;
19     MIDI::MIDIEvent::EventType Event;
20 };
21
22 class TrackCompilerContext final
23 {
24 public:
25     TrackCompilerContext() = default;
26
27     explicit TrackCompilerContext(int lastEventTime)
28     {
29         SetLastEventTime(lastEventTime);
30     }
31
32     void EnterBlock();
33     int GetLastEventTime();
34     void SetLastEventTime(int t);
35     void UpdateTime(int relativeTime);
36     void PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev);
37     void SortEvents();
38     const std::vector<AbsoluteMIDIEvent>& GetEvents() const;
39
40 private:
41     std::vector<AbsoluteMIDIEvent> m_Events;
42     int m_BaseTimeForCurrentBlock = 0;
43     int m_LastEventTime = 0;
44 };
45
46 class IIR2MIDICompiler
47 {
48 public:
49     virtual ~IIR2MIDICompiler() = default;
50
51     virtual std::string GetSourceName() const = 0;
52     virtual TrackCompilerContext& GetTrackContext(int trackNumber) = 0;
53 };
54
55 } // namespace IR2MIDI
56
57 } // namespace YAMML