Adding Lyrics via plugin

• Apr 29, 2020 - 21:07

Hi, how can I add lyrics in a plugin?

This works fine for text, however it doesn't seem to work for Element.LYRICS. What am I doing wrong?

var Text = newElement(Element.STAFF_TEXT);
Text.text = 'something';

Best regards,


I don't know the specifics of the plugin syntax, but I do know something of the internal representation. I can tell you that while staff text is added to a segment/track (which is essentially what a "cursor" represents), lyrics are added to chordrests.

Which version of MuseScore do you use? For me it works as expected with Element.LYRICS type:

var cursor = curScore.newCursor();
var lyr = newElement(Element.LYRICS);
lyr.text = "text!";

In reply to by dmitrio95

Thanks for this snippet! It works for me when I call .add(lyr) on a chord.

Do you happen to know how to set the "row number" of stacked lyrics?
I'm not sure if this Plugin API is up-to-date because it does not list the text property and calling the setNo(int) function yields "TypeError: Property 'setNo' of object Ms::PluginAPI::Element(0x55d29e400780) is not a function"...

In reply to by nurfz

The "text" property is listed on the generic "Element" page (…). Unfortunately for 3.x the plugin approach was changed from clean object-owned properties to a generic element propertydump without a decent way of knowing which property is supported by which element.

As for the error message, setNo is a method part of a Lyric and you're calling it on a generic Element so perhaps you're not calling it on the lyric itself?

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