LibMusicXML 3.22
partsummary.h
1/*
2 MusicXML Library
3 Copyright (C) Grame 2006-2013
4
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9 Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10 research@grame.fr
11*/
12
13#ifndef __partsummary__
14#define __partsummary__
15
16#include <map>
17#include <vector>
18
19#include "notevisitor.h"
20#include "timePositions.h"
21#include "smartlist.h"
22
23namespace MusicXML2
24{
25
30
39class EXP partsummary :
40 public notevisitor,
41 public visitor<S_part>,
42 public visitor<S_measure>,
43 public visitor<S_staves>,
44 public visitor<S_divisions>,
45 public visitor<S_backup>,
46 public visitor<S_forward>,
47 public visitor<S_print>,
48 public visitor<S_direction>
49{
50 public:
51 partsummary() : fStavesCount(1) {
52 };
53 virtual ~partsummary() {};
54
56 int countStaves () const { return fStavesCount; }
58 int countVoices () const { return int(fVoices.size()); }
60 int countVoices (int staff) const;
61
63 smartlist<int>::ptr getStaves() const;
65 smartlist<int>::ptr getStaves (int voice) const;
67 int getStaffNotes (int id) const;
68
70 smartlist<int>::ptr getVoices () const;
72 smartlist<int>::ptr getVoices (int staff) const;
74 int getMainStaff (int voiceid) const;
76 int getVoiceNotes (int voiceid) const;
78 int getVoiceNotes (int staffid, int voiceid) const;
79 // staff distance from S_print
80 std::map<int, int> fStaffDistances;
81
82 MusicXMLTimePositions timePositions;
83
84 // staves, measures (by string name) and their position in measure, mapped to LINE NUMBER for all Octave-Shift elements
85 std::map<int, std::map<std::string, std::map<rational, int>>> fOctavas;
86
87 protected:
88 virtual void visitStart ( S_part& elt);
89 virtual void visitStart ( S_staves& elt);
90 virtual void visitStart ( S_print& elt);
91 virtual void visitEnd ( S_note& elt);
92 virtual void visitStart ( S_backup& elt );
93 virtual void visitStart ( S_forward& elt );
94 virtual void visitStart ( S_divisions& elt );
95 virtual void visitStart ( S_measure& elt );
96 virtual void visitStart ( S_direction& elt );
97
98 private:
99 // count of staves (from the staves element)
100 int fStavesCount;
101 // staves and corresponding count of notes
102 std::map<int, int> fStaves;
103 // voices and corresponding count of notes
104 std::map<int, int> fVoices;
105 // staves and corresponding voices + count of notes
106 std::map<int, std::map<int, int> > fStaffVoices;
107
108 // Internal map for Voice-Position for on-going measure
109 std::map<int, rational> fCurrentVoicedMeasurePosition;
110
111
112 long fCurrentDivision; // the current measure division, expresses the time unit in division of the quarter note
113 S_measure fCurrentMeasure;
114
115 void moveMeasureTime (long duration, int voice);
116
117 rational getMeasureTime(int voice);
118 rational maxStaffTime(int staff);
119};
120
122
123}
124
125#endif
smartlist< int >::ptr getVoices() const
returns the voices ids list
int getVoiceNotes(int voiceid) const
returns the count of notes on a voice
int getMainStaff(int voiceid) const
returns the id of the staff that contains the more of the voice notes
smartlist< int >::ptr getStaves() const
returns the staff ids list
int countVoices(int staff) const
returns the number of voices on a staff
int countVoices() const
returns the number of voices
Definition partsummary.h:58
smartlist< int >::ptr getVoices(int staff) const
returns the voices ids list for one staff
int countStaves() const
returns the number of staves for the part
Definition partsummary.h:56
int getStaffNotes(int id) const
returns the count of notes on a staff
smartlist< int >::ptr getStaves(int voice) const
returns the staff ids list for one voice
int getVoiceNotes(int staffid, int voiceid) const
returns the count of notes on a voice and a staff
Definition visitor.h:27
Definition timePositions.h:20
Rational number representation.
Definition rational.h:25