Coloring slurs from within a plugin

• Jun 28, 2023 - 14:20

Hello,

i am working on a plugin to simplify exercising for a choir.

Simplified description:
In the plugin, the following choices can be made:
The exercise "Part" can be chosen by radiobutton.
The "Channel" (if more then one) can be chosen by radiobutton.

For the above choices the plugin now solely amplify volumes. Also colours (purple) the relevant notes(coloring includes stems, hooks, beams, dots, ties and gracenotes). All other channels/notes/etc are de-amplified and greyed out.

My question:
I want to colour the relevant Slurs as well, but i can't figure out how to do that.
I think it's not possible but if there is some workaround i like to hear about it !

background info:
This example code works:
[START CODE EXAMPLE]
colorElement( cursor.element.notes[k].tieForward , color_wanted) <<<<<<< (this works)
.....
.....
cursor.next()
// colorelement colors the element and puts in front with .z
[END CODE EXAMPLE]
but something similar with a Slur does not work

appriciate your help in this!

Harrie.


Comments

MuseScore gives less controls over slurs than ties, but you can try searching through a selection:

curScore.startCmd()
//either
cmd('select-all')
//or
curScore.selection.selectRange(parameters)
//then
for (var i in curScore.selection.elements) {
 if (curScore.selection.elements[i].type == Element.SLUR || curScore.selection.elements[i].type == Element.SLUR_SEGMENT) {
 colorElement(curScore.selection.elements[i])
 }
}
curScore.endCmd()

In reply to by hpcs444@gmail.com

Hi,

i tried your solution, my problem is solved (a workaround):

I could programmatically (by your method) select all slurs, but i could not find how the slur was "attached" to a specific note, channel or voice.

I tried all kind of searches on elements but got "undefined", "cannot read property of null..","cannot read property of undefined" et cetera et cetera.

I could find the Part/Staff it was attached to:
if the name was "Slur"(or something else) then i found the part/staff with
curScore.selection.elements[i].staff.part.startTrack
et cetera

but that was as far as i could get the information.

So i decided to make the selected slurs invisible, Slurs have in my case no effect on playback, and the scores are solely used for practice, and not while singing in the choir itself.

Thank you for your help!

Harrie.

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