[SOLVED] Detecting microtonal accidentals

• Mar 10, 2024 - 12:14

I'm trying to develop a plug-in to alter the tuning of some microtonal accidentals, but I'm having troubles detecting the accidental that is applied to a given note.
For example, if a note has a half sharp accidental, I can see via console.log(note.accidentalType) that that accidental is SHARP_SLASH, but I can't seem to detect that accidental inside a switch statement. I tried both detecting it as a string, or as Accidental.SHARP_SLASH, but I never enter that specific case.
Is there a way to detect the accidentals that are applied to a note in this way?

I attached the attempt at the plug-in I made.
In case this matters, this is for Musescore 3.

Attachment Size


I think, You need to check accidental, not note.

var accidental = note.accidental;
if (accidental) {

In reply to by sammik

That doesn't work, when I try to run console.log(accidental.accidentalType), I get undefined in the console.
And if I understand the documentation correctly, note.accidental returns a Ms::PluginAPI::Element, which does not have a accidentalType property, so that cannot work.

I think I found a way to make it work, you have to call the toString() method when you pass the accidental to the switch statement:

switch (note.accidentalType.toString())
 case "SHARP_SLASH":

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