infojunkie / musicxml-player

A TypeScript component that loads and plays MusicXML files in the browser using Web Audio and Web MIDI.
https://blog.karimratib.me/demos/musicxml/
GNU General Public License v3.0
34 stars 6 forks source link

Add better hit testing for beats #6

Open infojunkie opened 2 years ago

infojunkie commented 2 years ago

When the user touches the sheet, we want to position the cursor at the nearest beat.

Right now, we only detect direct hits on the notes SVG elements, but these take up a very small percentage of the surface of their beat, which is a rectangular slice of a staff or system of staves.

We need to compute these beat rectangles and store them for fast query, just like we do for measure timestamp maps.