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     void EnterBlock();
26     void SaveTime();
27     void RestoreTime();
28     void PushEvent(int relativeTime, const MIDI::MIDIEvent::EventType& ev);
29     void SortEvents();
30     const std::vector<AbsoluteMIDIEvent>& GetEvents() const;
31
32 private:
33     std::vector<AbsoluteMIDIEvent> m_Events;
34     int m_BaseTimeForCurrentBlock = 0;
35     int m_LastEventTime = 0;
36     int m_PrevLastEventTime = 0;
37 };
38
39 class IIR2MIDICompiler
40 {
41 public:
42     virtual ~IIR2MIDICompiler() = default;
43
44     virtual std::string GetSourceName() const = 0;
45     virtual TrackCompilerContext& GetTrackContext(int trackNumber) = 0;
46 };
47
48 } // namespace IR2MIDI
49
50 } // namespace YAMML