Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/engraving/dom/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "../editing/transpose.h"
#include "types/typesconv.h"
#include "iengravingfont.h"
#include "types/symnames.h"

#include "rendering/score/horizontalspacing.h"

Expand Down Expand Up @@ -2613,7 +2614,7 @@ int Note::playingOctave() const

double Note::playingTuning() const
{
return m_tuning + m_centOffset;
return m_tuning + effectiveCentOffset();
}
Comment on lines 2615 to 2618

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve explicit cent offsets and avoid degree-only key matches.

Line 2617 now makes effectiveCentOffset() the playback source, but Lines 4138-4159 never fall back to m_centOffset; notes set through Pid::CENT_OFFSET/setCentOffset() without a current accidental will stop playing their stored offset. Also, Lines 4151-4155 apply custom-key cents by degree only, so a chromatically altered note that inherits a prior accidental and has no m_accidental can still receive the custom key-signature microtonal offset.

Proposed fix
 double Note::effectiveCentOffset() const
 {
     if (m_accidental) { // explicit note-level accidental wins
-        double offset = Accidental::subtype2centOffset(m_accidental->accidentalType());
-        return offset;  
+        return Accidental::subtype2centOffset(m_accidental->accidentalType());
+    }
+    if (!muse::RealIsNull(m_centOffset)) {
+        return m_centOffset;
     }
     if (!staff() || !chord()) {
         return 0.0;
     }
@@
     }
     int deg = tpc2step(tpc());
+    AccidentalVal accVal = tpc2alter(tpc());
     for (const CustDef& cd : kse.customKeyDefs()) {
-        if (kse.degInKey(cd.degree) == deg) {
-            return Accidental::subtype2centOffset(
-                Accidental::name2subtype(SymNames::nameForSymId(cd.sym)));
+        if (kse.degInKey(cd.degree) != deg) {
+            continue;
+        }
+        AccidentalType accType = Accidental::name2subtype(SymNames::nameForSymId(cd.sym));
+        if (Accidental::subtype2value(accType) == accVal) {
+            return Accidental::subtype2centOffset(accType);
         }
     }
     return 0.0;
 }

Also applies to: 4138-4159

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/dom/note.cpp` around lines 2615 - 2618, Update
Note::playingTuning() and the accidental/custom-key handling in
Note::effectiveCentOffset() so explicit cent offsets stored via
Pid::CENT_OFFSET/setCentOffset() are preserved even when there is no current
accidental. Also tighten the custom key-signature cents lookup to require the
active accidental state, not just the note degree, so inherited chromatic notes
without m_accidental do not get degree-only microtonal offsets.


//---------------------------------------------------------
Expand Down Expand Up @@ -4133,4 +4134,27 @@ staff_idx_t Note::vStaffIdx() const
const Chord* c = chord();
return c ? c->vStaffIdx() : EngravingItem::vStaffIdx();
}

double Note::effectiveCentOffset() const
{
if (m_accidental) { // explicit note-level accidental wins
double offset = Accidental::subtype2centOffset(m_accidental->accidentalType());
return offset;
}
if (!staff() || !chord()) {
return 0.0;
}
const KeySigEvent& kse = staff()->keySigEvent(chord()->tick());
if (!kse.custom()) {
return 0.0;
}
int deg = tpc2step(tpc());
for (const CustDef& cd : kse.customKeyDefs()) {
if (kse.degInKey(cd.degree) == deg) {
return Accidental::subtype2centOffset(
Accidental::name2subtype(SymNames::nameForSymId(cd.sym)));
}
}
return 0.0;
}
}
1 change: 1 addition & 0 deletions src/engraving/dom/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class Note final : public EngravingItem
double centOffset() const { return m_centOffset; }
void setCentOffset(double v) { m_centOffset = v; }
int quarterToneOffset() const { return std::round(m_centOffset / 50); }
double effectiveCentOffset() const;

int ottaveCapoFret() const;
int linkedOttavaPitchOffset() const;
Expand Down
Loading