MuseScore Object Model

• Nov 27, 2018 - 00:44

It is really difficult to try and find out about all the objects of MuseScore, its properties and methods, by just looking into the plugin examples. I see things like startStaff, endStaff, cursor.staffIdx, cursor.tick and several other expressions, including method names which are not clearly described in the plugin manual within the help in the plugin creator. There should be a formal, complete description for all objects, properties, methods and events comprised by the MuseScore object model. I wonder if and when that will come to be, as much as I wonder which elements of the object model are NOT present in the examples. Sorry for the desperate tone, but that's how I'm feeling after a few days of searching and trying (with far more misses that hits).


I wonder if and when that will come to be,
Yes, it will come to be; when some volunteer finds the time to work on it (feel free to convince my employer to let you hire me for a week or 2 to work on this ;-) )

as much as I wonder which elements of the object model are NOT present in the examples
Quite a few aren't in an example plugin. But AFAIK they are all listed in the reference manual included in the plugin creator. To be able to work with it, a good understanding of both MuseScore and qml/javascript is advised (especially the latter).
The only "big" thing I'm aware of not being documented at all is the list of possible arguments you can pass into the cmd() call; as it depends on the action name of the shortcut in the real sourcecode, which wasn't as straightforward to quickly include in the parser that builds the reference documentation.

startStaff and endStaff are probably local variables to the script
The cursor properties are documented in the plugin creator included reference listing under "Cursor"

If you have a specific question/goal about plugin development, do not hesitate to simply ask for it here. It just might happen that someone like me can figure out a way to either achieve what you want (or point you in the right direction). Or we might at least be able to tell you that what you're looking for is currently not supported/achievable through the limited plugin API before you get all frustrated with it.

In reply to by jeetee

First of all, thank you for the content-rich reply. I myself, could gladly start to work on that (or at least try), for I have the time to spare and I enjoy doing it. Now, when you say that AFAYK all MuseScore model members are included in the help of the plugin creator, that still leaves room (tiny, I might suppose) for some that wouldn't be. In that case, who am I to assume such a task when not all information is there to start with. You see, this is part of my problem, not being sure that if a specific member that I might need (or think of), be it a property, a method or an event, is not in the help, that definitely means it does NOT exist it the object model. Other than that, I can patiently go through all the qml examples and learn a lot from there. In fact i'm doing that now. In fact I'm also learning a great deal from the Qt Documentation site.

BTW, you're absolutely right, startStaff and endStaff are indeed local variables in the program. In my frustration mode, I hadn't noticed it.

Anyway, I am positively convinced that MuseScore is such a great musical application, resulting from an excellent team work. I've tried quite a few others an I know what I'm saying. My score creation efficiency has increased enough to make me not try any further. I'll just stick to MuseScore. Regardless of the effort I might have to throw in, to reasonably master its object model. Time will tell...

While I'm still here, I would like to ask for the meaning of one term I'm not sure I understood correctly:
segment - it seems to me that segment defines a portion of the score that is currently selected (?)

Thank you again for the nice reply.

In reply to by Marc Sabatella

Yes, I noticed it. I'm going through the document and I just found a few things which are not "exactly" as shown in the document, but I managed to discover how those things really (presently) are. I'll continue studying the object model from this and other documents I can find. As soon as I acquire a more concrete understanding of the model I'll start to contribute to its documentation. All through extensive testing, so that my contributions remain solid.

In reply to by PaulSC

I wish the information were also available outside of this plugin creator. I’m much more comfortable with my regular text editor in an xterm, and having documentation available separately, ideally in some text format (or lynx-compatible HTML).

Also, 3.0 plugins are in a state of flux, a lot is still not working with them and up for change. Unfortunately, there does not seem to be a way to at least autogenerate documentation of all objects, their hierarchy, and the methods and attributes they have (with the semantics being in the hand-written documentation, having this as an addon so one knows whether something exists or how it could be named might be useful).

Accessing ornaments through JavaScript:
Is there a way to access elements like a glissando, an arpeggio and other ornaments using JavaScript and the objects from the MuseScore Object Model? I've been trying this for a few days now, with no success. I've tried many different combinations based on what I can derive from the objects info in the Help included in the plugin creator and other doc sources. I would like to see a qml script with an example of such manipulation. In the mean time, I'll go on trying.

The developer's handbook says:
A segment can also contain annotations – markings like staff text, chord symbols, dynamics, etc.

Are these "annotations" accessible through the plugin API? If so, how?
Thanks for any help on that.

Annotations are available. Glissandi/Slur/SegmentLines however are not.

Run the attached example plugin I've just thrown together over a score to get more information on what can be detected.

Attachment Size
walk-friendly-names.qml 3.7 KB

In reply to by jeetee

Nor are other ornaments like arpeggio, fermata, etc! That blows my intention of building up a "linked copy" plugin. If I can't get ALL the elements in a measure - not just the notes and rests, to insert them somewhere else in the staff, I can't write my plugin. That functionality - copy everything, however, is definitely available in MuseScore, because I can copy a complete measure, with everything in it and insert it somewhere else in the score! It's just not available as an API function to be used in plugins... too bad. But that's the breaks... who knows in the (near) future...

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