Note’s Elements structure
I am trying to read if a note has had articulations or tremolos add to it but cannot find it in the note object. I am guessing it is kept in the elements sub object, but I cannot figure out its structured to be able to read anything from it. Any help would be appreciated.
Comments
It should be a list/array of Elements, so I'd expect something like this to work out:
In reply to It should be a list/array of… by jeetee
Here you can find a good documentation of the Note class:
https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
Articulations and tremolos are not attached to Notes but to Chords.
To learn more about the structure of the elements as exposed by the plugin framework, sometimes the best way to learn is to examine the actual structure within the MuseScore source code. See libmscore/chord.h, also libmscore/chordrest.h (parent class of chord & rest) and libmscore/note.h for the definitions of these classes.
In reply to Articulations and tremolos… by Marc Sabatella
From what I can gather is that, yes it is part of the chord class but there are no hooks in place for the plugin to get to them.
The place to actually see what the plugin can read for note, chord and chord rest is in
plugins/api/elements.h
In reply to From what I can gather is… by dalekdarbuka
Can you get to the Chords elements ?
In reply to Can you get to the Chords… by parkingb
note.parent should give you that
In reply to Can you get to the Chords… by parkingb
In libmscore/chord.h the tremolo is defined in the same way as the stem, stem slash,etc.
You do not get to these items from the elements but by directly pulling them from the chord
chord.stem or chord.stemslash
This is because they have been define in the chord wrapper in the plugin api.
Tremolo and Articulations are not defined in the API so they are not searchable.
If I am wrong let me know, or else how can I put in a call for these to be added to the chord wrapper.
Pictures are a segment of libmscore/chord.h and plugin/api/elements.h
In reply to In libmscore/chord.h the… by dalekdarbuka
I don't find them neither.
I just dumped all the properties and elements of a note and its parents, and a tremolo and its parents. The parent of the tremolo is indeed the chord, but I don't find to any reference to it in the chord itself. The same applies for articulations.
Could another approach be working on the user's selection ? Or even selecting everything from the code (don't know if it is possible).
Because you can find the tremolo in the selection.
var selection = curScore.selection;
var el = selection.elements;
if (el.length==0) {
invalidSelectionDialog.open();
return;
}
// the tremolos are now among the el array.
In reply to I don't find them neither. I… by parkingb
That is where I was going. Basically finding the tremolos and articulations in the score and checking them to the chords to see which is the parent. The problem I am having is that I can only find it in the selection and as it is what I am doing does not use selections. I cannot even find an object of all elements in a score. I’ll keep looking and if anything will have to switch over to a selection style.
In reply to That is where I was going… by dalekdarbuka
Some basic code of mine:
var cursor = curScore.newCursor();
curScore.selection.selectRange(0,curScore.lastSegment.tick + 1,0,curScore.nstaves - 1);
var el = curScore.selection.elements;
var tremolos = [];
for (var i = 0; i < el.length; i++) {
var element = el[i];
console.log("* "+i+") "+element.type + " -- "+element.name);
if (element.type == Element.TREMOLO) {
tremolos.push(element);
}
}
}
In reply to That is where I was going… by dalekdarbuka
So since tremolo and articulations are not actually in the plugin api (you cannot tell what type of tremolo or articulation it is), and it would make more sense to be able to read them from their actual parent. I am putting what I am doing on hold and see if I can contribute to flushing out the api more.
In reply to I don't find them neither. I… by parkingb
I'm just getting started with plugins. What is the utility that generates that dump, and how would I use it?
In reply to I'm just getting started… by dhfx
I know there is this plugin that takes your selection and makes a text file of the properties, methods and parents.
https://musescore.org/en/project/objectexplorer-v20