Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect pitch when using insert input mode in first measure with alto clef #26029

Open
4 tasks done
L0uisc opened this issue Jan 8, 2025 · 6 comments
Open
4 tasks done
Assignees

Comments

@L0uisc
Copy link
Contributor

L0uisc commented Jan 8, 2025

Issue type

Engraving bug (incorrect score rendering)

Description with steps to reproduce

  1. Select "new score" on "Scores" page in home tab.
  2. Create a new score based on treble clef template
  3. Change treble clef to alto clef
  4. Change note input mode to "insert"
  5. Enter note input mode on the first beat of the first bar.
  6. Type "C" to enter C
  7. Expected: Note C is input and sounds.
  8. Actual: Note is drawn on Middle C (middle line of the stave), but it sounds B4 and is displayed as B4 on the bottom note property display area.
  9. Inserting more notes by typing "C" are consistently an octave above the previous one. See screenshot. These octaves are also indicated and sound as B, even though they are technically C.

Workaround: add first note in step time input mode.

Supporting files, videos and screenshots

image

What is the latest version of MuseScore Studio where this issue is present?

4.5 prerelease 8 Jan 2025

Regression

No

Operating system

OS: Windows 11 Version 2009 or later, Arch.: x86_64, MuseScore Studio version (64-bit): 4.5.0-, revision: github-musescore-musescore-

Checklist

  • This report follows the guidelines for reporting bugs and issues
  • I have verified that this issue has not been logged before, by searching the issue tracker for similar issues
  • I have attached all requested files and information to this report
  • I have attempted to identify the root problem as concisely as possible, and have used minimal reproducible examples where possible
@sammik
Copy link
Contributor

sammik commented Jan 8, 2025

Any clef changed in first measure causes this issue.
(For example bass cleff staff with changed celf to treble in firs measure).

@L0uisc
Copy link
Contributor Author

L0uisc commented Jan 9, 2025

Indeed. Should have mentioned it in the report.

@sammik
Copy link
Contributor

sammik commented Jan 10, 2025

Not a regression, same issue in MU 3.6.2 too.

@oktophonie oktophonie added os: linux Potentially specific to Linux-based operating systems UX/interaction P3 Priority: Low and removed os: linux Potentially specific to Linux-based operating systems labels Jan 10, 2025
@oktophonie oktophonie moved this to Some release after that in MuseScore Studio Backlog Jan 10, 2025
@L0uisc
Copy link
Contributor Author

L0uisc commented Jan 11, 2025

I've started to look into this. Will try to investigate further, but afaict the issue must originate here

Ret Score::insertChordByInsertingTime(const Position& pos)
in Score::insertChordByInsertingTime() somewhere before
putNote(p, true);
.

The issue only manifests in insert mode, and step time note input mode just directly calls putNote(). So my suspicion is that the bug is somewhere in the code which only gets executed when inserting, but not in the other input modes.

@sammik
Copy link
Contributor

sammik commented Jan 11, 2025

In fact, core of issue is in Staff::insertTime, and affects also key signatures (and may be instrumentChanges too).

In short, if clef is after barline (start of score, or option "after barline") record in staffList is manipulated (moved).

// check if there is a clef at the end of measure
// before tick
Clef* clef = 0;
Measure* m = score()->tick2measure(tick);
if (m && (m->tick() == tick) && (m->prevMeasure())) {
m = m->prevMeasure();
Segment* s = m->findSegment(SegmentType::Clef, tick);
if (s) {
track_idx_t track = idx() * VOICES;
clef = toClef(s->element(track));
}
}
ClefList cl2;
for (auto i = m_clefs.lower_bound(tick.ticks()); i != m_clefs.end();) {
ClefTypeList ctl = i->second;
Fraction t = Fraction::fromTicks(i->first);
if (clef && tick == t) {
++i;
continue;
}
m_clefs.erase(i++);
cl2.setClef((t + len).ticks(), ctl);
}
m_clefs.insert(cl2.begin(), cl2.end());
// check if there is a clef at the end of measure
// before tick: do not remove from clefs list
if (clef) {
setClef(clef);
}

Some situations are handled on many different places, I think (basic "clef before barline" directly in insertTime, other situations, if I remember in Scorre::insertMeasure / removeMeasure, others in Undo:InsertMeasure)

Short fix could be to add option to move / remove elements at tick.

Another variant of this issue is removing first note in place of key signature (select note, Ctrl + Del) - key signature itself remains in score, but record from keyList is removed see:

keysig-removeTime-issue.mp4

But I think, something deeper, redesign and refactor would be neccessary in future. Sorry for my language, I dont know right terms, but I hope, it would be understable.

I think realtion between Clef (in score) and clefList /and same for Key signature and keyList, Instrument change and instrumenList, staffTypeChange and staffTypeList/

It is good, that under the hood, it is possible to manipulate Celf, and clefList independently, but in most situations, they should be "linked", so (re)moving Clef erase/move record in clefList /or vice versa, (re)moving record in clefList (re)moves Clef itself.

So I think, there sould be "trinity":
manipulateClefOnly
manipulateClefListOnly
manipulateClef (which process both manipulateClefListOnly and manipulateClefOnly under the hood), and in most cases, we should use this third function.

(And same for others, keys, times, instruments, whatever...)

@sammik
Copy link
Contributor

sammik commented Jan 21, 2025

I belive, same core in #21095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Some release after that
Development

No branches or pull requests

4 participants