Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2024 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #pragma once
23 :
24 : #include "../shared/musicxmltypes.h"
25 : #include "musicxmlvoicedesc.h"
26 :
27 : namespace mu::iex::musicxml {
28 : class MusicXmlOctaveShiftList : public std::map<engraving::Fraction, int>
29 : {
30 : public:
31 1884 : MusicXmlOctaveShiftList() {}
32 : int octaveShift(const engraving::Fraction f) const;
33 : void addOctaveShift(const int shift, const engraving::Fraction f);
34 : void calcOctaveShiftShifts();
35 : };
36 :
37 : class MusicXmlPart
38 : {
39 : public:
40 : MusicXmlPart(muse::String id = {}, muse::String name = {});
41 : void addMeasureNumberAndDuration(muse::String measureNumber, engraving::Fraction measureDuration);
42 : muse::String getId() const { return m_id; }
43 : muse::String toString() const;
44 : VoiceList voicelist; // the voice map information TODO: make private
45 : engraving::Fraction measureDuration(size_t i) const;
46 3520 : size_t nMeasures() const { return m_measureDurations.size(); }
47 : MusicXmlInstrList _instrList; // TODO: make private
48 : MusicXmlIntervalList _intervals; ///< Transpositions
49 : engraving::Interval interval(const engraving::Fraction f) const;
50 : int octaveShift(const engraving::staff_idx_t staff, const engraving::Fraction f) const;
51 : void addOctaveShift(const engraving::staff_idx_t staff, const int shift, const engraving::Fraction f);
52 : void calcOctaveShifts();
53 509 : void setName(muse::String nm) { m_name = nm; }
54 510 : muse::String getName() const { return m_name; }
55 511 : void setPrintName(const bool b) { m_printName = b; }
56 726 : bool getPrintName() const { return m_printName; }
57 388 : void setAbbr(muse::String ab) { m_abbr = ab; }
58 819 : muse::String getAbbr() const { return m_abbr; }
59 390 : void setPrintAbbr(const bool b) { m_printAbbr = b; }
60 707 : bool getPrintAbbr() const { return m_printAbbr; }
61 2 : std::map<int, int> staffNumberToIndex() const { return m_staffNumberToIndex; }
62 : int staffNumberToIndex(const int staffNumber) const;
63 2 : void insertStaffNumberToIndex(const int staffNumber, const int staffIndex) { m_staffNumberToIndex.insert({ staffNumber, staffIndex }); }
64 8149 : LyricNumberHandler& lyricNumberHandler() { return m_lyricNumberHandler; }
65 : const LyricNumberHandler& lyricNumberHandler() const { return m_lyricNumberHandler; }
66 : void setMaxStaff(const int staff);
67 471 : int maxStaff() const { return m_maxStaff; }
68 : bool isVocalStaff() const;
69 : bool isPercussionStaff() const;
70 280 : void hasLyrics(bool b) { m_hasLyrics = b; }
71 : private:
72 : muse::String m_id;
73 : muse::String m_name;
74 : bool m_printName = true;
75 : muse::String m_abbr;
76 : bool m_printAbbr = true;
77 : std::vector<muse::String> m_measureNumbers; // MusicXML measure number attribute
78 : std::vector<engraving::Fraction> m_measureDurations; // duration in fraction for every measure
79 : std::vector<MusicXmlOctaveShiftList> m_octaveShifts; // octave shift list for every staff
80 : LyricNumberHandler m_lyricNumberHandler;
81 : int m_maxStaff = -1; // maximum staff value found (0 based), -1 = none
82 : bool m_hasLyrics = false;
83 : std::map<int, int> m_staffNumberToIndex; // Mapping from staff number to index in staff list.
84 : // Only for when staves are discarded in MusicXmlParserPass1::attributes.
85 : };
86 : }
|