Multi-voice grace notes not aligned

• Aug 13, 2014 - 01:26
Priority
P2 - Medium
Type
Functional
Severity
S4 - Minor
Status
active
Regression
No
Workaround
No
Project

1. Open attached score (produced in 2.0).

Result: The multi-voice grace notes don't align vertically (for adjacent notes specifically: not positioned correctly).

Multi-voice grace notes not aligned.png

Note: These are grace before and after for each normal note.

Using MuseScore 2.0 Nightly Build (e176e25) - Mac 10.7.5.


Comments

What has set your expectation for the how the grace notes should align? The current algorithm produces an odd artifact where downstem grace notes are too close to their "parent" note, and I will plan to fix this. But overall, this is another one of those situations where the "correct" behavior is highly subjective and very dependent on the specific context.

FYI, what the algorithm does is treat each voice's grace notes separately, laying them out as if the other voices didn't exist at all. This might not be the right thing for all situations, but it's right for some, and it would be a nice consistent starting point for adjustment - *if* it didn't place downstem grace notes too close to the main note. It's not actually about multiple voices per se - even a single grace note on a single note in a single voice is laid out too close if you flip its stem down. That much should be a simple fix.

EDIT: actually, it's working as designed. The amount of space between the grace note and the main note - from the right edge of the grace note to the left edge of the main note - is the same for both upstem and downstem grace notes. It's an optical illusion that the upstem notes are further away. The difference is that on the upstem grace notes, the flag is to the right of the notehead, and on the downstem grace notes, the flag overlaps the note. The question, is it worth artificially moving downstem grace notes further away than necessary, just to get them to align with upstem ones? I guess so, but I'm kind of ambivalent.

Yes, it did cross my mind as to whether grace notes should align like normal notes (e.g. partly because they occur at the same time), or be independent. I was originally going to post this in the Technology Preview section.

For the original example, I don't see why they shouldn't align. Do you have examples?

However, as you more-or-less say, there could be instances in which there is disagreement.

The accidental wouldn't allow the grace note closer to the notehead it precedes:

Alignment.png

When it does:

Non-alignment.png

The attached mscz were produced in 1.3.

Attachment Size
Alignment.mscz 1.82 KB
Alignment.png 300.8 KB
Non-alignment.mscz 1.7 KB
Non-alignment.png 93.02 KB

I don't have real world examples where they do or don't because this is case is extremely rare in my world. Probably not quite as rare for rock guitar transcriptions as other types of music. And I can see they align in the Gould examples, though.

Anyhow, the algorithm currently works by ensuring the same amount of space between the right edge of the grace note and left edge of the grace note. This means you get three potentially different placements for the gracenote, depending on whether it is upstem with flag, downstem with flag, or beamed, since these three cases all have different widths.

Because there is no way for the grace note layout algorithm currently to know about grace notes in other voices, the only solution I can see that would align the grace notes is to place both beamed and downstem flagged grace notes as far away from the main note as upstem flagged grace notes. This really would look pretty bad in most cases though - cases where there are not grace notes in both voices. And in any case, it still won't produce the alignment in cases the main notes themselves don't align (either because of seconds or overlap between voices or because of accidentals). So it would really just be a kludge that only sometimes worked but often produced worse results.

I'm kind of inclined to try a partial kludge that will work "sometimes" and might look better overall, and that's to leave beamed grace notes alone - so they won't ever align with flagged ones - but go ahead and force downstem grace notes a little further away, so if the main notes do happen to align, a single grace note will align with a single grace note, and beamed grace notes will still align (as they do now) with other beamed grace notes.

If that doesn't end up working well, though, I'll just mark this postponed so it can be considered for some day if/when the layout engine is ever completely revamped in a way that allows elements to be more aware of other elements.

In reply to by Marc Sabatella

Severity S1 - Blocker
Reported version 2.1  
Regression No
Workaround No

I just came up against this one and searched to see if the issue had already been raised. It had.

You said (a long time ago ...) "I can see they align in the Gould examples" and later " the algorithm currently works by ensuring the same amount of space between the right edge of the grace note and left edge of the grace note. This means you get three potentially different placements for the gracenote, depending on whether it is upstem with flag, downstem with flag, or beamed, since these three cases all have different widths.

