MuseScore  3.4
Music composition and notation
importptb.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <libmscore/score.h>
4 #include <libmscore/mscore.h>
5 #include <libmscore/fraction.h>
6 #include <libmscore/fret.h>
7 #include <libmscore/chordrest.h>
8 #include <libmscore/slur.h>
9 #include <libmscore/clef.h>
10 #include <libmscore/keysig.h>
11 #include <libmscore/chordrest.h>
12 #include <libmscore/clef.h>
13 #include <libmscore/keysig.h>
14 #include <libmscore/hairpin.h>
15 #include <libmscore/ottava.h>
16 #include <libmscore/drumset.h>
17 
18 namespace Ms {
19 
20 class PalmMute;
21 
22 class PowerTab {
23  QFile* _file;
25 
26  bool readBoolean();
27  unsigned char readUChar();
28  char readChar();
29  unsigned short readShort();
30  int readInt();
31  void skip(int len = 1);
32  std::string readString(int length = -1);
33 
34  struct ptSongInfo {
35  int classification{ 0 };
36  int releaseType{ 0 };
37  int albumType{ 0 };
38  int day{ 0 };
39  int month{ 0 };
40  int year{ 0 };
41  int style{ 0 };
42  int level{ 0 };
43  bool liverecording{ 0 };
44  std::string name;
45  std::string interpret;
46  std::string album;
47  std::string author;
48  std::string lyricist;
49  std::string arrenger;
50  std::string guitarTranscriber;
51  std::string bassTranscriber;
52  std::string lyrics;
53  std::string guitarInstructions;
54  std::string bassInstructions;
55  std::string instructions;
56  std::string copyright;
57  };
58 
59  struct ptComponent {
60  enum Type {
65  Bar,
68  TDirection
69  };
70  virtual Type type() {
71  return Empty;
72  };
73 
74  virtual ~ptComponent() {}
75  };
76 
77  struct stRhytmSlash final : public ptComponent {
78  int position {0};
79  int duration {0};
80  bool triplet{ false };
81  bool tripletend{ false };
82  bool dotted{ false };
83  bool doubleDotted{ false };
84  bool is_rest{ false };
85  };
86 
87  struct ptGuitarIn final : public ptComponent {
88  int rhytmSlash{ true };
89  int staff{ 0 };
90  int trackinfo{ 0 };
91  int section{ 0 };
92  int position{ 0 };
93  Type type() override {
94  return GuitarIn;
95  }
96  };
97 
98  struct ptSymbol final : public ptComponent {
99  int value{ 0 };
100  ptSymbol(int val) : value(val) {}
101  Type type() override {
102  return Symbol;
103  }
104  };
105 
106  struct ptBar final : public ptComponent {
107  int measureNo{ 0 };
108  int repeatClose{ 0 };
109  bool repeatStart{ false };
110 
111  int numerator{ 0 };
112  int denominator{ 0 };
113  Type type() override {
114  return Bar;
115  }
116  };
117  std::vector<ptBar*> bars;
118 
119  struct ptNote final : public ptComponent {
120  int value{ 0 };
121  int str{ 0 };
122  int bend{0};
123  bool tied{ false };
124  bool dead{ false };
125  bool hammer{ false };
126  int slide{ 0 };
127  Type type() override {
128  return Note;
129  }
130  };
131 
132  struct ptChord final : public ptComponent {
133  int key;
134  int formula;
136  int extra;
137  int top_fret;
138  std::vector<int> frets;
139  };
140 
141  struct ptChordText final : public ptComponent {
142  int position;
143  int key;
144  int formula;
146  int extra;
147  };
148 
149  struct ptBeat final : public ptComponent {
150  int position{ 0 };
151  int staff{ 0 };
152  int voice{ 0 };
153  int mmrest{ 0 };
154  bool isRest{ false };
155  int duration{ 0 };
156  int enters{ 0 };
157  int times{ 0 };
158  bool dotted{ false };
159  bool tuplet{ false };
160  bool doubleDotted{ false };
161  bool vibrato{ false };
162  bool grace{ false };
163  bool arpegioUp{ false };
164  bool arpegioDown{ false };
165  bool palmMute{ false };
166  bool accent{ false };
167  bool staccato{ false };
168  std::vector<ptNote> notes;
169 
170  ptBeat(int _staff, int _voice) : staff(_staff), voice(_voice) {}
171  Type type() override {
172  return Beat;
173  }
174  };
175 
176  struct ptDirection final : public ptComponent {
177  enum Direction {
178  DIRECTION_CODA = 0,
179  DIRECTION_DOUBLE_CODA = 1,
180  DIRECTION_SEGNO = 2,
181  DIRECTION_SEGNO_SEGNO = 3,
182  DIRECTION_FINE = 4,
183  DIRECTION_DA_CAPO = 5,
184  DIRECTION_DAL_SEGNO = 6,
185  DIRECTION_DAL_SEGNO_SEGNO = 7,
186  DIRECTION_TO_CODA = 8,
187  DIRECTION_TO_DOUBLE_CODA = 9,
188  DIRECTION_DA_CAPO_AL_CODA = 10,
189  DIRECTION_DA_CAPO_AL_DOUBLE_CODA = 11,
190  DIRECTION_DAL_SEGNO_AL_CODA = 12,
191  DIRECTION_DAL_SEGNO_AL_DOUBLE_CODA = 13,
192  DIRECTION_DAL_SEGNO_SEGNO_AL_CODA = 14,
193  DIRECTION_DAL_SEGNO_SEGNO_AL_DOUBLE_CODA = 15,
194  DIRECTION_DA_CAPO_AL_FINE = 16,
195  DIRECTION_DAL_SEGNO_AL_FINE = 17,
196  DIRECTION_DAL_SEGNO_SEGNO_AL_FINE = 18
197  };
198 
199  enum ActiveSym {
200  ACTIVE_SYMBOL_NONE = 0,
201  ACTIVE_SYMBOL_DC = 1,
202  ACTIVE_SYMBOL_DS = 2,
203  ACTIVE_SYMBOL_DSS = 3
204  };
205 
206  Direction direction{ DIRECTION_CODA };
207  ActiveSym activeSymbol{ ACTIVE_SYMBOL_NONE };
208  int repeat{ 0 };
209 
210  ptDirection(int dir, int sym, int rep) : direction((Direction)dir),
211  activeSymbol((ActiveSym)sym), repeat(rep) {}
212  Type type() override {
213  return TDirection;
214  }
215  };
216 
217  struct ptPosition {
218  int position{ 0 };
219  std::vector<shared_ptr<ptComponent>> components;
220  void addComponent(ptComponent* c);
221  };
222 
223  struct TrackInfo {
224  int number{ 0 };
225  std::string name;
226  int instrument{ 0 };
227  int volume{ 0 };
228  int balance{ 0 };
229  int reverb{ 0 };
230  int chorus{ 0 };
231  int tremolo{ 0 };
232  int phaser{ 0 };
233  int capo{ 0 };
234  std::string tuningName;
235  int offset{ 0 };
236  std::vector<int> strings;
237  int notes_count{ 0 };
238  };
239 
240  typedef std::list<shared_ptr<ptBeat>> tBeatList;
241 
242  struct ptTrack;
243  struct ptSection {
244  int number{ 0 };
245  int staffs{ 0 };
246  std::string partName;
248  std::vector<ptPosition> positions;
249 
250  std::vector<int> staffMap;
251 
252  int tempo{ 0 };
253 
254  std::list<stRhytmSlash> rhytm;
255 
256  std::map<int, ptChordText> chordTextMap;
257  std::vector<tBeatList> beats;
258  std::list<shared_ptr<ptBar>> bars;
259  bool readed{ false };
260 
261  void copyTracks(ptTrack*);
262 
263  ptSection(int num);
264  ptPosition& getPosition(int pos);
265  int getNextPositionNumber();
266  };
267 
268  struct chordData {
269  int a[3];
270  bool operator > (const chordData& other) const {
271  if (a[0] == other.a[0]) {
272  if (a[1] == other.a[1]) {
273  return a[2] > other.a[2];
274  }
275  return a[1] > other.a[1];
276  }
277  return a[0] > other.a[0];
278  }
279  bool operator < (const chordData& other) const {
280  if (a[0] == other.a[0]) {
281  if (a[1] == other.a[1]) {
282  return a[2] < other.a[2];
283  }
284  return a[1] < other.a[1];
285  }
286  return a[0] < other.a[0];
287  }
288  bool operator == (const chordData& other) const {
289  return memcmp(a, other.a, 3 * sizeof(int)) == 0;
290  }
291  };
292 
293  struct ptTrack {
294  std::vector<TrackInfo> infos;
295  std::vector<ptSection> sections;
296  ptSection& getSection(int ind);
297  std::map < chordData, ptChord > diagramMap;
298 
299  std::list<ptGuitarIn> guitar_ins;
300  };
301 
302  struct ptSong {
306  };
307 
308  void readSongInfo(ptSongInfo& info);
309  void readDataInstruments(ptTrack& info);
310  void readTrackInfo(ptTrack& info);
311  void readGuitarIn(ptTrack& info);
312  void readTempoMarker(ptTrack& info);
313  void readSectionSymbol(ptTrack& info);
314  void readSection(ptSection& sec);
315  void readBarLine(ptSection& sec);
316  void readDirection(ptSection& sec);
317  void readTimeSignature(ptBar* bar);
318  void readStaff(int staff, ptSection& sec);
319  void readPosition(int staff, int voice, ptSection& sec);
320  void readNote(ptBeat* beat);
321  void readRehearsalSign(ptSection& sec);
322  void readChordText(ptSection& sec);
323  void readChord(ptTrack& si);
324  void readRhytmSlash(ptSection& sec);
325 
326  void readFloatingText();
327  void readFontSettings();
328  void readDynamic();
329  void readKeySignature();
330 
331  bool readVersion();
332  int readHeaderItems();
333 
334  std::vector<int> lastStaffMap;
335  std::vector<int> getStaffMap(ptSection& sec);
336  int repeatCount{ 0 };
337  void addToScore(ptSection& sec);
338 
339  Measure* createMeasure(ptBar* bar, const Fraction& tick);
340  void fillMeasure(tBeatList& elist, Measure* measure, int staff, std::vector<Note*>&);
341 
342  int staves{ 0 };
343 
345  int staffInc{ 0 };
346  char lastPart{ 0 };
347 
349 
350  std::vector<PalmMute*> _palmMutes;
351  void addPalmMute(Chord*);
352 
353  public:
354  PowerTab(QFile* f, MasterScore* s) : _file(f), score(s) {}
356  };
357 
358 }
void addToScore(ptSection &sec)
Definition: importptb.cpp:758
std::string arrenger
Definition: importptb.h:49
void readChord(ptTrack &si)
Definition: importptb.cpp:190
int repeatCount
Definition: importptb.h:336
std::string instructions
Definition: importptb.h:55
int key
Definition: importptb.h:143
int position
Definition: importptb.h:142
ActiveSym
Definition: importptb.h:199
std::vector< ptNote > notes
Definition: importptb.h:168
std::string copyright
Definition: importptb.h:56
std::list< shared_ptr< ptBar > > bars
Definition: importptb.h:258
Definition: importptb.h:87
int readInt()
Definition: importptb.cpp:55
Type type() override
Definition: importptb.h:113
Definition: importptb.h:59
void readDataInstruments(ptTrack &info)
Definition: importptb.cpp:1055
Definition: importptb.h:63
Definition of Score class.
char partMarker
Definition: importptb.h:247
one measure in a system
Definition: measure.h:65
Definition: score.h:1227
std::vector< int > staffMap
Definition: importptb.h:250
void readChordText(ptSection &sec)
Definition: importptb.cpp:259
ptSongInfo info
Definition: importptb.h:303
void readSongInfo(ptSongInfo &info)
Definition: importptb.cpp:90
ptBeat(int _staff, int _voice)
Definition: importptb.h:170
ptTrack track1
Definition: importptb.h:304
ptTrack * curTrack
Definition: importptb.h:344
std::string lyricist
Definition: importptb.h:48
void fillMeasure(tBeatList &elist, Measure *measure, int staff, std::vector< Note *> &)
Definition: importptb.cpp:597
int style
Definition: importptb.h:41
Definition: importptb.h:176
std::vector< int > strings
Definition: importptb.h:236
Definition: importptb.h:243
std::string readString(int length=-1)
Definition: importptb.cpp:62
Definition: importptb.h:65
int top_fret
Definition: importptb.h:137
std::string bassTranscriber
Definition: importptb.h:51
Type type() override
Definition: importptb.h:127
Type
Definition: importptb.h:60
std::vector< int > getStaffMap(ptSection &sec)
Definition: importptb.cpp:505
int formula_mod
Definition: importptb.h:145
Definition: importptb.h:34
Definition: importptb.h:223
Definition of classes Clef.
std::list< stRhytmSlash > rhytm
Definition: importptb.h:254
std::string lyrics
Definition: importptb.h:52
std::string name
Definition: importptb.h:225
std::vector< shared_ptr< ptComponent > > components
Definition: importptb.h:219
std::string author
Definition: importptb.h:47
void readGuitarIn(ptTrack &info)
Definition: importptb.cpp:306
Definition: importptb.h:268
void readDynamic()
Definition: importptb.cpp:236
Definition: importptb.h:293
int day
Definition: importptb.h:38
void readFloatingText()
Definition: importptb.cpp:223
virtual Type type()
Definition: importptb.h:70
std::list< shared_ptr< ptBeat > > tBeatList
Definition: importptb.h:240
Type type() override
Definition: importptb.h:93
MasterScore * score
Definition: importptb.h:24
std::string partName
Definition: importptb.h:246
std::vector< int > lastStaffMap
Definition: importptb.h:334
int year
Definition: importptb.h:40
std::vector< PalmMute * > _palmMutes
Definition: importptb.h:350
int readHeaderItems()
Definition: importptb.cpp:152
Definition: importptb.h:132
Definition: importptb.h:302
int classification
Definition: importptb.h:35
std::string name
Definition: importptb.h:44
QFile * _file
Definition: importptb.h:23
Definition: importptb.h:61
Definition: importptb.h:119
Type type() override
Definition: importptb.h:212
std::vector< TrackInfo > infos
Definition: importptb.h:294
Definition: importptb.h:64
Definition: importptb.h:98
Direction
Definition: importptb.h:177
char lastPart
Definition: importptb.h:346
std::list< ptGuitarIn > guitar_ins
Definition: importptb.h:299
Definition: importptb.h:141
Measure * createMeasure(ptBar *bar, const Fraction &tick)
Definition: importptb.cpp:1140
int formula
Definition: importptb.h:134
std::vector< ptBar * > bars
Definition: importptb.h:117
Definition: importptb.h:62
int a[3]
Definition: importptb.h:269
FileError
Definition: score.h:395
ptDirection(int dir, int sym, int rep)
Definition: importptb.h:210
void readKeySignature()
Definition: importptb.cpp:244
ptSymbol(int val)
Definition: importptb.h:100
Definition: aeolus.cpp:26
int albumType
Definition: importptb.h:37
void readPosition(int staff, int voice, ptSection &sec)
Definition: importptb.cpp:415
void readStaff(int staff, ptSection &sec)
Definition: importptb.cpp:380
void readNote(ptBeat *beat)
Definition: importptb.cpp:394
Definition: importptb.h:22
void readFontSettings()
Definition: importptb.cpp:212
unsigned short readShort()
Definition: importptb.cpp:40
std::vector< ptPosition > positions
Definition: importptb.h:248
bool readBoolean()
Definition: importptb.cpp:28
bool readVersion()
Definition: importptb.cpp:77
int extra
Definition: importptb.h:146
int staffInc
Definition: importptb.h:345
Graphic representation of a chord.
Definition: chord.h:55
std::vector< int > frets
Definition: importptb.h:138
ptSection * cur_section
Definition: importptb.h:348
int level
Definition: importptb.h:42
virtual ~ptComponent()
Definition: importptb.h:74
ptTrack track2
Definition: importptb.h:305
unsigned char readUChar()
Definition: importptb.cpp:33
void readSectionSymbol(ptTrack &info)
Definition: importptb.cpp:340
int key
Definition: importptb.h:133
std::string guitarTranscriber
Definition: importptb.h:50
void readDirection(ptSection &sec)
Definition: importptb.cpp:1045
int formula
Definition: importptb.h:144
Score::FileError read()
Definition: importptb.cpp:1205
std::map< int, ptChordText > chordTextMap
Definition: importptb.h:256
std::string tuningName
Definition: importptb.h:234
int staves
Definition: importptb.h:342
std::map< chordData, ptChord > diagramMap
Definition: importptb.h:297
PowerTab(QFile *f, MasterScore *s)
Definition: importptb.h:354
Graphic representation of a note.
Definition: note.h:212
Definition: fraction.h:46
std::string bassInstructions
Definition: importptb.h:54
void skip(int len=1)
Definition: importptb.cpp:84
Definition: importptb.h:149
Symbol
Definition: symbols.h:31
std::string album
Definition: importptb.h:46
int modification
Definition: importptb.h:135
std::string guitarInstructions
Definition: importptb.h:53
void readTrackInfo(ptTrack &info)
Definition: importptb.cpp:167
int extra
Definition: importptb.h:136
void readRehearsalSign(ptSection &sec)
Definition: importptb.cpp:249
Definition: importptb.h:66
std::vector< ptSection > sections
Definition: importptb.h:295
void readTempoMarker(ptTrack &info)
Definition: importptb.cpp:318
void addPalmMute(Chord *)
Definition: importptb.cpp:558
std::vector< tBeatList > beats
Definition: importptb.h:257
Type type() override
Definition: importptb.h:171
void readSection(ptSection &sec)
Definition: importptb.cpp:983
Definition: importptb.h:77
Definition: importptb.h:106
Type type() override
Definition: importptb.h:101
Definition: importptb.h:217
void readRhytmSlash(ptSection &sec)
Definition: importptb.cpp:271
void readBarLine(ptSection &sec)
Definition: importptb.cpp:360
char readChar()
Definition: importptb.cpp:47
Definition: importptb.h:67
bool liverecording
Definition: importptb.h:43
int month
Definition: importptb.h:39
int releaseType
Definition: importptb.h:36
std::string interpret
Definition: importptb.h:45
void readTimeSignature(ptBar *bar)
Definition: importptb.cpp:350