Learning the language
Once in a while I try to write a script (plugin) in MuseScore 2, and I give up too soon. I have an idea to write a chord player, that plays the chords from above the upper staff. I may come into UI troubles later (like letting the user to decide if he wants block chords or arpeggios, etc.), but before I begin, I have to be sure that there is a way to play notes straight from the script.
I also want to be sure that I understand the Plugin Creator environment: As I understand, the main object is the MuseScore{} object, which includes many properties and methods (hardly documented), including the onRun event, and can use JavaScript functions.
I'd like to have confirmations or corrections.
Comments
1. There is currently no supported way in the scripting interface that allows playback interception/modification.
What you can do however, is have your plugin write the notes for the chords onto a staff.
2. Not that many methods/properties exist on the root object; you can find the (limited) documentation from within the plugin creator (Help → Manual). It contains a listing of all available objects and their methods/properties (including the MuseScore object).
3. The onRun event is the entry point for your plugin, which is executed when a user calls your plugin.
4. The plugins are written in QML; it is a JSON-like format and thus yes, allows for declaring your own javascript functions.
Improving the documentation around plugin development is one of my medium-level wishlist items for 3.0. Just today even, werner has commit some part of the code which should enable us to expose enumerations easier to the scripting interface.
In reply to 1. There is currently no by jeetee
Even before the official documentation for QML plugins is written, please can we have a brief introduction to the most important aspects of the QML format? In reality it's substantially different to both JSON and ECMAScript 2015, so I don't really have a clue where to start, other than painfully reverse-engineering existing examples.
In reply to Even before the official by adam.spiers
FWIW, I find the reverse-engineering to be reasonably effective. But if you want documentation on QML, see the Qt web site. Perhaps in particular things like http://doc.qt.io/qt-5/qml-tutorial.html
In reply to FWIW, I find the by Marc Sabatella
Ohhhh, QML is a generic Qt thing! I thought it was specific to MuseScore! OK, that's a huge help - thanks a lot! :-)