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 "annotationsmetaparser.h"
24 :
25 : #include "dom/dynamic.h"
26 :
27 : using namespace mu::engraving;
28 : using namespace muse;
29 : using namespace muse::mpe;
30 :
31 42 : void AnnotationsMetaParser::doParse(const EngravingItem* item, const RenderingContext& ctx, mpe::ArticulationMap& result)
32 : {
33 42 : IF_ASSERT_FAILED(item) {
34 0 : return;
35 : }
36 :
37 42 : mpe::ArticulationType type = mpe::ArticulationType::Undefined;
38 :
39 42 : if (item->isDynamic()) {
40 5 : const Dynamic* dynamic = toDynamic(item);
41 5 : const DynamicType dynamicType = dynamic->dynamicType();
42 :
43 5 : if (dynamicType == DynamicType::S
44 5 : || dynamicType == DynamicType::SF
45 5 : || dynamicType == DynamicType::SFF
46 5 : || dynamicType == DynamicType::SFFF
47 5 : || dynamicType == DynamicType::SFZ
48 5 : || dynamicType == DynamicType::SFFZ
49 5 : || dynamicType == DynamicType::SFFFZ
50 5 : || dynamicType == DynamicType::SFP
51 5 : || dynamicType == DynamicType::SFPP) {
52 0 : type = mpe::ArticulationType::Subito;
53 : }
54 : }
55 :
56 42 : if (type == mpe::ArticulationType::Undefined) {
57 42 : return;
58 : }
59 :
60 0 : const mpe::ArticulationPattern& pattern = ctx.profile->pattern(type);
61 0 : if (pattern.empty()) {
62 0 : return;
63 : }
64 :
65 0 : appendArticulationData(mpe::ArticulationMeta(type, pattern, ctx.nominalTimestamp, ctx.nominalDuration), result);
66 : }
|