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) 2021 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 :
23 : #ifndef MU_ENGRAVING_SYNTHESIZERSTATE_H
24 : #define MU_ENGRAVING_SYNTHESIZERSTATE_H
25 :
26 : #include <list>
27 :
28 : #include "global/allocator.h"
29 : #include "types/string.h"
30 :
31 : namespace mu::engraving {
32 : class SynthesizerState;
33 :
34 : class XmlWriter;
35 : class XmlReader;
36 :
37 : //---------------------------------------------------------
38 : // IdValue
39 : //---------------------------------------------------------
40 :
41 : struct IdValue {
42 : int id = 0;
43 : muse::String data;
44 :
45 : IdValue() {}
46 0 : IdValue(int _id, const muse::String& _data)
47 0 : : id(_id), data(_data) {}
48 : };
49 :
50 : //---------------------------------------------------------
51 : // SynthesizerGroup
52 : //---------------------------------------------------------
53 :
54 : class SynthesizerGroup : public std::list<IdValue>
55 : {
56 : OBJECT_ALLOCATOR(engraving, SynthesizerGroup)
57 :
58 : public:
59 0 : const muse::String& name() const { return m_name; }
60 0 : void setName(const muse::String& s) { m_name = s; }
61 :
62 36 : SynthesizerGroup()
63 36 : : std::list<IdValue>() {}
64 : SynthesizerGroup(const char* n, std::list<IdValue> l)
65 : : std::list<IdValue>(l), m_name(muse::String::fromUtf8(n)) {}
66 :
67 : private:
68 : muse::String m_name;
69 : };
70 :
71 : //---------------------------------------------------------
72 : // SynthesizerState
73 : //---------------------------------------------------------
74 :
75 : class SynthesizerState : public std::list<SynthesizerGroup>
76 : {
77 : OBJECT_ALLOCATOR(engraving, SynthesizerState)
78 :
79 : public:
80 : SynthesizerState(std::initializer_list<SynthesizerGroup> l)
81 : {
82 : insert(end(), l.begin(), l.end());
83 : }
84 :
85 2346 : SynthesizerState()
86 2346 : : std::list<SynthesizerGroup>() {}
87 :
88 : void write(XmlWriter&, bool force = false) const;
89 : void read(XmlReader&);
90 : SynthesizerGroup group(const muse::String& name) const;
91 : bool isDefaultSynthSoundfont();
92 : int ccToUse() const;
93 : int method() const;
94 0 : bool isDefault() const { return m_isDefault; }
95 0 : void setIsDefault(bool val) { m_isDefault = val; }
96 :
97 : private:
98 :
99 : bool m_isDefault = true;
100 : };
101 : } // namespace mu::engraving
102 : #endif
|