Skip to content

Fix microtonal key sig playback #34030

Open
Ash-86 wants to merge 1 commit into
musescore:mainfrom
Ash-86:apply-microtonal-key-sig-
Open

Fix microtonal key sig playback #34030
Ash-86 wants to merge 1 commit into
musescore:mainfrom
Ash-86:apply-microtonal-key-sig-

Conversation

@Ash-86

@Ash-86 Ash-86 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Resolves: #25604

@Ash-86 Ash-86 force-pushed the apply-microtonal-key-sig- branch from 8141ebc to 1bcf660 Compare July 1, 2026 15:40
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 20c41b64-7e46-4787-a871-2c746eb5a1e8

📥 Commits

Reviewing files that changed from the base of the PR and between 8141ebc and 1bcf660.

📒 Files selected for processing (2)
  • src/engraving/dom/note.cpp
  • src/engraving/dom/note.h
✅ Files skipped from review due to trivial changes (1)
  • src/engraving/dom/note.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/engraving/dom/note.cpp

📝 Walkthrough

Walkthrough

This change adds Note::effectiveCentOffset() to resolve a note’s cent offset from an explicit accidental first, then from custom key-signature definitions at the note’s tick when available, otherwise returning 0.0. The method is declared in note.h and implemented in note.cpp, which also includes types/symnames.h. Note::playingTuning() now uses effectiveCentOffset() instead of reading m_centOffset directly.

Changes

Area Change
note.h Declared new public method effectiveCentOffset() const
note.cpp Added symnames.h include; implemented effectiveCentOffset(); updated playingTuning() to use it

Sequence Diagram(s)

sequenceDiagram
  participant ComponentA
  participant ComponentB
  ComponentA->>ComponentB: observable interaction
Loading

Related issues: None found in the provided context.

Related PRs: None found in the provided context.

Suggested labels: engraving, playback

Suggested reviewers: None specified in the provided context.

Poem
A note seeks cents by sign and key,
Then plays with tuned consistency.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is only a resolver reference and misses the required summary, motivation, and checklist content from the template. Add the missing template sections, including a short change summary, motivation, checklist items, testing details, and prior-attempt notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: fixing microtonal key signature playback.
Linked Issues check ✅ Passed The code now derives playback cent offset from custom key signatures, matching the microtonal accidental playback fix requested in #25604.
Out of Scope Changes check ✅ Passed The changes remain focused on note playback cent-offset handling and the supporting Note API/header addition.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped musescore/muse_framework.git.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In `@src/engraving/dom/note.cpp`:
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4fe54173-ee3f-402a-b739-e9f9acaa92f3

📥 Commits

Reviewing files that changed from the base of the PR and between d7f0fa7 and 8141ebc.

📒 Files selected for processing (2)
  • src/engraving/dom/note.cpp
  • src/engraving/dom/note.h

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom key signatures don't apply microtonal accidentals

2 participants