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 : #include "midimodule.h"
23 :
24 : #include "modularity/ioc.h"
25 :
26 : #include "project/inotationreadersregister.h"
27 : #include "internal/notationmidireader.h"
28 : #include "project/inotationwritersregister.h"
29 : #include "internal/notationmidiwriter.h"
30 :
31 : #include "internal/midiconfiguration.h"
32 :
33 : #include "log.h"
34 :
35 : using namespace muse::modularity;
36 : using namespace mu::iex::midi;
37 : using namespace mu::project;
38 :
39 0 : std::string MidiModule::moduleName() const
40 : {
41 0 : return "iex_midi";
42 : }
43 :
44 0 : void MidiModule::registerExports()
45 : {
46 0 : m_configuration = std::make_shared<MidiConfiguration>();
47 :
48 0 : globalIoc()->registerExport<IMidiImportExportConfiguration>(moduleName(), m_configuration);
49 0 : }
50 :
51 0 : void MidiModule::resolveImports()
52 : {
53 0 : auto readers = globalIoc()->resolve<INotationReadersRegister>(moduleName());
54 0 : if (readers) {
55 0 : readers->reg({ "mid", "midi", "kar" }, std::make_shared<NotationMidiReader>());
56 : }
57 :
58 0 : auto writers = globalIoc()->resolve<INotationWritersRegister>(moduleName());
59 0 : if (writers) {
60 0 : writers->reg({ "mid", "midi", "kar" }, std::make_shared<NotationMidiWriter>(globalCtx()));
61 : }
62 0 : }
63 :
64 0 : void MidiModule::onInit(const muse::IApplication::RunMode&)
65 : {
66 0 : m_configuration->init();
67 0 : }
|