Plugin API Bug or Feature? Note.accidental and Note.accidentalType not updated in new cursor instance after setting to regular accidental.

• May 27, 2020 - 13:14

Hi all. I have provided a condensed snippet of my situation:

Assuming that the first note in the score on voice = 1, staffIdx = 1, tick = 0 exists, and is any note that is not F#...

// some necessary preliminary code for other parts of the plugin.
cursor.track = 0;

// Setting the first note to F#5
var x = {the first note in the score};
x.line = 0;
x.accidentalType = Accidental.SHARP;
console.log(x.accidental, x.accidentalType); // as expected: Ms::PluginAPI::Element(0x1dbb9fe0) SHARP

// some more necessary code
cursor.track = 0;

// this is my issue
var y = cursor.element.notes[0];
console.log(y.line); // correct: 0
console.log(y.tpc); // correct: 20
console.log(y.accidental); // expected: [Element object], got: null
console.log(y.accidentalType); // expected: SHARP, got: NONE

The unexpected values of y.accidental and y.accidentalType do not occur when I set the x.accidentalType to a non-standard microtonal accidental such as SHARP_ARROW_DOWN or MIRRORED_FLAT, and I assume it is because when I set the accidental to a recognized standard accidental, it updates the tpc of the note, removes any attached accidental and marks the score dirty such that it updates and attaches the new regular accidental only after the plugin runs.

However, I require access to that accidental in order for my plugin to work. Is there any way I can force the score to redraw in the middle of my plugin's execution? Or is there something I'm missing or doing wrong? Or is this a bug that I should report in the Support and Bug Reports forum?

Any help greatly appreciated :)

Thanks in advance!


Depending on your pluginType the framework calls startCmd/endCmd for you to apply the undostack correctly.
You could try calling endCmd() after changing the setting, Then startCmd() again before changing different stuff.

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