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 "gracenotesmetaparser.h"
24 :
25 : #include "dom/chord.h"
26 :
27 : using namespace mu::engraving;
28 : using namespace muse;
29 :
30 20 : void GraceNotesMetaParser::doParse(const EngravingItem* item, const RenderingContext& ctx, mpe::ArticulationMap& result)
31 : {
32 20 : IF_ASSERT_FAILED(item->isChord()) {
33 0 : return;
34 : }
35 :
36 20 : mpe::ArticulationType type = mpe::ArticulationType::Undefined;
37 :
38 20 : const Chord* graceChord = toChord(item);
39 :
40 20 : if (!graceChord->isChordPlayable()) {
41 1 : return;
42 : }
43 :
44 19 : switch (graceChord->noteType()) {
45 4 : case NoteType::ACCIACCATURA:
46 4 : type = mpe::ArticulationType::Acciaccatura;
47 4 : break;
48 :
49 5 : case NoteType::APPOGGIATURA:
50 : case NoteType::GRACE4:
51 : case NoteType::GRACE16:
52 : case NoteType::GRACE32:
53 5 : type = mpe::ArticulationType::PreAppoggiatura;
54 5 : break;
55 :
56 10 : case NoteType::GRACE8_AFTER:
57 : case NoteType::GRACE16_AFTER:
58 : case NoteType::GRACE32_AFTER:
59 10 : type = mpe::ArticulationType::PostAppoggiatura;
60 10 : break;
61 0 : default:
62 0 : break;
63 : }
64 :
65 19 : if (type == mpe::ArticulationType::Undefined) {
66 0 : return;
67 : }
68 :
69 19 : const mpe::ArticulationPattern& pattern = ctx.profile->pattern(type);
70 19 : if (pattern.empty()) {
71 0 : return;
72 : }
73 :
74 19 : appendArticulationData(mpe::ArticulationMeta(type, pattern, ctx.nominalTimestamp, ctx.nominalDuration), result);
75 : }
|