Skip to content

[4.7] fix issue #32962 [TablEdit import] string/fret assignments ignored in part 2 and up#32973

Open
Jojo-Schmitz wants to merge 1 commit intomusescore:4.7from
Jojo-Schmitz:4.7-ports
Open

[4.7] fix issue #32962 [TablEdit import] string/fret assignments ignored in part 2 and up#32973
Jojo-Schmitz wants to merge 1 commit intomusescore:4.7from
Jojo-Schmitz:4.7-ports

Conversation

@Jojo-Schmitz
Copy link
Copy Markdown
Contributor

@Jojo-Schmitz Jojo-Schmitz commented Apr 9, 2026

Resolves: #32962
Backport of #32966

Summary by CodeRabbit

  • Bug Fixes

    • Corrected tablature string-offset handling so normal and grace notes import to the correct strings across instruments with different string counts.
  • Tests

    • Added a multi-track tablature fixture covering 6/5/4-string setups and a new automated test.
    • Updated a couple of test note fret/string values to match expected import results.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c396e821-4f17-4493-ba02-298856250e87

📥 Commits

Reviewing files that changed from the base of the PR and between f6b85e5 and c758d12.

📒 Files selected for processing (5)
  • src/importexport/tabledit/internal/importtef.cpp
  • src/importexport/tabledit/tests/data/multi_track_frets.mscx
  • src/importexport/tabledit/tests/data/multi_track_frets.tef
  • src/importexport/tabledit/tests/data/time_signatures_2.mscx
  • src/importexport/tabledit/tests/tabledit_tests.cpp

📝 Walkthrough

Walkthrough

Adjusts TablEdit importer string indexing by introducing a stringOffset parameter to the local helper that creates notes, and updates grace-note string/pitch calculations accordingly. Adds a multi-part tablature test fixture and a GoogleTest that exercises the new test data.

Changes

Cohort / File(s) Summary
Importer change
src/importexport/tabledit/internal/importtef.cpp
Added stringOffset parameter to static helper addNoteToChord; use tefNote->string - stringOffset - 1 for note.string and for grace-note pitch/string lookups; updated call sites in TablEdit::createContents.
New test data
src/importexport/tabledit/tests/data/multi_track_frets.mscx
Added new MuseScore .mscx fixture containing three parts with 6-/5-/4-string tablatures and explicit fret/string values to validate multi-part imports.
Test data tweak
src/importexport/tabledit/tests/data/time_signatures_2.mscx
Adjusted two tablature <Note> entries: <fret> changed from 15 and <string> from 12.
Test case
src/importexport/tabledit/tests/tabledit_tests.cpp
Added TEST_F(TablEdit_Tests, tef_multi_track_frets) which calls tefReadTest("multi_track_frets").

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • RomanPudashkin
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing TablEdit import string/fret assignments for parts 2 and up, directly addressing issue #32962.
Description check ✅ Passed The description is minimal but contains the essential resolution reference and backport context. The template checkboxes are not filled, but the core information is present.
Linked Issues check ✅ Passed Code changes correctly fix the string offset calculation bug in the TablEdit importer. The signature update to addNoteToChord to accept stringOffset parameter, adjusted call sites, and fixed grace-note handling all directly address the root cause identified in #32962 by ensuring correct string/fret assignments for all parts.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to fixing the string offset issue: core fix in importtef.cpp, test data files for validation, and a new test case. No refactoring or unrelated changes present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/importexport/tabledit/internal/importtef.cpp (1)

256-267: 🧹 Nitpick | 🔵 Trivial

Derive stringIndex once to avoid drift between pitch/string computations.

The conversion formula is repeated in multiple places. Computing it once per note and passing it through reduces future mismatch risk.

♻️ Proposed refactor
-static void addNoteToChord(mu::engraving::Chord* chord, const TefNote* tefNote, int stringOffset, int pitch, muse::draw::Color color,
+static void addNoteToChord(mu::engraving::Chord* chord, const TefNote* tefNote, int stringIndex, int pitch, muse::draw::Color color,
                            std::vector<mu::engraving::Note*>& tiedNotes)
 {
@@
-        note->setString(tefNote->string - stringOffset - 1);
+        note->setString(stringIndex);
@@
-                        for (const auto note : tefNotes) {
-                            const auto stringOffset = stringNumberPreviousParts(part);
+                        const int stringOffset = stringNumberPreviousParts(part);
+                        for (const auto note : tefNotes) {
+                            const int stringIndex = note->string - stringOffset - 1;
                             // todo fix magical constant 96 and code duplication
-                            int pitch = 96 - instrument.tuning.at(note->string - stringOffset - 1) + note->fret;
+                            int pitch = 96 - instrument.tuning.at(stringIndex) + note->fret;
                             LOGN("      -> string %d fret %d pitch %d", note->string, note->fret, pitch);
                             // note TableEdit's strings start at 1, MuseScore's at 0
-                            addNoteToChord(chord, note, stringOffset, pitch, toColor(voice), tiedNotes);
+                            addNoteToChord(chord, note, stringIndex, pitch, toColor(voice), tiedNotes);
                             if (note->hasGrace) {
                                 // todo fix magical constant 96 and code duplication
-                                int gracePitch = 96 - instrument.tuning.at(note->string - stringOffset - 1) + note->graceFret;
-                                addGraceNotesToChord(chord, gracePitch, note->graceFret, note->string - stringOffset - 1, toColor(voice));
+                                int gracePitch = 96 - instrument.tuning.at(stringIndex) + note->graceFret;
+                                addGraceNotesToChord(chord, gracePitch, note->graceFret, stringIndex, toColor(voice));
                             }
                         }

Also applies to: 437-447


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 17eae987-256c-4a1d-b22d-7b62b6b50be5

📥 Commits

Reviewing files that changed from the base of the PR and between c5ac9d6 and f6b85e5.

📒 Files selected for processing (5)
  • src/importexport/tabledit/internal/importtef.cpp
  • src/importexport/tabledit/tests/data/multi_track_frets.mscx
  • src/importexport/tabledit/tests/data/multi_track_frets.tef
  • src/importexport/tabledit/tests/data/time_signatures_2.mscx
  • src/importexport/tabledit/tests/tabledit_tests.cpp

@Jojo-Schmitz
Copy link
Copy Markdown
Contributor Author

♻️ Proposed refactor

Refactoring is out of scope for a pure and plain backport

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.

3 participants