Skip to content

Commit

Permalink
fix the pickup todo in abc notation
Browse files Browse the repository at this point in the history
  • Loading branch information
retrogtx committed Sep 30, 2024
1 parent 4fdfa32 commit b6162c3
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions js/abc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const processABCNotes = function(logo, turtle) {

for (const [key, value] of Object.entries(replacements)) {
if (note.includes(key)) {
note = note.replace(new RegExp(key, 'g'), value);
note = note.replace(new RegExp(key, "g"), value);
if (key.length === 1) break;
}
}
Expand Down Expand Up @@ -152,16 +152,31 @@ const processABCNotes = function(logo, turtle) {
"\n";
i += 2;
break;
// fixed: how does one define pickup in ABC notation?
// Fixed: how does one define multi-voice in ABC notation?
case "pickup":
// FIXME: how does one define pickup in ABC notation?
i += 1;
{
// Handle pickup measure
const pickupDuration = logo.notation.notationStaging[turtle][i + 1];
logo.notationNotes[turtle] += `K: pickup=${pickupDuration}\n`;
i += 1;
} // <- made a seperate block for this since js doesnt allow declaration of variables using let or const directly inside a case block
break;
case "voice one":
logo.notationNotes[turtle] += "V:1\n";
break;
case "voice two":
logo.notationNotes[turtle] += "V:2\n";
break;
case "voice three":
logo.notationNotes[turtle] += "V:3\n";
break;
case "voice four":
logo.notationNotes[turtle] += "V:4\n";
break;
case "one voice":
// FIXME: how does one define multi-voice in ABC notation?
// Return to a single voice
logo.notationNotes[turtle] += "V:1\n";
break;
default:
logo.notationNotes[turtle] += obj;
Expand Down Expand Up @@ -223,7 +238,7 @@ const processABCNotes = function(logo, turtle) {
}
}

/**
/**
* Processes an incomplete tuplet and appends the corresponding ABC notation to the notation string.
* @param {object} logo - The logo object containing notation information.
* @param {string} turtle - The identifier for the turtle.
Expand Down Expand Up @@ -424,4 +439,4 @@ const saveAbcOutput = function(activity) {

activity.logo.notationOutput += "\n";
return activity.logo.notationOutput;
};
};

0 comments on commit b6162c3

Please sign in to comment.