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

Alignment of left-justified lyrics on whole notes different depending on stem direction #16878

Closed
oktophonie opened this issue Mar 17, 2023 · 10 comments · Fixed by #17840
Closed
Assignees
Labels
engraving good first issue Issues suitable for first-time contributors. See https://github.com/musescore/MuseScore/contribute P2 Priority: Medium

Comments

@oktophonie
Copy link
Contributor

oktophonie commented Mar 17, 2023

Issue type

Engraving bug

Bug description

When a lyric starts on a whole note and is left-justified on it (as it would be for a melisma), the alignment is different according to the stem direction of the chord. There should be no difference.

image
Here, the first note is upstemmed and the second note is downstemmed. (I made the lyrics much smaller than usual to make the difference more obvious.)

It looks like on the second note the lyric is aligned with the left of the bounding box of the notehead. This looks better than the first note to me; in any case, they should both be the same, as changing the stem direction of the note has no other graphical consequences in this case.

MuseScore Version

OS: Artix Linux, Arch.: x86_64, MuseScore version (64-bit): 4.1.0-230760632, revision: github-musescore-musescore-fdc7952

Regression

No.

Operating system

Linux, Windows 11

@oktophonie oktophonie added P2 Priority: Medium engraving labels Mar 17, 2023
@oktophonie oktophonie assigned oktophonie and mike-spa and unassigned mike-spa Mar 17, 2023
@bkunda bkunda added the good first issue Issues suitable for first-time contributors. See https://github.com/musescore/MuseScore/contribute label May 10, 2023
@MengLinMaker
Copy link
Contributor

Could I tackle this issue?
I think I would need information on how to reproduce the problem.

@oktophonie
Copy link
Contributor Author

It only occurs on unstemmed notes where the alignment of the lyric is set to 'Align left'.
Here you can see the difference as I flip the note repeatedly (by pressing X):

box-230511-1707-48.mp4

You're very welcome to try to find a solution!

@oktophonie oktophonie assigned MengLinMaker and unassigned mike-spa May 11, 2023
@MengLinMaker
Copy link
Contributor

@oktophonie Successfully reproduced your described issue.
I also reproduced this issue when the lyric is set to 'Align right'
https://github.com/musescore/MuseScore/assets/39476147/57c60d0f-a250-486c-8f6d-628d9606a488

@MengLinMaker
Copy link
Contributor

MengLinMaker commented May 12, 2023

Interestingly this change in placement is different for different Notehead types.
Recording_12_05_2023_14_23_15.webm
Description: pressing 'x' to change the direction of the 'stem', while the text is left aligned.

It seems that wider noteheads without stems creates the bigger displacements.
Recording_12_05_2023_18_20_34.webm

According to xiaomigros, allowing stem flipping on stemless notes produces better horizontal alignment (multiple voices and lyrics). So a possible solution would be to calculate the right placement of lyrics based on notehead width

@MengLinMaker
Copy link
Contributor

MengLinMaker commented May 13, 2023

@oktophonie It's not just the lyrics that show this behavior:
https://github.com/musescore/MuseScore/assets/39476147/66f387ed-1576-4f6e-8458-edce1db0b5d4

Should the alignment of these other text types also remain the same after stem flips?

This issue applies to:

  • Lyrics
  • Sustain pedals
  • Let ring
  • Palm mute

@MengLinMaker
Copy link
Contributor

MengLinMaker commented May 13, 2023

Helpful information for locating files:

  • Lyric inspector qml: src/inspector/view/qml/MuseScore/Inspector/text/TextInspectorView.qml
  • Pedal inspector qml: src/inspector/view/qml/MuseScore/Inspector/notation/lines/PedalSettings.qml

I believe these qml scripts are mapped to the "abstractinspectormodel" class: src/inspector/models/abstractinspectormodel.cpp through another class signal: PropertyItem::applyToStyleRequested().

This appears to apply styles through a "styleId": mu::engraving::Sid styleId.

How does these UI relate to the code that changes the position information of Lyrics, Sustain pedal?

@cbjeukendrup
Copy link
Contributor

@MengLinMaker The UI files are not relevant for this issue, since it is purely an engraving issue and not an interaction issue. But for completeness, I will tell you how the Inspector works:

  1. When the user changes something in the UI, the value property of the PropertyItem is changed in QML.
  2. The PropertyItem emits the propertyModified signal.
  3. This signal is handled by AbstractInspectorModel; see AbstractInspectorModel::initPropertyItem where it is connected.
  4. The handler eventually calls AbstractInspectorModel::setPropertyValue, which communicates the change to the engraving module, where the actual engraving objects live.

But to find the cause of this issue, you'll need to look at the code where the layout is computed, which is in the files in the src/engraving/layout folder.

@MengLinMaker
Copy link
Contributor

@cbjeukendrup Thank you, I've been trying to locate the relevant files.
I thought if I worked backwards from the UI I would be able to locate the relevant files.

@MengLinMaker
Copy link
Contributor

So I have identified how to remove the alignment flipping issue:
Recording_15_05_2023_17_12_03.webm

Reference file location: src/engraving/layout/lyricslayout.cpp

There is a minor issue where the offset alignment is the same for all noteheads. I believe adjustments for different noteheads should be made.

@MengLinMaker
Copy link
Contributor

MengLinMaker commented May 16, 2023

I think the alignment problem is caused by the ChordRest moving with stem flips. This causes the lyrics to also move. ChordRest = 0 when the notehead is a half, quarter, eighth note... so in this case no movement is observed.

Additional consideration:

  • Which note should lyric align to in a chord with different notehead sizes?

After these considerations, I've decided to optimise for the most common notehead size (half, quarter...)

Submitting pull request

MengLinMaker added a commit to MengLinMaker/MuseScore that referenced this issue May 16, 2023
MengLinMaker added a commit to MengLinMaker/MuseScore that referenced this issue Jun 3, 2023
MengLinMaker added a commit to MengLinMaker/MuseScore that referenced this issue Jun 3, 2023
MengLinMaker added a commit to MengLinMaker/MuseScore that referenced this issue Jun 5, 2023
RomanPudashkin added a commit that referenced this issue Jun 15, 2023
…lignment

Fix #16878: Enforce same lyric alignment stem flip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engraving good first issue Issues suitable for first-time contributors. See https://github.com/musescore/MuseScore/contribute P2 Priority: Medium
Projects
Status: Done
5 participants