Writing my first plugin - coloring notes based on chord tones
I've just installed 4.0, and I want to write a plugin for jazz lead sheets that will color chord tones, based on the chord symbols in the score. For example, if the note is being played while a Bb7b9
is relevant, it would color Bb D F Ab C (say all green), with the others being black.
I see the code for colornotes, which tells me something. Can someone point me to info on how I would be a able to 1) tell for a given note, if there's a chord symbol over it, 2) given a chord symbol get the chord tones. Other than that, I'm all set :-)
The hard part may be to say what chord to use in some cases. For example if the first chord symbol in a measure starts on the second note, one could look forward to the first chord symbol in that measure, but OTOH it might be better to use the last chord symbol in the preceding measure. I suppose I'd just pick one, and people could always force the behaviour by changing the score.
Comments
Hi Rob
All the best for your first plugin. I too need a plugin but I dont know where to start.
I have read that it needs QML language. Do you need to build it using QML only ? Or you can use some other language also?
IT is not my field. So sorry for basic questions :P
Thanks in Advance
Regards ,
Aditya
In reply to Hi Rob All the best for your… by Aditya Pawar
QML 'language' is just javascript. Start by reading existing plugins in a plain text editor (https://musescore.org/en/plugins). Debugging is limited to console.log statement, which makes it all the more challenging. In MU4 there is even a plugin that debugs plugins!!
https://musescore.org/en/node/345973
In reply to QML 'language' is just… by elsewhere
Thanks ! I will check it out
In reply to Thanks ! I will check it out by Aditya Pawar
Forgot to mention that the New Retrograde plugin
https://musescore.org/en/project/new-retrograde
has elegant code that shows how to deal with most score elements.
In reply to QML 'language' is just… by elsewhere
Thanks! I'm looking at the ones that comes with the standard distribution and will do some experiments.
In reply to Hi Rob All the best for your… by Aditya Pawar
QML is a bit more than "just javascript", IMHO ;-)
Here are some really well done tutorials about QML. These are the ones I used when I started writing MuseScore plugins.
In reply to QML is a bit more than "just… by parkingb
Thanks, it's good to have a place to start! From a quick look it has some familiar constructs, and I assume MS has some "libraries" that give access to various components and data.
In reply to Thanks, it's good to have a… by Robt@aya.yale.edu
See https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
But the documentation is/was poor, and you often find better info by Googling "site: musescore.org your topic"
Re 1) tell for a given note, if there's a chord symbol over it.
segment.annotations see apidoc
Re 2) given a chord symbol get the chord tones.
Thanks to the heart warming community here, Chord symbol syntax contains a link to the musescore internal chord to note function src, which is not exposed as plugin api, and useful alternative plugins / libraries.
See the latest Chord ID and Roman numeral analysis where the marvelous Expand chord symbols into notes plugin by markshepherd is utilized.
The current plugin dev environment for musescore 4 is harsh, pls seePlugins for 4.x. You may want to write for musescore 3 instead, see Plugins for 3.x.
In reply to Re 1) tell for a given note,… by msfp
EDIT: This applies to MU3.6
But note that if you walk through the score using:
while(cursor.segment && cursor.tick < endTick) {
…
cursor.next();
you will not see chord symbols that have no note under them.
See also:
Adding a chord symbol from a plugin at a position where there is no note.
https://musescore.org/en/node/307565
To see all the chord symbols you need a separate walk and use:
var segment = curScore.firstSegment();
while (segment) {
…
segment = segment.next;
As in attached
FindAllChordSymbols.txt