Skip to content

Commit

Permalink
Added check to see if the annotation contains text
Browse files Browse the repository at this point in the history
With this change the plugin works correctly for fermatas, and other annotations that don't contain text.
  • Loading branch information
looptailG committed May 4, 2024
1 parent 517c1b3 commit c9f1a66
Showing 1 changed file with 55 additions and 51 deletions.
106 changes: 55 additions & 51 deletions source/31EdoTuner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -284,63 +284,67 @@ MuseScore
// signature change.
for (var i = 0; i < cursor.segment.annotations.length; i++)
{
var annotationText = cursor.segment.annotations[i].text.replace(/\s*/g, "");
if (customKeySignatureRegex.test(annotationText))
var annotationText = cursor.segment.annotations[i].text;
if (annotationText)
{
logMessage("Applying the current custom key signature: " + annotationText);
currentCustomKeySignature = {};
try
annotationText = annotationText.replace(/\s*/g, "");
if (customKeySignatureRegex.test(annotationText))
{
var annotationTextSplitted = annotationText.split(".");
for (var j = 0; j < annotationTextSplitted.length; j++)
logMessage("Applying the current custom key signature: " + annotationText);
currentCustomKeySignature = {};
try
{
var currentNote = customKeySignatureNoteOrder[j];
var currentAccidental = annotationTextSplitted[j].trim();
var accidentalName = "";
switch (currentAccidental)
var annotationTextSplitted = annotationText.split(".");
for (var j = 0; j < annotationTextSplitted.length; j++)
{
case "bb":
case "b":
case "":
case "h":
case "#":
case "x":
// Non-microtonal accidentals are
// automatically handled by
// Musescore even in custom key
// signatures, so we only have to
// check for microtonal accidentals.
break;

case "db":
accidentalName = "MIRRORED_FLAT2";
break;

case "d":
accidentalName = "MIRRORED_FLAT";
break;

case "t":
accidentalName = "SHARP_SLASH";
break;

case "t#":
accidentalName = "SHARP_SLASH4";
break;

default:
throw "Unsupported accidental in the custom key signature: " + currentAccidental;
}
if (accidentalName != "")
{
currentCustomKeySignature[currentNote] = accidentalName;
var currentNote = customKeySignatureNoteOrder[j];
var currentAccidental = annotationTextSplitted[j].trim();
var accidentalName = "";
switch (currentAccidental)
{
case "bb":
case "b":
case "":
case "h":
case "#":
case "x":
// Non-microtonal accidentals are
// automatically handled by
// Musescore even in custom key
// signatures, so we only have to
// check for microtonal accidentals.
break;

case "db":
accidentalName = "MIRRORED_FLAT2";
break;

case "d":
accidentalName = "MIRRORED_FLAT";
break;

case "t":
accidentalName = "SHARP_SLASH";
break;

case "t#":
accidentalName = "SHARP_SLASH4";
break;

default:
throw "Unsupported accidental in the custom key signature: " + currentAccidental;
}
if (accidentalName != "")
{
currentCustomKeySignature[currentNote] = accidentalName;
}
}
}
}
catch (error)
{
logMessage(error, true);
currentCustomKeySignature = {};
catch (error)
{
logMessage(error, true);
currentCustomKeySignature = {};
}
}
}
}
Expand Down

0 comments on commit c9f1a66

Please sign in to comment.