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 : #include "chordlinemetaparser.h"
24 :
25 : #include "dom/chordline.h"
26 :
27 : using namespace mu::engraving;
28 : using namespace muse;
29 : using namespace muse::mpe;
30 :
31 4 : void ChordLineMetaParser::doParse(const EngravingItem* item, const RenderingContext& ctx, mpe::ArticulationMap& result)
32 : {
33 4 : IF_ASSERT_FAILED(item) {
34 0 : return;
35 : }
36 :
37 4 : if (!item->isChordLine()) {
38 0 : return;
39 : }
40 :
41 4 : const ChordLine* chordLine = toChordLine(item);
42 :
43 4 : ArticulationType type = chordLineArticulationType(chordLine->chordLineType());
44 :
45 4 : if (type == ArticulationType::Undefined) {
46 0 : return;
47 : }
48 :
49 4 : const mpe::ArticulationPattern& pattern = ctx.profile->pattern(type);
50 4 : if (pattern.empty()) {
51 4 : return;
52 : }
53 :
54 0 : appendArticulationData(mpe::ArticulationMeta(type, pattern, ctx.nominalTimestamp, ctx.nominalDuration), result);
55 : }
56 :
57 4 : ArticulationType ChordLineMetaParser::chordLineArticulationType(const ChordLineType chordLineType)
58 : {
59 : static const std::unordered_map<ChordLineType, ArticulationType> ARTICULATION_TYPES = {
60 : { ChordLineType::DOIT, ArticulationType::Doit },
61 : { ChordLineType::FALL, ArticulationType::Fall },
62 : { ChordLineType::PLOP, ArticulationType::Plop },
63 : { ChordLineType::SCOOP, ArticulationType::Scoop }
64 6 : };
65 :
66 4 : auto search = ARTICULATION_TYPES.find(chordLineType);
67 :
68 4 : if (search != ARTICULATION_TYPES.cend()) {
69 4 : return search->second;
70 : }
71 :
72 0 : return ArticulationType::Undefined;
73 : }
|