Stream.noteElementFromScaledX() returns a note n from the stream whose leftmost x position (n.x) and rightmost x position (n.x + n.width) are within allowablePixels of the given x position. If no note falls within this range, we select the note whose leftmost and rightmost x positions are nearest to x.
Problem
It is possible for a note's rightmost x position to overlap with the next note's leftmost position. If n1 ends at 123 and n2 begins at 120, then an x value of 121 will return n2, but 122 will return n1!
Solution
The current PR fixes this issue by truncating note widths so that n1 never ends after n2 begins.
Background
Stream.noteElementFromScaledX()
returns a noten
from the stream whose leftmost x position (n.x
) and rightmost x position (n.x
+n.width
) are withinallowablePixels
of the given x position. If no note falls within this range, we select the note whose leftmost and rightmost x positions are nearest to x.Problem
It is possible for a note's rightmost x position to overlap with the next note's leftmost position. If
n1
ends at 123 andn2
begins at 120, then an x value of 121 will returnn2
, but 122 will returnn1
!Solution
The current PR fixes this issue by truncating note widths so that
n1
never ends aftern2
begins.