Accessing Articulations and Layout breaks after creation

• Oct 10, 2021 - 14:16

Hello,
I have some issues accessing to some informations after having created it within a plugin. Does anyone know how to retrieve an articulation in the score please ? I thought I could find them with the following code, but I had no success with it. The console show no result when it's applied to a nota with an accent.

var cursor = curScore.newCursor()
cursor.rewind(1)

var i=0
var segmentTemp=cursor.segment

for(i=0 ; i


Comments

Articulation is an element type. So you'd need to cycle though all elements of the score or selection and pick on their type.
Check the "walk.qml" plugin:

...
            var cursor = curScore.newCursor();
            cursor.voice    = 0;
            cursor.staffIdx = 0;
            cursor.rewind(Cursor.SCORE_START);
 
            while (cursor.segment) {
                var e = cursor.element;
                if (e) {
                    console.log("type:", e.name, "at  tick:", e.tick, "color", e.color);
                    if (e.type == Element.REST) {
                        var d = e.duration;
                        console.log("   duration " + d.numerator + "/" + d.denominator);
                        }
                    }
                cursor.next();
                }
...
 

In reply to by Jojo-Schmitz

Hello ! Thank you for your answer. I know how to cycle through all the elements of the score with the cursor, but I am not able to find any Element.ARTICULATION or any Element.LAYOUT_BREAK, even with the "walk.qml" plugin.
As I have seen on the documentation, Articulations are considered as annotations of a segment and have as parent a chord element. But I wasn't able to find them this way either. Do you have an idea why please ?

In reply to by millermix

I believe that articulations are not annotations on the segment but rather are children of chordrest elements directly. The exception is fermatas which are kind of a separate class. I'm not sure what that might mean as far as plugins go, but I wouldn't be trying to find them on the segment. if they are exposed at all, I'd expect it to be as a method on the chordrest.

In reply to by millermix

The walk.qml plugin only walks through "main" elements of the score like chords or rests. To search for annotations you should get the current segment and check its annotations list. Layout breaks are attached to a measure so you should use the measure.elements property, like this:

var annotations = cursor.segment.annotations;
for (var i = 0; i < annotations.length; ++i) {
    var el = annotations[i];
    console.log(el.type, el.name);
}
 
var measureElements = cursor.measure.elements;
for (var i = 0; i < measureElements.length; ++i) {
    var el = measureElements[i];
    console.log(el.type, el.name);
}

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