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

More beautiful default layout related to tremolos (fix #20390) (+ collect_artifacts) #5619

Merged
merged 9 commits into from
Apr 14, 2020

Conversation

Harmoniker1
Copy link
Contributor

@Harmoniker1 Harmoniker1 commented Jan 17, 2020

This PR uses minAbsStemLength() for all stems with tremolos (default placement and placing mid-stem), after some modification.

Below are a quick overview and some explanations. All layout principles stated below are in Behind Bars:

Layout diff:
tremoloVisual1-1
tremoloVisual2-1
See #5619 (review) for the layout change of the tremolo in the third measure

  • Improvements for single-note tremolos:
  1. Fixes https://musescore.org/node/20390. The tremolo should be inside the staff. This is done here in Tremolo::layoutOneNoteTremolo().

  2. Avoid collision between hook/beam and tremolo by extending stem. This is done in Chord::minAbsStemLength() with the calculation of beamLvl and beamDist. It becomes very effective by calculating a fairly new variable: the vertical distance between note and the far edge of tremolo, which can be seen here.

  3. Set a minimum value and reasonable interval of note-tremolo distance, and extend stem accordingly. The former is done here in Tremolo::layoutOneNoteTremolo(). and the latter is done in Chord::minAbsStemLength(). This is based on the principle that nearest distance between chord and tremolo stroke should be no less than 1sp, which is represented by 3.0 in the code.

  • Improvements for two-note tremolos:
  1. Reduce slope of beam stroke(s) if too steep by extending stem (if stem exists, which can automatically alter tremolo layout subsequently) or altering tremolo layout (if no stem). This is seen in various examples provided by Behind Bars. The new stem lengths are calculated in a new function extendedStemLenWithTwoNotesTremolo(), which is called after the default stem lengths of two notes are both calculated. Semibreves and longer notes don't have stem, so for those tremolos. the layout is directly altered. Since layout of these tremolos also depend on the concept of "stem length" even if there're no stem, in here, extendedStemLenWithTwoNotesTremolo() is called externally to get the right layout.

  2. Avoid collison between beam and tremolo. This is also done in Chord::minAbsStemLength().

@MarcSabatella
Copy link
Contributor

Definitely a big improvement! I wonder though, if it's really necessary to make the stem so long with the hooks? Seems Gould is OK with the hooks overlapping a bit, and it looks less weird to me. Maybe 1sp less long for that second note?

Also, I'm not sure the ramifications of altering stem length in "minAbs..." versus "default..." but be sure there are no weird dependencies where this causes, say, autoplaced text above the staff to not position itself properly. Could you do an update with "+ collect_artifacts" to make it easier for others to test?

@Harmoniker1
Copy link
Contributor Author

I wonder though, if it's really necessary to make the stem so long with the hooks?

Under this musical font, you'll probably find the occasions of 16th and shorter notes pretty ugly, if the stem is shorter, even if an 8th note looks fine, because the offset of different hooks is, well, different. But if you then want to differentiate the offset based on note duration, then some other musical fonts, which have the same offset for all kinds of hooks, will not be happy too. Besides, this is not that weird to look at. Personally, I find shortening the stem another kind of "weird" too.

@Harmoniker1
Copy link
Contributor Author

Could you do an update with "+ collect_artifacts" to make it easier for others to test?

Commit message or PR title?

@MarcSabatella
Copy link
Contributor

Commit message. See the "git workflow" documentation for MuseScore for more on build artifacts. I do this when I particularly want to get some real world testing of a proposed change, it allows people to download a nightly build without needing to build for themselves.

@Harmoniker1 Harmoniker1 changed the title More beautiful default layout related to tremolos (fix #20390) More beautiful default layout related to tremolos (fix #20390) (+ collect_artifacts) Jan 19, 2020
@Harmoniker1
Copy link
Contributor Author

@MarcSabatella Done. I saw that artifacts had been attached to the build job.

libmscore/tremolo.cpp Outdated Show resolved Hide resolved
Comment on lines 434 to 407
y1 = _chord1->stemPosBeam().y() - firstChordStaffY + _chord1->defaultStemLength();
y2 = _chord2->stemPosBeam().y() - firstChordStaffY + _chord2->defaultStemLength();
const std::array<double, 2> extendedLen
= extendedStemLenWithTwoNoteTremolo(this, spatium(), _chord1->defaultStemLength(), _chord2->defaultStemLength());
y1 = _chord1->stemPos().y() - firstChordStaffY + extendedLen[0];
y2 = _chord2->stemPos().y() - firstChordStaffY + extendedLen[1];
Copy link
Contributor Author

@Harmoniker1 Harmoniker1 Jan 26, 2020

Choose a reason for hiding this comment

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

In case anyone is wondering, regarding the stemPosBeam() to stemPos() change: this is intended. We're actually getting the y coordinate of stem tip here by calculating stem position (which is where it's attached to a note) and stem length. stemPosBeam() gives the position of the nearest note to beam, whereas stemPos() gives the real start position of the stem (the position of the furthest note to beam). So stemPosBeam() is actually a bad mistake.

EDIT: In the PR description there's an example (tremolo in the third measure) of how this affects layout.

@Harmoniker1 Harmoniker1 force-pushed the tremolo-layout branch 4 times, most recently from 9b948ee to acd5da0 Compare January 27, 2020 06:00
@worldwideweary
Copy link
Contributor

worldwideweary commented Jan 28, 2020

Hey Howard, looks way better.
Additionally, have you looked into the cross-staffing between tremolos? Maybe in the future you could fix that up (not trying to push my luck of course). For example, as it is currently:

cross-staff unmeasured-trem

The note on the right belongs to the (not shown) staff below through cross-staffing.

A screen capture of what is "supposed to be correct" is included here:

unmeasured trem

The dotted lines are apparently to provide a visual aid as to how the placement should be considered. I figured since you seem to have a grip on what's going on, maybe you can check it out or something :)

Anyways, thanks again for this PR.

@Harmoniker1 Harmoniker1 force-pushed the tremolo-layout branch 2 times, most recently from b1c8e59 to 6018579 Compare January 29, 2020 13:46
@Harmoniker1
Copy link
Contributor Author

Harmoniker1 commented Jan 29, 2020

@worldwideweary I'm working on it, but there're some problems I cannot get rid of very soon. I posted a question in the developers' chat and haven't get any answer yet.

// if there is a two-note tremolo attached, and it is too steep,
// extend stem of one of the chords (if not cross-staff)
// or extend both stems (if cross-staff)
// this should be done after the stem lengths of two notes are both calculated
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the problem you are having is that there is no way stem lengths can be known this early for the cross staff case, at least not if beams are involved. Probably not for the cross-measure case either. This is only finalized later.

While it might be possible to resolve these issues with some work, to me it would be acceptable to not do any such adjustment for cross-staff or cross-measure cases,and just let users contonue to need to adjust these manually. not sure how easy it is to detect cross-measure at this point though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aside: One of the issues of leaving customization of tremolos between notes up to the user is that the user can't adjust the "grow left/right" (cf. feather beams terminology) related to the tremolos (or maybe they can and I'm missing something). Although the placement algorithm works well enough for most use cases, maybe it would be appropriate to have inspector attributes for changing the angles of note tremolos for some "off cases", ... but that's another story.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarcSabatella Manual adjustment can work for minim cross-staff tremolo and shorter, because you can adjust stem lengths. But for semibreve and longer there's no way of manual adjustment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Plus, there aren't any grips ("adjustment handles") for the tremolo strokes themselves. Inspector attributes are nice, but it's nicer to have grips ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

