MuseScore Object Model
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).
Comments
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 I wonder if and when that… 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 First of all, thank you for… by luizcrodrigues
Hi Luiz, welcome to the sometimes frustrating but often rewarding world of MuseScore plugin design. Segments have their own documentation in the Plugin Creator, but it may also help to read this:
https://musescore.org/en/developers-handbook/references/musescore-inter…
In reply to Hi Luiz, welcome to the… by PaulSC
Thank you Paul, lots of precious information in the link you provided. And well written, too. It's already included in my favourites. I'm avidly reading through it and I'll post here any doubts that might (will) come up.
In reply to Thank you Paul, lots of… by luizcrodrigues
Just a note (and thanks for the compliment :-) - that document is a bit old, much has changed since it was written. but not, I think, much that would actually be relevant. That is, the stuff that has changed is things not covered there.
In reply to Just a note (and thanks for… 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 Yes, I noticed it. I'm going… by luizcrodrigues
That would be most welcome. Thanks in advance for wanting to contribute your time on this!
In reply to Hi Luiz, welcome to the… 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).
In reply to I wish the information were… by mirabilos
You can look in your computer's MuseScore directory for manual > plugins, a folder with many small files like "accidental.html", "ambitus.html", ... These seem to be how the Plugin Creator's Help browser is built.
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.
In reply to The developer's handbook… by luizcrodrigues
In time: the above statement about segment was obtained from:
https://musescore.org/en/developers-handbook/references/musescore-inter… - 3rd. paragraph
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.
In reply to Annotations are available… 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...
In reply to Nor are other ornaments like… by luizcrodrigues
Most articulations are not annotations on segments but rather on chords or rests.
In reply to Nor are other ornaments like… by luizcrodrigues
Indeed, as mentioned many times, the plugin interface is quite limited currently. Efforts are scheduled to improve this for/during MuseScore 3.
Copy and paste however might very well be possible using the
cmd("_sc_id_string")
interface; just as I mentioned here earlier today: https://musescore.org/en/node/64031#comment-877460In reply to Nor are other ornaments like… by luizcrodrigues
And indeed as Marc mentioned, you could dive deeper into
Chord
elements to detect graceNotes/lyrics/notes. Then into theNote
you can analyse the elements property (an array) for note-attached things.My quickly thrown together example plugin needs some expanding ;)