Line data Source code
1 : #ifndef MU_IMPORTEXPORT_GPTRACK_H
2 : #define MU_IMPORTEXPORT_GPTRACK_H
3 :
4 : #include <unordered_map>
5 : #include <string>
6 :
7 : #include "types/string.h"
8 :
9 : namespace mu::iex::guitarpro {
10 : class GPTrack
11 : {
12 : public:
13 : struct RSE {
14 : float pan{ 0 };
15 : float volume{ 0 };
16 : float chorus{ 0 };
17 : float reverb{ 0 };
18 : float phase{ 0 };
19 : float tremolo{ 0 };
20 : };
21 :
22 : struct StaffProperties {
23 : int fretCount{ 24 };
24 : int capoFret{ 0 };
25 : std::vector<int> tuning;
26 : bool useFlats{ false };
27 : bool ignoreFlats{ false };
28 : };
29 :
30 : struct InstrumentString {
31 : int num{ 0 };
32 : int tunning{ 0 };
33 : };
34 :
35 : struct Diagram {
36 : int id{ 0 };
37 : muse::String name;
38 : int stringCount{ 0 };
39 : int fretCount{ 0 };
40 : int baseFret{ 0 };
41 : std::unordered_map<int, int> frets;
42 : // there are some other tags
43 : // which cant be used in MU
44 : };
45 :
46 : struct Sound {
47 : int programm{ 0 };
48 : muse::String name;
49 : muse::String label;
50 : muse::String path;
51 : muse::String role;
52 : };
53 :
54 : struct SoundAutomation {
55 : muse::String type;
56 : muse::String value;
57 : int bar = 0;
58 : bool linear = 0;
59 : float position = 0;
60 : };
61 :
62 239 : GPTrack(int idx)
63 239 : : _idx(idx) {}
64 478 : virtual ~GPTrack() = default;
65 :
66 239 : void setName(const muse::String& n) { _name = n; }
67 242 : muse::String name() const { return _name; }
68 :
69 239 : void setShortName(const muse::String& s) { _shortName = s; }
70 239 : muse::String shortName() const { return _shortName; }
71 :
72 82 : void setInstrument(const muse::String& s) { _instrument = s; }
73 3 : muse::String instrument() const { return _instrument; }
74 :
75 238 : void setRSE(const RSE& r) { _rse = r; }
76 478 : const RSE& rse() const { return _rse; }
77 :
78 239 : void setProgramm(int pr) { _programm = pr; }
79 442 : int programm() const { return _programm; }
80 :
81 239 : void setMidiChannel(int ch) { _midiChannel = ch; }
82 256 : int midiChannel() const { return _midiChannel; }
83 :
84 80 : void setIsGuitar(bool arg) { _isGuitar = arg; }
85 : bool isGuitar() const { return _isGuitar; }
86 :
87 241 : void setStaffProperties(const StaffProperties& st) { _staffProperties = st; }
88 236 : const StaffProperties& staffProperties() const { return _staffProperties; }
89 :
90 : void addSound(Sound sound);
91 :
92 : struct SoundAutomationPos {
93 : int bar = 0;
94 : float pos = 0;
95 :
96 78 : bool operator<(const SoundAutomationPos& other) const { return std::tie(bar, pos) < std::tie(other.bar, other.pos); }
97 : };
98 :
99 171 : void addSoundAutomation(SoundAutomation val) { _automations.insert({ { val.bar, val.position }, val }); }
100 342 : const std::unordered_map<muse::String, Sound>& sounds() { return _sounds; }
101 239 : const std::map<SoundAutomationPos, SoundAutomation>& soundAutomations() { return _automations; }
102 :
103 : std::vector<InstrumentString> strings() const
104 : {
105 : std::vector<InstrumentString> ss;
106 : for (size_t i = 0; i < _staffProperties.tuning.size(); ++i) {
107 : ss.push_back({ static_cast<int>(i + 1), _staffProperties.tuning.at(i) });
108 : }
109 :
110 : return ss;
111 : }
112 :
113 158 : void setStaffCount(size_t n) { _staffCount = n; }
114 720 : size_t staffCount() const { return _staffCount; }
115 :
116 237 : void setTranspose(int t) { _transpose = t; }
117 1906 : int transpose() const { return _transpose; }
118 :
119 27 : void addDiagram(std::pair<int, Diagram>&& d) { _diagrams.insert(d); }
120 29 : const std::unordered_map<int, Diagram>& diagram() const { return _diagrams; }
121 :
122 238 : void setLyrics(const std::string& l) { _lyrics = l; }
123 : const std::string& lyrics() const { return _lyrics; }
124 :
125 238 : void setLyricsOffset(int n) { _lyricsOffset = n; }
126 : int lyricsOffset() const { return _lyricsOffset; }
127 :
128 3 : void setLineCount(int n) { _lineCount = n; }
129 : int lineCount() const { return _lineCount; }
130 :
131 410 : int idx() const { return _idx; }
132 :
133 : protected:
134 :
135 : muse::String _name;
136 : muse::String _shortName;
137 : muse::String _instrument;
138 : RSE _rse;
139 : int _programm{ 0 };
140 : int _midiChannel{ 0 };
141 : bool _isGuitar{ false };
142 : int _idx{ -1 };
143 : size_t _staffCount{ 1 };
144 : StaffProperties _staffProperties;
145 : std::unordered_map<muse::String, Sound> _sounds;
146 : std::map<SoundAutomationPos, SoundAutomation> _automations;
147 : int _transpose{ 0 };
148 : std::unordered_map<int, Diagram> _diagrams;
149 : std::string _lyrics;
150 : int _lyricsOffset = { 0 };
151 : int _lineCount{ 5 }; // for percussion lines
152 : };
153 :
154 : class GP6Track : public GPTrack
155 : {
156 : public:
157 : GP6Track(int idx)
158 : : GPTrack(idx) {}
159 :
160 : private:
161 : };
162 :
163 : class GP7Track : public GPTrack
164 : {
165 : public:
166 : GP7Track(int idx)
167 : : GPTrack(idx) {}
168 :
169 : private:
170 : };
171 : } // namespace mu::iex::guitarpro
172 : #endif // MU_IMPORTEXPORT_GPTRACK_H
|