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

Inability to place the cursor on some beats upon clicking #959

Closed
1 task done
mxAlexG opened this issue Aug 28, 2022 · 1 comment · Fixed by #960
Closed
1 task done

Inability to place the cursor on some beats upon clicking #959

mxAlexG opened this issue Aug 28, 2022 · 1 comment · Fixed by #960
Assignees
Labels
area-rendering Everything related to the rendering platform-all Affects all platforms state-accepted This is a valid topic to work on. type-bug 🕷️

Comments

@mxAlexG
Copy link

mxAlexG commented Aug 28, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

This behavior occurs regardless of which voice the note/beat clicked falls under. Another observation is that they are notes belonging to the first staff (index 0). Only encountered with grand staff tracks- MusicXML format.

I used the same file I provided with issue #949 (here) and from this:
https://musescore.com/user/13955466/scores/5244260

I provided screenshots (from file in issue #949) for better reference :
image
image
image
image
image
image
image

Expected Behavior

The ability to place the cursor on any note.

Steps To Reproduce

  1. Hold the mouse with your hand
  2. Move the mouse cursor over every note
  3. Tap on the currently hovered over note
  4. Repeat until you encounter instances where the cursor doesn't get positioned on a beat

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.2

Platform

Web

Environment

- **Ubuntu**:
- **Brave Browser**:

Anything else?

No response

@mxAlexG mxAlexG added the state-needs-triage Bug not triaged yet. label Aug 28, 2022
@Danielku15 Danielku15 added type-bug 🕷️ area-rendering Everything related to the rendering state-accepted This is a valid topic to work on. platform-all Affects all platforms and removed state-needs-triage Bug not triaged yet. labels Aug 28, 2022
@Danielku15
Copy link
Member

Danielku15 commented Aug 28, 2022

For the normal notes it is indeed a bug. Seems like some consolidation logic which used to be there got lost. A temporary workaround:

api.postRenderFinished.on(_ => {
    const lookup = api.renderer.boundsLookup;
    lookup.finish();
    for (const staveGroup of lookup.staveGroups) {
        for (const masterBar of staveGroup.bars) {
            for (const bar of masterBar.bars) {
                bar.beats.sort((a, b) => a.realBounds.x - b.realBounds.x);
            }
        }
    }
});

The grace notes selection is by design: Those are "before beat" grace notes at the start of a bar. That means they are effectively played even before the bar 21 starts as part of the previous bar.

Grace Beats are a nightmare in music notation because they are not aligned correctly according to their actual time they are played, but they visually "stick" to the next beat and "steal" their duration from the previous or nest beat:

  • There are "on-beat" grace notes which start when normally the beat afterwards would start and the normal beat is shortened by the grace notes in front of it stealing part of the duration.
  • Secondly there are "before-beat" grace notes, which are stealing their duration from the previous beat which is shortened. So if they are in the start of a bar, they are actually played within the previous bar.

So when you click on those notes visually, alphaTab will seek to this bar and the first beat played within this bar. And this is after the grace notes.

This makes mismatch in visual placement and audio playback make it close to impossible to handle it correctly. When clicking on your mentioned examples, the cursor would actually need to be placed somewhere into the previous bar close to the end to be visually correctly placed at the time they are played. You either need to choose between seeking the playback and cursor the the place where the notes are played, or you seek to the place where they are visually located and then take the time from this visual location.

AlphaTab follows the latter. It takes the visual position the user clicked, takes the "time" from there and places the cursor / playback accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-rendering Everything related to the rendering platform-all Affects all platforms state-accepted This is a valid topic to work on. type-bug 🕷️
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants