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 :
23 : #pragma once
24 :
25 : #include "modularity/ioc.h"
26 : #include "engraving/types/types.h"
27 : #include "iglobalconfiguration.h"
28 :
29 : namespace mu::engraving {
30 : class Drumset;
31 : class Instrument;
32 : class MasterScore;
33 : class Score;
34 : }
35 :
36 : namespace mu::project {
37 : using RepitchFunc = std::function<int (int)>;
38 :
39 : class MdlMigrator
40 : {
41 : muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
42 :
43 : public:
44 0 : MdlMigrator(mu::engraving::MasterScore* score)
45 0 : : m_score(score) {}
46 :
47 : void remapPercussion();
48 :
49 : private:
50 : bool loadDrumset(mu::engraving::Drumset* drumset, muse::io::path_t path);
51 : void remapPitches(mu::engraving::track_idx_t startTrack, mu::engraving::track_idx_t endTrack, mu::engraving::Fraction startTick,
52 : mu::engraving::Fraction endTick, const RepitchFunc& repitch);
53 : bool needToRemap(const mu::engraving::Instrument& instr, RepitchFunc& repitch, muse::io::path_t& drumsetPath);
54 :
55 : // Repitch functions
56 : static int repitchMdlSnares(int pitch);
57 : static int repitchMdlTenors(int pitch);
58 : static int repitchMdlBassline10(int pitch);
59 : static int repitchMdlBassline5(int pitch);
60 : static int repitchMdlCymballine(int pitch);
61 :
62 : mu::engraving::MasterScore* m_score = nullptr;
63 : };
64 : }
|