Plugin coding tutorial?

• Nov 23, 2016 - 23:49

Is there any tutorial for how to create a musescore2 plugin?

Am I to understand that for the most part we an do whatever is possible with QT QML, and then the musescore specific API gets us access to data objects in the score?

What are the basic requirements of a MS2 plugin within the wider QML capability...?


Comments

In reply to by Jojo-Schmitz

As far as I can see, there is only one plug-in on the page https://musescore.org/plugins that is compatible with the 2.0 version, and written in qml.

I found a few other examples by right clicking (on Mac), and spelunking into the distribution folder for MuseScore 2.0 itself, namely, these:

pconrad$ pwd
/Applications/MuseScore 2.app/Contents/Resources/plugins
pconrad$ ls
abc_import.qml	helloqml	random.qml	scorelist.qml
colornotes.qml	notenames.qml	random2.qml	view.qml
createscore.qml	panel.qml	run.qml		walk.qml
pconrad$ 

I'm currently trying to dive into the QML learning curve, because I really need plugins for inversion and retrograde.

I'm doing some composition where I want to take a few recognizable snippets of melody and invert them and reverse them (retrograde). I envision that this would be done in a separate score with a single melodic line, and then the transformed melodic material would be copied/pasted into a larger composition.

There are some older MuseScore 1.x js-based plugins that do this in a rudimentary fashion. For a while, I was trying to work by having an old version of MuseScore 1.3 around, and moving material between the new and old versions by exporting to MusicXML---but it was getting too painful, so I tried to take the plunge into QML plugin development.

It seems that not many folks have taken that plunge, and it may have to do with the fact that it seems there are not many tutorial resources available.

If anyone else is trying this journey in late 2016 early 2017, I would welcome some fellow travelers.

In reply to by pconrad

I wonder if any of the plugin developers have managed to find this old thread, and recreate the ability to refer to external javascript files in order to factor out common functions.

https://musescore.org/en/node/17581

It would be super nice to be able to develop some pure Javascript "helper functions", unit test those separately, and then import those tested, tried and true functions into other plugins in order to keep the plugins nice and tidy, instead of monolothic huge files containing lots of copy/pasted code from other plugins.

It seems that the designers of QML anticipated this need and allowed for this possibility in their design of QML, and that on a particular August night back in 2012, "theGleep" got it to work.

But I've been unsuccessful in that attempt.

In reply to by pconrad

If you really need inversion and retrograde and can cope with C++ a bit, I would advise to implement these in the core of MuseScore and not as a plugin. There are many things that will be hard or impossible to do with a plugin (for example creating a tuplet...).
I'm happy to help you dive in the core, here on the forum or on IRC #musescore on freenode.net.

In reply to by [DELETED] 5

What about something like doing a "diff" of corresponding ranges of measures in two scores, to see what notes (if any) have been changed? Or doing a search for a particular sequence of intervals between successive notes, e.g. to find occurrences of a thematic figure which may have been transposed and/or changed in rhythm? Some utilities like these for MS score files would be a very useful set of tools. I would be interested in doing some of this, but at the moment I'm still working up the guts to "dive in" by getting a copy of the source code and finding my way around in it. That was one reason for my interest in what can be done with plugins.

In reply to by dhfx

doing a search for a particular sequence of intervals between successive notes, e.g. to find occurrences of a thematic figure which may have been transposed and/or changed in rhythm?

This one could be done with a plugin. It only involves going through the notes and search for a pattern, and then report the results (coloring the notes?)

doing a "diff" of corresponding ranges of measures in two scores, to see what notes (if any) have been changed
This one sounds harder to do in a plugin and you will have to carefully describe what you expect the diff to do.

I am still going through the learning curve, although not all of the structures are available to the plugin framework there is a lot of information here https://musescore.org/en/developers-handbook, you can see what is available from the documentation in the Plugin Creator. And for the QML environment, information is here: http://doc.qt.io/qt-5/qtquick-index.html.

I would also suggest that you use something like notepad++ to edit your code in tandem with the plugin creator, you can use the refresh button in the plugin creator to sync the two to run it.

It should be possible to use the Qt Creator to edit code and have it's full help and auto complete available, but I haven't yet spent the time to work out how to import the musescore libraries.

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