playEvent lengths in MuseScore 4 scores are always 1000

• Jun 10, 2024 - 03:36

Hello,
A few years ago I wrote an Arduino library with corresponding MuseScore 3 plugin for encoding sheet music in a space-efficient form that can be replayed by a microcontroller. I'm finally getting around to making the plugin work with MuseScore 4 and have hit a bit of a snag with playEvents.

The output from the microcontroller is typically a square wave of the note's frequency, with what fraction of each note that sound is generated being one of the few voicing / articulation options. The plugin currently uses playEvents to determine if the note should be played as staccato (50% of the time), slurred / legato (100% of the time) or normally (87.5% of the time).

In MuseScore 3 and scores created using MuseScore 3 that are opened in MuseScore 4, the playback events for each note have varying lengths. In documents created using MuseScore 4, all playEvents have length 1000 regardless of articulation / lines added.

As an example with the following bar, playEvents[0].len for each note is:
playEventsExample.png

Created with MS3: [ 950, 1000,  950,  500]
             MS4: [1000, 1000, 1000, 1000]

I've tried adding:

curScore.startCmd();
curScore.createPlayEvents();
curScore.endCmd();

This doesn't seem to make any noticeable difference. The plugin file itself with some debugging to print playevent lengths is here. I've been testing with MuseScore 3.6.2 (appimage) and MuseScore 4.3.1 (flatpak). I'm not sure if the difference in behavious between MuseScore 3 and 4 is intentional or not with the various changes to the voicing. Does anyone have any suggestions of things to look at please? Thanks.


Comments

If it's any help / use with reproducing and demonstrating what I'm experiencing, this file has a cut down version of the plugin that only shows the length of the play event for each note: NoteLengths.qml.

Do you still have an unanswered question? Please log in first to post your question.