[SOLVED] Detecting microtonal accidentals
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 |
---|---|
MICROTONAL_TEST.qml | 2.46 KB |
Comments
I think, You need to check accidental, not note.
var accidental = note.accidental;
if (accidental) {
console.log(accidental.accidentalType);
}
In reply to I think, You need to check… 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 aMs::PluginAPI::Element
, which does not have aaccidentalType
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 STUFF
break;
}