CoderLine/alphaTab

Grace note overlaps with the previous note

Reiji777 opened this issue · 3 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The grace note is unnecessarily overlapping with the previous note, though the bar still has room to display the notes properly.

I found a similar issue (#1094), but seems the bug persists after the fix.

Screenshot 2023-07-03 at 9 53 45 AM

Expected Behavior

The grace note shouldn't overlap with the previous note.

Steps To Reproduce

It can be reproduced by uploading the tab to the demo player on alphatab.net

Please find attached the example gp file for reference.
grace-note.gp.zip

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.3-alpha

Platform

Web

Environment

- **OS**: MacOS
- **Browser**: Chrome 114.0.5735.198
- **.net Version**:

Anything else?

No response

What exact version of alphaTab are you using? I cannot reproduce your shown example in either 1.2.3 (released) and 1.3.0-alpha.684.

1.2.3 (page layout) - tested on alphatab.net
image

1.2.3 (horizontal layout)
image

1.3.0-alpha.684 (page layout) - tested on next.alphatab.net
image

1.3.0-alpha.684 (horizontal layout)
image

I wrote a simple script to demonstrate the issue. I'm using the version alphatab@1.3.0-alpha.684

https://stackblitz.com/edit/web-platform-8bu4vd?file=index.html

The issue happens when the screen width is small (e.g. 300px, which is common for a mobile phone). For example, in the second line of the following screenshot, the grace note has overlapping issue; the third line doesn't have any display issue while having the same amount of notes.

Screenshot 2023-07-03 at 10 35 47 PM

When there's enough width, the overlapping issue won't occur.
Screenshot 2023-07-03 at 10 19 35 PM

This is the expected behavior. If there is simply not enough space for the notes to be placed, there must be overlaps. For each note a minimum size is calculated it requires. This size then influences the general spacing in the bar according to the time they are played (in a more-or less logarithmic scale). According to this notes are then placed. Grace notes are treated special: they are "sticking" to the next note following them.

There is always room for improvement (especially with grace notes) but I prefer not to touch this area currently unless it is really a misbehavior. In this case we could try adding a mechanism which would prefer a correct time position but rather avoid collisions. Not a straight forward thing.

For such small sizes I would recommend to switch to horizontal layouts or reduce the scale dynamically.