MuseScore  3.4
Music composition and notation
groups.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2013 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __GROUPS__
14 #define __GROUPS__
15 
16 #include "fraction.h"
17 #include "mscore.h"
18 #include "durationtype.h"
19 #include "beam.h"
20 
21 namespace Ms {
22 
23 class ChordRest;
24 class XmlWriter;
25 class XmlReader;
26 
27 //---------------------------------------------------------
28 // GroupNode
29 //---------------------------------------------------------
30 
31 struct GroupNode {
32  int pos; // tick position, division 32nd
33  int action; // bits: cccc bbbb aaaa
34  // cc - 1/64 bb - 1/32 aa - 1/16
35  // bit pattern xxxx:
36  // 1 - start new beam
37  // 2 - start new 1/32 subbeam
38  // 3 - start new 1/64 subbeam
39 
40  bool operator==(const GroupNode& g) const { return g.pos == pos && g.action == action; }
41  };
42 
43 //---------------------------------------------------------
44 // @@ Groups
46 //---------------------------------------------------------
47 
48 class Groups : public std::vector<GroupNode> {
49 
50  public:
51  Groups() {}
52  Groups(const std::vector<GroupNode>& l) : std::vector<GroupNode>(l) {}
53 
54  void write(XmlWriter&) const;
55  void read(XmlReader&);
56 
57  Beam::Mode beamMode(int tick, TDuration::DurationType d) const;
58  void addStop(int pos, TDuration::DurationType d, Beam::Mode bm);
59  bool operator==(const Groups& g) const {
60  if (g.size() != size())
61  return false;
62  for (unsigned i = 0; i < size(); ++i) {
63  if (!(g[i] == (*this)[i]))
64  return false;
65  }
66  return true;
67  }
68  void dump(const char*) const;
69 
70  static const Groups& endings(const Fraction& f);
71  static Beam::Mode endBeam(ChordRest* cr, ChordRest* prev = 0);
72  };
73 
74 //---------------------------------------------------------
75 // NoteGroup
76 //---------------------------------------------------------
77 
78 struct NoteGroup {
81  };
82 
83 
84 } // namespace Ms
85 
86 Q_DECLARE_METATYPE(Ms::Groups);
87 
88 #endif
89 
int action
Definition: groups.h:33
Definition: xml.h:67
Fraction timeSig
Definition: groups.h:79
DurationType
Definition: durationtype.h:30
bool operator==(const GroupNode &g) const
Definition: groups.h:40
Groups(const std::vector< GroupNode > &l)
Definition: groups.h:52
GroupNodes must be sorted by tick.
Definition: groups.h:48
Definition: groups.h:78
int pos
Definition: groups.h:32
Mode
Definition: beam.h:73
Definition: aeolus.cpp:26
Definition: xml.h:218
Definition: xmlwriter.h:26
Definition: chordrest.h:48
Groups endings
Definition: groups.h:80
Definition: xmlreader.h:28
Groups()
Definition: groups.h:51
Definition: groups.h:31
Definition: fraction.h:46
bool operator==(const Groups &g) const
Definition: groups.h:59