Note changes pitch, but accidental is not changed

• Dec 26, 2019 - 20:18
Reported version
3.3
Type
Functional
Frequency
Once
Severity
S3 - Major
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

There is an error that can occur when changing the accidental of a note. The following conditions must be met in order to produce the error:

  • The note must have an accidental that is not one of the 5 "usual" accidentals (i.e. sharp, flat, natural, double sharp, double flat).
  • The accidental is being changed to one of the 5 "usual" accidentals.
  • The change of accidental results in a change of pitch, and this pitch is not the pitch that the note would have without an accidental.

To observe this error, the following steps may be taken:

  1. Enter a note.
  2. Open the Accidentals palette, and click on the "Natural flat" accidental.
    The "Natural flat" is applied to the note, as expected.
  3. Now click on the "Double flat" accidental.
    The pitch of the note is changed, as verified by the sounding tone, as well as the status bar. But the note still has the "Natural flat" next to it, rather than the "Double flat".
  4. Click on the "Double flat" again.
    The note now has the correct accidental as well as the correct pitch.

This has nothing to do with the recent merge of https://github.com/musescore/MuseScore/pull/5341, nor does it have anything to do with changes involving single click interaction. From what I can tell, this error has been present for a long time.


Comments

Status PR created fixed

Fixed in branch master, commit 2f2d9e316e

_fix #298959: Note changes pitch, but accidental is not changed

Resolves: https://musescore.org/en/node/298959.

Note: In the following paragraphs, I use the word "microtonal" to refer to all accidentals for which Accidental::isMicrotonal() currently returns true. That is, all proper microtonal accidentals as well as NATURAL_FLAT, NATURAL_SHARP, and SHARP_SHARP.

When force adding or force removing an accidental, Score::changeAccidental() will remove a note's existing accidental (if any) from the score. When not force adding or force removing an accidental, the note's pitch is changed, but the accidental is left alone until Note::updateAccidental() is called. But Note::updateAccidental() does not touch microtonal accidentals, so any existing microtonal accidentals must be removed in Score::changeAccidental().

Also, when changing from a microtonal accidental to a non-microtonal accidental that results in the same change to the pitch of the note, the new accidental's role is currently set to USER every time, when in fact this should only be done if it truly is a courtesy accidental. So when determining whether or not the accidental is being force added, when we are comparing the new pitch to the old pitch, we should also look at whether the old accidental was microtonal or not, to make sure that the accidental's role is not being set incorrectly._

Fix version
3.5.0