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 "engraving/dom/mscore.h"
25 :
26 : namespace mu::iex::musicxml {
27 : //---------------------------------------------------------
28 : // VoiceDesc
29 : //---------------------------------------------------------
30 :
31 : /**
32 : The description of a single voice in a MusicXML part.
33 : */
34 :
35 : class VoiceDesc
36 : {
37 : public:
38 : VoiceDesc();
39 : void incrChordRests(int s);
40 : int numberChordRests() const;
41 141 : int numberChordRests(int s) const { return (s >= 0 && s < engraving::MAX_STAVES) ? m_chordRests[s] : 0; }
42 : int preferredStaff() const; // Determine preferred staff for this voice
43 579 : void setStaff(int s)
44 : {
45 579 : if (s >= 0) {
46 578 : m_staff = s;
47 : }
48 579 : }
49 :
50 8712 : int staff() const { return m_staff; }
51 578 : void setVoice(int v)
52 : {
53 578 : if (v >= 0) {
54 578 : m_voice = v;
55 : }
56 578 : }
57 :
58 7370 : int voice() const { return m_voice; }
59 14 : void setVoice(int s, int v)
60 : {
61 14 : if (s >= 0 && s < engraving::MAX_STAVES) {
62 14 : m_voices[s] = v;
63 : }
64 14 : }
65 :
66 28 : int voice(int s) const { return (s >= 0 && s < engraving::MAX_STAVES) ? m_voices[s] : -1; }
67 9 : void setOverlap(bool b) { m_overlaps = b; }
68 11953 : bool overlaps() const { return m_overlaps; }
69 16 : void setStaffAlloc(int s, int i)
70 : {
71 16 : if (s >= 0 && s < engraving::MAX_STAVES) {
72 16 : m_staffAlloc[s] = i;
73 : }
74 16 : }
75 :
76 2391 : int staffAlloc(int s) const { return (s >= 0 && s < engraving::MAX_STAVES) ? m_staffAlloc[s] : -1; }
77 : muse::String toString() const;
78 : private:
79 : int m_chordRests[engraving::MAX_STAVES]; // The number of chordrests on each MusicXML staff
80 : int m_staff; // The MuseScore staff allocated
81 : int m_voice; // The MuseScore voice allocated
82 : bool m_overlaps; // This voice contains active notes in multiple staves at the same time
83 : int m_staffAlloc[engraving::MAX_STAVES]; // For overlapping voices: voice is allocated on these staves (note: -2=unalloc -1=undef 1=alloc)
84 : int m_voices[engraving::MAX_STAVES]; // For every voice allocated on the staff, the voice number
85 : };
86 : typedef std::map<int, VoiceDesc> VoiceList;
87 : }
|