Because there is no way for the grace note layout algorithm currently to know about grace notes in other voices, the only solution I can see that would align the grace notes is to place both beamed and downstem flagged grace notes as far away from the main note as upstem flagged grace notes. This really would look pretty bad in most cases though - cases where there are not grace notes in both voices. And in any case, it still won't produce the alignment in cases the main notes themselves don't align (either because of seconds or overlap between voices or because of accidentals). So it would really just be a kludge that only sometimes worked but often produced worse results."

Gould also says (page 126 in my copy) "Grace notes take up-stems, regardless of their position on the stave. An exception to this is where there are two parts on one stave, in which case the lower part takes the down-stems".

Following Gould's guidance cuts down the number of cases that need to be considered. The default position for grace notes should be what you suggest is the "only solution" - i.e place the down-stem grace notes as far away from the main note as up-stem grace notes. Having down-stem grace notes in other situations is non-standard, and MS can not know what non-standard spacing the user might want to see.

Severity S1 - Blocker S4 - Minor
Frequency Many
Reproducibility Always

I agree this is an annoying bug, but it's far from a blocker. There are simple workarounds. Click the grace note and adjust the offset for the notes you don't like. I would like to see grace notes all align on their heads (except to avoid collisions) rather than their stems as is the current case.

Frequency Many  
Reproducibility Always  
Priority P2 - Medium

In case it isn't clear - we already do put grace notes stem down in the right places. The only question is distance to main note. As I said above, it actually is the same for upstem and downstem, if you measure the actual gap (right edge of grace note to left edge of main note - typo in my original comment). It's the different widths of the grace notes that produces the illusion of inconsistent distances, and the reality of different start points. So instead of shooting for the same distance, we should be shooting for the same start point (left edge) in these cases. But as I said, that won't be ideal in the cases where there aren't grace notes in other voices, as the downstem grace notes will be noticeably too far away. We'd want to only do this where necessary, and right now that info isn't readily available. Not that the information can't be determined, but it would be a bit hacky to get at it.

In your picture you can see that the noteheads for the main note aligns. This is more natural looking and is what I expect.

Yes when alignment is the goal, that's what we'd obviously like. But if there is no voice 1 note to align with, placing the voice 2 note here would be too far away. That's what I've been trying to explain - we don't want to always place the voice grace notes this far away, only if there is also a voice 1 grace note. And currently there is no non-hacky way to know if that's the case. Maybe we need to resort to hacks, or maybe the algorithms need to be revisited more fundamentally.

Yes, that is clearer now.

I have tried to reproduce the Gould example (see attached ) and I see now that this is a non-trivial problem to even analyse, let alone solve.

Before I started I thought that if I moved the first down-stem grace note to align the note heads, I could apply the same offset to all the other down-stem grace notes and Robert would be my mother's brother. However, the first thing I found was that the two grace notes on the third beat did look as though the note heads were aligned when they were first entered. Unfortunately the second pair shouldn't be aligned as they are an interval of an augmented second apart in the Gould example and when at the correct pitch they collided before I adjusted the offset. I started as I said, by moving the first down-stem grace note (D natural) to appear aligned with the first up-stem grace note (B natural) by giving it an x offset of -0.75. Then I gave the the C natural grace note on the fourth beat the same x offset of -0.75. I had to give the D# an offset of -1.25 to avoid the collision with the C natural and then the accidental was colliding with the up-stem of the A natural. I gave the A natural an offset of -1.5 as it looked about right and avoided the collision with the accidental. Then the down-stem A natural had to be adjusted to align with its up-stem partner. It needed an offset of -1.6.

Bar 1 done! On to Bar 2.

I gave the first down-stem grace note (G natural) an offset of -0.75. It looked too far away from the main note, as you said it would. -0.25 looked about right. But the main note F natural with its grace note looked too near the upper voice C natural, so I added a leading space of 1.3. I gave the E natural grace note an offset of -0.25 and again it looked too near the preceding main F natural and so I added a leading space of 0.8.

It probably IS possible to find an algorithm that would produce nice results but it is certainly beyond my capabilities.

In conclusion, I suggest this one is replaced on the back burner until someone gets inspired.