Assigning a new note head to a note
I'd like to write something like
note.headGroup = HEAD_FA;
but despite the "note" documentation saying that headGroup is a Ms::NoteHead::Group with a list of possible values that includes "HEAD_FA", this doesn't seem to work ("ReferenceeError: HEAD_FA is not defined"). I have to assume that HEAD_FA, HEAD_SOL, etc., are constants that are local to some class, but I cannot figure out how to name that class in my code. (I confess, I've never written in this language before.)
Can someone tell me what I should be writing to change a note-head in this rather simple way?
Comments
Well, in the soruce to MuseScore itself, those are NoteHead::Group::HEAD_FA, etc. So Hopefully some syntax like that will work in plugins (I haven't experimented with the 2.0 plugin framework yet, so I don't really know).
In reply to Well, in the soruce to by Marc Sabatella
I've tried a bunch of those. It turns out that the moment I put a "::" in there, I get a parsing error (Line 92: expected token ';'). I also tried
note.headGroup = NoteHead.Group.HEAD_FA;
in hopes that maybe dot syntax would help...but got
92:-1: ReferenceError: NoteHead is not defined
and with
note.headGroup = Ms.NoteHead.Group.HEAD_FA;
I got
92:-1: ReferenceError: Ms is not defined
So I clearly need more help. I even tried assigning it random small integer constants (which works in C++, for instance)
note.headGroup = 4;
but that gave
92:-1: Error: Cannot assign int to Ms::NoteHead::Group
I clearly need more expert help here. :(
In reply to I've tried a bunch of those. by spike7638
Does any of these help?
https://www.google.com/?gws_rd=ssl#q=enum+Qt+qml
In reply to Does any of these by Jojo-Schmitz
Alas, no. It might help an expert in Qt and Ms, but to me, it's mostly gibberish. It appears that something needs to register some class as visible from qml, and that I then need to use the right "dotted path" to get to and enum in that now-registered thing. But the documentation for MS doesn't really disclose whether this "exposure" has been done, or what dotted path I'd use, and if it turns out that to effectively use scripting, I have to read the MS source, then I'm gonna give up and stick with 1.3 instead.
In reply to Alas, no. It might help an by spike7638
I gather from other thread that you are trying to create a shape notes plugin for 2.0.
Starting with f59e1af5d7 it should work to call
note.headGroup = NoteHead.HEAD_XCIRCLE;
In reply to I gather from other thread by [DELETED] 5
Thanks. I tried that one before, but just in case, I tried it again:
note.headGroup = NoteHead.HEAD_XCIRCLE;
produced
95:-1: ReferenceError: NoteHead is not defined
Perhaps I'm failing to include some ".h" file (or the equivalent). I just started from colornotes and began editing.
In reply to Thanks. I tried that one by spike7638
You need a more recent version of MuseScore. I just added some code to make this work.
Also I'm not sure you need access to NoteHead.HEAD_XCIRCLE to make it work.
Something like this in the current master branch. I don't have a UI for it, but if anyone wants to try to make a QML version of the UI, please make a PR here https://github.com/lasconic/shape_notes
function shapeNotes(note) {
var tpcNames = "FCGDAEB"
var name = tpcNames[(note.tpc + 1) % 7]
var names = "CDEFGAB"
var curKey = curScore.keysig;
var scale = scales[curKey+7];
var degrees =[9, 12, 10, 9, 12, 10, 4]; // 4 notes
//var degrees = [0, 0, 0, 0, 0, 0, 0];
//var degrees = [7, 8, 4, 9, 12, 10, 11]; // 7 notes
note.headGroup = degrees[(names.indexOf(name) - names.indexOf(scale) +28)%7];
}
In reply to You need a more recent by [DELETED] 5
For an example on how a GUI might work, check https://github.com/Jojo-Schmitz/batch_export/blob/master/batch_convert…, the GUI is there (and once worked, haven't checked in a while) the logic is still missing though.
In reply to You need a more recent by [DELETED] 5
That's the very code I was planning to port, which I'm pretty sure I can do...but I wanted to start out easy by assigning a single note head shape to every note so that I could be sure it worked. It didn't. :(
Mimicking the code above OUGHT to work..but assigning an integer to a headGroup (as you do in the last line) generates an error (as well it might, in any reasonable language).
What I DON'T know is how to get a more recent version of MS ... I downloaded this one just yesterday. Do I need to use Github and compile it myself, etc? Or is there some easy way to get the results of your latest build?
In reply to That's the very code I was by spike7638
You'd get the most recent versions from http://musescore.org/en/download#Nightly-versions
In reply to You'd get the most recent by Jojo-Schmitz
Thanks. I'm on my way. I've got diamond-shaped notes now. Soon, world domination. :)
In reply to You need a more recent by [DELETED] 5
I've taken this, combined it with colornotes, and created a nice working shapenotes plugin (for the 4-note system; I could make another for the 7-note system, I'm sure. But I cannot make a UI with the current framework, and don't want to try).
I'd be happy to have someone who understands GitHub and other such things include it into the distribution. I've attached it here in case no one wants to do the inclusion, but someone else wants to use it someday. (You just drop it in the plugins folder.)
In reply to I've taken this, combined it by spike7638
I updated the plugin with a UI http://musescore.org/en/project/shapenotes
In reply to I updated the plugin with a by [DELETED] 5
You may want to explicitly mention it does support 2.0...