Setting chordStyle for a Score created from the API

• Jul 24, 2021 - 12:03

Hi,
When creating a score in a plugin with the following code:

var score = newScore("Workout", "bass-flute", 99);

the chordStyle setting isn't set correctly (this can be verified when adding a Chord diagram to a segment: the chord isn't displayed as it does. See this question for more info).

My question is
* how to create the score directly with the chordStyle set correclty
* - or - how to change it afterwards from the plugin ?

My attempts to modify it from the code failed so far.
Both this:

var score = newScore("Workout", "bass-flute", 1);
var cs=eval("Sid.chordStyle");
console.log("CHORD STYLE:" + score.styles.value(cs));

and this:

var score = newScore("Workout", "bass-flute", 1);
console.log("CHORD STYLE:" + score.styles.value(Sid.chordStyle));

are returning an error that "Sid" is unknown.

Any suggestion on how to have this chordStyle set correctly ?

Thanks


Comments

As far as I can see score.style.value() takes a string (and style is singular)

var score = newScore("Workout", "bass-flute", 1);
console.log("CHORD STYLE:" + score.style.value("chordStyle"));
Debug: CHORD STYLE:std

(or jazz or custom)

In reply to by sammik


var score = newScore("Workout", "bass-flute", 1);
console.log("CHORD STYLE:" + score.style.value("chordStyle"));
curScore.style.setValue("chordStyle","jazz");
console.log("CHORD STYLE:" + score.style.value("chordStyle"));

The output is:

Debug: CHORD STYLE:std
Debug: CHORD STYLE:jazz

But in the end, a "Bbt7" chord is still displayed as "t7".

In reply to by parkingb

I've never tried setting this via a plugin, but internally, the effect of that style setting is to cause a particular XML file to be loaded (chords_std or chord_jazz). The symptoms you describe are consistent with that load not happening. Not sure what might be required to trigger it, perhaps wrapping in stand/end command statements?

In reply to by Marc Sabatella

> perhaps wrapping in stand/end command statements?
This is already the case.

And actually, setting that style's value is only a workaround because the score creation via a plugin does not do it correctly.

But the explanation could be the same: the score creation wouldn't load the default xml file correctly.

In reply to by parkingb

You don't need a full file path, just chords_std.xml or chords_jazz.xml would be enough. The code below does change a chord style for me:

curScore.style.setValue("chordStyle", "jazz");
curScore.style.setValue("chordDescriptionFile", "chords_jazz.xml");

Actually the second line alone produces the effect of changing a chord style but it's better to set both values to avoid chord style settings being reverted back by the style dialog, like Jojo has mentioned above.

In reply to by dmitrio95

Thanks !!

For setting the "std" style, oddly one has to set the jazz style first and then the std one:

score.style.setValue("chordDescriptionFile", "chords_jazz.xml");
score.style.setValue("chordStyle", "std");
score.style.setValue("chordDescriptionFile", "chords_std.xml");

So many discussions on so many topics, but I'm glad my new plugin is ready: Scale Workout Builder.
Feel free to check it here. Thanks to all for your help.

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