Accessing Ties in a Plugin

• Mar 29, 2022 - 17:13

Is there a way to detect ties and then set their colour?

It would save me manual effort for this type of formatting:

ties.png


Comments

In reply to by jeetee

What does the tieForward value actually mean? How do I then use it?

Example:

  if(element.type == Element.CHORD) {
     console.log("Tie Forward: " + element.notes[0].tieForward);

Gives:

Debug: Tie Forward: Ms::PluginAPI::Tie(0x14617270)

But how do I use this 0x14617270 value?

In reply to by elsewhere

Does it return a note object or a pointer?

My element.notes[0] should also be returning a note, and this to be confirmed by being able to reference its tieForward property. Then I get stuck because I don't know how to use the pointer that this property seems to be.

In reply to by yonah_ag

The debug log shows you the element type and the address value for the wrapper element from it.

You can use it as a truthy value to see whether it exists or not and you can also use the object directly to access the element.

var tie = elements.notes[0].tieForward;
if (tie) {
    console.log("Tied", "color: ", tie.color);
}

Check out this slightly modified walk.qml which also shows the tieForward color and the score used to test it with.

Attachment Size
Untitled.mscz 9.27 KB
walk.qml 4.58 KB

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