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

Support jumps and repeats in Verovio MIDI converter #37

Open infojunkie opened 1 month ago

infojunkie commented 1 month ago

The core Verovio engine does not support jumps and repeats when converting MusicXML to MIDI.

In order to have our own VerovioConverter support jumps and repeats, the trivial solution is to unroll the score at the level of Player. However, this means that the score now shows unrolled, which is not ideal.

To keep the original jumps and repeats in Player, we need to fix both the MIDI generator and the timemap generator in VerovioConverter.

The MIDI generator can be already solved today by automatically unrolling the incoming MusicXML before feeding it to the core Verovio MIDI converter.

For the timemap generator, the unrolling approach would not work, because it would be out of sync with the Player display. The problem to be solved is to map an incoming timestamp from the unrolled MIDI to the original score. We don't have the benefit of our own musicxml-midi annotations in the MIDI stream, which allow to create the proper timemap. One invariant we can rely on is the measure's number attribute that gets duplicated during unrolling.

infojunkie commented 1 month ago

The unrolling transformation accepts a renumberMeasures param that loses the original measure numbers.

For a more reliable approach, we can use measure.id as per https://github.com/infojunkie/musicxml-midi/issues/46.