MuseScore 3.3: Plugin API Update

• Oct 31, 2019 - 12:33

A brief list of new features in plugins API in MuseScore 3.3:

  • Expose Align enumeration. Can be used to assign values to text alignment properties of elements (align, beginTextAlign etc., see Element type documentation).
  • Expose note play events:
    • Add PlayEvent type
    • Add Note.playEvents property. Play events can be read from this list. This is a writable list so events can also be appended with push() function and removed by clearing a list (n.playEvents = []). See list QML type documentation.
    • Add Chord.playEventType property which controls whether play events are generated automatically by MuseScore or fully controlled by a user (or a plugin). Usually this property is assigned automatically, assign it manually to PlayEventType.Auto to make play events be reset by MuseScore later.
  • Adding and removing elements:
  • Expose list of selected elements to plugins:
  • Restore some properties available in MuseScore 2 (and add some new ones):
  • Comparing variables:
    • Add ScoreElement.is() and Excerpt.is() functions. They allow to check whether different plugin objects correspond to the same internal MuseScore object which is not currently possible to determine correctly with == or === operators.
  • Notifying plugins of score changes:
    • [Experimental] Add onScoreStateChanged handler. Mostly useful for plugins that are supposed to be used interactively (like "dock" type plugins). See the documentation for usage example.

Comments

Glad to see plugin API evolving further, even adding some of the yet missing MuseScore 2 properties. Alas parts[].volume has not made its way into MuseScore 3 yet (see https://musescore.org/en/node/294183) :-(
This is (AFAIC) the last missing piece for me to be able to switch to (the highly appreciated) MuseScore 3 version...

Is there any way I can get the same results (meaning: setting volume for mp3 export separately per part)?

Thanks for all the effort all of you are putting into MuseScore!

In reply to by msmb

Thanks for your response!

The issue with exposing part volume is that a part can contain instrument changes anywhere in the middle of a score so exposing this property in a way that was used in MuseScore 2 would not really be complete and would not correspond to the way in which instruments and channels are manipulated in MuseScore code internally. Actually, looking briefly at MuseScore 2 code, it looks like setting a part volume from a plugin should also be incomplete as this would probably work incorrectly for instruments which use multiple MIDI channels (like violin for pizzicato and tremolo effects or some brass instruments for playing with a mute) and does not allow handling instrument changes. So exposing these properties probably requires exposing some parts of functionality of instruments data structures which is possible, of course, but still requires some effort.

As far as I know, there is no other way to set a part volume for mp3 export except for using a mixer manually (which is probably what you want to avoid here).

Still this functionality should probably return to MuseScore 3 plugins some day. Maybe you could also create a feature request in the issue tracker, then it would be easier to keep track of this issue.

In reply to by dmitrio95

Hi dmitrios95, thank you for your reply!

I'm using this feature to generate mp3 files as study files for our choir, so the "instruments" are voices only in this case (soprano, alto, ...). In my little plugin I loop over all voices, exporting a mp3 file for each voice, having the current voice set to 100% volume, the other dimmed to 50% volume. I could do this manually, but it is very time consuming when exporting an eight voices sheet, probably several time throughout the process, so I really would like to avoid that. Getting this feature back would be highly appreciated and actually the last missing piece for me to switch to MuseScore 3 - currently I'm still sticking to MuseScore 2 because of this.

I've created a feature request in the forum: https://musescore.org/en/node/294183

Any chance for example code for adding (a few) chords to a score? I tried what seemed most straightforward https://musescore.org/en/node/296447 but failed, and I could not find hints to it in the API documentation; I attempted to follow the logic on the C/C++ side, but I gave up. Thank you in advance. (If this functionality is currently missing on the C/C++ side, pointers on how to implement it are welcome.)

In reply to by HuBandiT

Sorry for being so late with the answer, but starting from version 3.3.4 Cursor type gained an ability to add notes to existing chords (see addToChord parameter in addNote function). That should make adding chords easier so something like this should work:

cursor.addNote(60);
cursor.addNote(64, /* addToChord */ true);
cursor.addNote(67, /* addToChord */ true);

In reply to by [DELETED] 1831606

Current means that it belongs to a segment where cursor currently is. It can be positioned using Cursor.next() or Cursor.prev(), or shifts itself when using Cursor.addNote(). Most of Cursor API in plugins actually reuses the implementation of note input in MuseScore so it should behave mostly the same as normal note input cursor.

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