True, I mixed up one and two note tremolos in my head here. Anyhow, I assume it's still the case that this isn't going to work here, you'd need to do this at the point where the stem length is actually calculated during cross-staff layout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stem lengths are correct now, it's stemPos() (or stem()->pagePos()) that's wrong. But thanks for replying!

Copy link
Contributor

Choose a reason for hiding this comment

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

Stem directions also are not known for sure until cross staff processing, and thus, stem positions too.

@Harmoniker1 Harmoniker1 force-pushed the tremolo-layout branch 2 times, most recently from 8c16ad2 to 42820ca Compare February 22, 2020 06:12
libmscore/chord.cpp Outdated Show resolved Hide resolved
libmscore/layout.cpp Outdated Show resolved Hide resolved
libmscore/chord.cpp Outdated Show resolved Hide resolved
libmscore/layout.cpp Outdated Show resolved Hide resolved
libmscore/layout.cpp Outdated Show resolved Hide resolved
libmscore/tremolo.cpp Outdated Show resolved Hide resolved
t = up ? -3.0 - (2.0 * (lines() - 1)) * td - 2.0 * sw : 3.0;
}
else {
if (!up && !(line & 1)) // stem is down; even line
Copy link
Contributor

Choose a reason for hiding this comment

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

indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intend to align the conditionals, in this way it's clearer.

fix musescore#20390: tremolo through stem collide with ledger lines
…ng it in a Chord member function

+ provide a commented-out part of adjusting stem lengths for cross-staff two-note tremolos that currently isn't working in some cases
…Between() (+ collect_artifacts)

The case of two chords having the same `up()` value is already taken care of in the usage of `extendedStemLenWithTwoNoteTremolo()`.
+ fix one bug regarding `_spatium` not considerated
@igorkorsukov
Copy link
Contributor

@Howard-C vtests failed

@Harmoniker1
Copy link
Contributor Author

@Howard-C vtests failed

Yes, @AntonioBL told me failure just indicates some generated images were different from previous commits. It doesn't necessarily mean something went wrong. In this case, tremolo-1.png and grace-4.png are different, which is expected. You can download the artifact as suggested in https://github.com/musescore/MuseScore/pull/5619/checks?check_run_id=585441612 and see for yourself, nothing "failed".

@anatoly-os anatoly-os merged commit a59f72e into musescore:master Apr 14, 2020
@anatoly-os anatoly-os moved this from To do to Done in MuseScore 3.5 Alpha Apr 14, 2020
@Harmoniker1 Harmoniker1 deleted the tremolo-layout branch April 14, 2020 13:40
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented Apr 20, 2020

Not good for tremolos on grace notes.
Before (bad):
grace-4-ref
After (too long stem, too big tremolo strokes):
grace-4-1
Came up in #5449
It should be smaller and thicker tremolo strokes, matching the smaller notes. A grace note tremolo should look like a normal tremolo, just smaller.

@Harmoniker1
Copy link
Contributor Author

Behind Bars doesn't specify this, probably because the chance of adding tremolos to grace notes is too rare. But you're probably right.

@Jojo-Schmitz
Copy link
Contributor

Same for small notes, so probably should get fixed in the same go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants