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 : #pragma once
23 :
24 : #include "modularity/ioc.h"
25 :
26 : #include "iinstrumentsrepository.h"
27 : #include "async/asyncable.h"
28 :
29 : #include "io/ifilesystem.h"
30 : #include "inotationconfiguration.h"
31 : #include "framework/musesampler/imusesamplerinfo.h"
32 :
33 : namespace mu::notation {
34 : class InstrumentsRepository : public IInstrumentsRepository, public muse::async::Asyncable
35 : {
36 : muse::GlobalInject<muse::io::IFileSystem> fileSystem;
37 : muse::GlobalInject<INotationConfiguration> configuration;
38 : muse::GlobalInject<muse::musesampler::IMuseSamplerInfo> museSampler;
39 :
40 : public:
41 0 : InstrumentsRepository() = default;
42 :
43 : void init();
44 :
45 : const InstrumentTemplateList& instrumentTemplates() const override;
46 : const InstrumentTemplate& instrumentTemplate(const muse::String& instrumentId) const override;
47 :
48 : const ScoreOrderList& orders() const override;
49 : const ScoreOrder& order(const muse::String& orderId) const override;
50 :
51 : const InstrumentGenreList& genres() const override;
52 : const InstrumentGroupList& groups() const override;
53 :
54 : const InstrumentStringTuningsMap& stringTuningsPresets() const override;
55 :
56 : private:
57 : using InstrumentTemplateMap = std::unordered_map<muse::String, const InstrumentTemplate*>;
58 :
59 : void load();
60 : void clear();
61 :
62 : bool loadStringTuningsPresets(const muse::io::path_t& path);
63 : void loadMuseInstruments(const InstrumentTemplateMap& standardInstrumentByMusicXmlId);
64 :
65 : InstrumentTemplateList m_instrumentTemplateList;
66 : InstrumentTemplateMap m_instrumentTemplateMap;
67 : InstrumentStringTuningsMap m_stringTuningsPresets;
68 : };
69 : }
|