Package: musescore2 / 2.3.2+dfsg4-16

upstream/pitch-ottava.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Origin: backport, commit:66be5a18fa40a6358b0a78723adcd42f15176fcc
Author: Niek van den Berg <njvdberg@xs4all.nl>
Description: fix #293593 - Issues with ottavas
 Corrects first problem: Status doesn't display the pitch of note that have an
 ottave line. This is solved in Note::tpcUserName().
 .
 Solves the second problem in issue 293593: Accidentals do apply if 8va sign is added.
 This is solved in Note::updateAccidental(). All calculations are based on the
 effective pitch of the a note rather than the actual pitch. The solution now
 takes to ottava signs into account by using the actual pitch.
 .
 For easily find out whether an ottava is applied, a new method ottavaCapoFret()
 is added which returns the pitch offset by an ottava (or capo fret). To prevent
 code dublication, ppitch() also use this new ottavaCapoFret() method.

--- a/libmscore/note.cpp
+++ b/libmscore/note.cpp
@@ -415,7 +415,7 @@ int Note::tpc() const
 QString Note::tpcUserName(bool explicitAccidental) const
       {
       QString pitchName = tpc2name(tpc(), NoteSpellingType::STANDARD, NoteCaseType::AUTO, explicitAccidental);
-      QString octaveName = QString::number((epitch() / 12) - 1);
+      QString octaveName = QString::number(((epitch() + ottaveCapoFret()) / 12) - 1);
       return pitchName + (explicitAccidental ? " " : "") + octaveName;
       }
 
@@ -1923,11 +1923,12 @@ void Note::updateAccidental(AccidentalSt
 
             AccidentalVal accVal = tpc2alter(tpc());
             bool error = false;
-            AccidentalVal relLineAccVal = as->accidentalVal(relLine, error);
+            int eRelLine = absStep(tpc(), epitch()+ottaveCapoFret());
+            AccidentalVal relLineAccVal = as->accidentalVal(eRelLine, error);
             if (error)
                   return;
-            if ((accVal != relLineAccVal) || hidden() || as->tieContext(relLine)) {
-                  as->setAccidentalVal(relLine, accVal, _tieBack != 0);
+            if ((accVal != relLineAccVal) || hidden() || as->tieContext(eRelLine)) {
+                  as->setAccidentalVal(eRelLine, accVal, _tieBack != 0);
                   acci = Accidental::value2subtype(accVal);
                   // if previous tied note has same tpc, don't show accidental
                   if (_tieBack && _tieBack->startNote()->tpc1() == tpc1())
@@ -2175,6 +2176,18 @@ void Note::setHeadGroup(NoteHead::Group
       }
 
 //---------------------------------------------------------
+//   ottaveCapoFret
+//    offset added by Ottava's and Capo Fret.
+//---------------------------------------------------------
+
+int Note::ottaveCapoFret() const
+      {
+      Chord* ch = chord();
+
+      return staff()->pitchOffset(ch->segment()->tick());
+      }
+
+//---------------------------------------------------------
 //   ppitch
 //    playback pitch
 //---------------------------------------------------------
@@ -2192,7 +2205,7 @@ int Note::ppitch() const
                         return div.pitch;
                   }
             }
-      return _pitch + staff()->pitchOffset(ch->segment()->tick());
+      return _pitch + ottaveCapoFret();
 
       }
 
--- a/libmscore/note.h
+++ b/libmscore/note.h
@@ -296,6 +296,7 @@ class Note : public Element {
       void undoSetPitch(int val);
       void setPitch(int pitch, int tpc1, int tpc2);
       int pitch() const                   { return _pitch;    }
+      int ottaveCapoFret() const;
       int ppitch() const;           ///< playback pitch
       int epitch() const;           ///< effective pitch
       qreal tuning() const                { return _tuning;   }