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) 2025 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 <array>
25 : #include <map>
26 : #include <vector>
27 :
28 : #include "engraving/dom/mscore.h"
29 : #include "engraving/types/types.h"
30 :
31 : namespace mu::iex::tabledit {
32 : struct TefNote;
33 :
34 : class VoiceAllocator
35 : {
36 : public:
37 : void addColumn(const std::vector<const TefNote*>& column);
38 : void addNote(const TefNote* const note, const bool preferVoice0);
39 : void allocateVoice(const TefNote* const note, int voice);
40 : bool canAddTefNoteToVoice(const TefNote* const note, const int voice);
41 : void dump();
42 : int findFirstPossibleVoice(const TefNote* const note, const std::array<int, 3> voices);
43 : int stopPosition(const size_t voice);
44 : int voice(const TefNote* const note);
45 292 : const std::vector<std::vector<const TefNote*> >& voiceContent(mu::engraving::voice_idx_t voice) const
46 : {
47 292 : return voiceContents.at(voice);
48 : }
49 :
50 : private:
51 : void appendNoteToVoice(const TefNote* const note, int voice);
52 : std::map<const TefNote*, int> allocations;
53 : std::array<const TefNote*, mu::engraving::VOICES> notesPlaying = { nullptr, nullptr, nullptr, nullptr };
54 : std::array<std::vector<std::vector<const TefNote*> >, mu::engraving::VOICES> voiceContents;
55 : };
56 : } // namespace mu::iex::tabledit
|