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) 2025 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 "note.h"
24 :
25 : namespace mu::iex::tabledit {
26 710 : EffectType TefNote::effect() const
27 : {
28 710 : if (simpleEffect == 0 && (complexEffect & 0x0F) == 0) {
29 418 : return EffectType::NONE;
30 292 : } else if (simpleEffect != 0 && (complexEffect & 0x0F) == 0) {
31 194 : switch (simpleEffect) {
32 0 : case 0: return EffectType::NONE; // for completeness, but not reached
33 14 : case 1: return EffectType::HAMMER_ON;
34 9 : case 2: return EffectType::PULL_OFF;
35 10 : case 3: return EffectType::SLIDE;
36 7 : case 4: return EffectType::CHOKE;
37 14 : case 5: return EffectType::BRUSH;
38 35 : case 6: return EffectType::NATURAL_HARMONIC;
39 7 : case 7: return EffectType::ARTIFICIAL_HARMONIC;
40 7 : case 8: return EffectType::MUTED;
41 0 : case 9: return EffectType::TAPPING;
42 0 : case 0xA: return EffectType::VIBRATO;
43 0 : case 0xB: return EffectType::TREMOLO;
44 0 : case 0xC: return EffectType::SIMPLE_BEND;
45 0 : case 0xD: return EffectType::BEND_AND_RELEASE;
46 84 : case 0xE: return EffectType::ROLL_ARPEGGIO;
47 7 : case 0xF: return EffectType::DEAD_NOTE;
48 0 : default: return EffectType::INVALID;
49 : }
50 98 : } else if (simpleEffect == 0 && (complexEffect & 0x0F) != 0) {
51 98 : switch (complexEffect & 0x0F) {
52 0 : case 0: return EffectType::NONE; // for completeness, but not reached
53 28 : case 1: return EffectType::RINGING_NOTE;
54 0 : case 2: return EffectType::SLAP;
55 14 : case 3: return EffectType::RASGUEADO;
56 0 : case 4: return EffectType::GHOST_NOTE;
57 0 : case 5: return EffectType::TREMOLO_UP_DOWN;
58 0 : case 6: return EffectType::TREMOLO_DIVE_RETURN;
59 56 : case 7: return EffectType::STACCATO;
60 0 : case 8: return EffectType::FADE_IN;
61 0 : case 9: return EffectType::FADE_OUT;
62 0 : default: return EffectType::INVALID;
63 : }
64 : }
65 0 : return EffectType::INVALID;
66 : }
67 :
68 602 : EffectType TefNote::combinationEffect() const
69 : {
70 602 : switch (complexEffect & 0xF0) {
71 519 : case 0: return EffectType::NONE;
72 6 : case 0x10: return EffectType::HAMMER_ON;
73 8 : case 0x20: return EffectType::PULL_OFF;
74 17 : case 0x30: return EffectType::ROLL;
75 5 : case 0x50: return EffectType::BRUSH;
76 24 : case 0x60: return EffectType::NATURAL_HARMONIC;
77 6 : case 0x70: return EffectType::ARTIFICIAL_HARMONIC;
78 4 : case 0x80: return EffectType::RINGING_NOTE;
79 0 : case 0x90: return EffectType::GHOST_NOTE;
80 13 : case 0xB0: return EffectType::VARIATION;
81 0 : default: return EffectType::INVALID;
82 : }
83 : }
84 :
85 : // return TablEdit note length in 64th (including triplets rounded down to nearest note length)
86 : // TODO: remove code duplication with importtef.cpp duration2length()
87 :
88 355 : int durationToInt(uint8_t duration)
89 : {
90 355 : switch (duration) {
91 70 : case 0: return 64; //"whole";
92 3 : case 1: return 48; //"half dotted";
93 0 : case 2: return 32; //"whole triplet";
94 79 : case 3: return 32; //"half";
95 2 : case 4: return 24; //"quarter dotted";
96 0 : case 5: return 16; //"half triplet";
97 168 : case 6: return 16; //"quarter";
98 2 : case 7: return 12; //"eighth dotted";
99 5 : case 8: return 8; //"quarter triplet";
100 11 : case 9: return 8; //"eighth";
101 2 : case 10: return 6; //"16th dotted";
102 5 : case 11: return 4; //"eighth triplet";
103 2 : case 12: return 4; //"16th";
104 2 : case 13: return 3; //"32nd dotted";
105 0 : case 14: return 2; //"16th triplet";
106 2 : case 15: return 2; //"32nd";
107 : //case 16: return "64th dotted";
108 0 : case 17: return 1; //"32nd triplet";
109 2 : case 18: return 1; //"64th";
110 0 : case 19: return 56; //"half double dotted";
111 : //case 20: return "16th quintuplet";
112 0 : case 22: return 28; //"quarter double dotted";
113 0 : case 25: return 14; //"eighth double dotted";
114 0 : case 28: return 7; //"16th double dotted";
115 0 : default: return 0; //"undefined";
116 : }
117 : }
118 : } // namespace mu::iex::tabledit
|