From b6162c35d26753f3bc46426206b96a924bfcc02b Mon Sep 17 00:00:00 2001 From: Amrit Rai Date: Mon, 30 Sep 2024 09:31:56 +0530 Subject: [PATCH] fix the pickup todo in abc notation --- js/abc.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/js/abc.js b/js/abc.js index a0bc7b526..33c98e17f 100644 --- a/js/abc.js +++ b/js/abc.js @@ -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; } } @@ -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; @@ -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. @@ -424,4 +439,4 @@ const saveAbcOutput = function(activity) { activity.logo.notationOutput += "\n"; return activity.logo.notationOutput; -}; +}; \ No newline at end of file