From 300231598559dbe46832973d2369a013cb6f009b Mon Sep 17 00:00:00 2001 From: Wolfgang Drescher Date: Tue, 14 Mar 2023 22:46:04 +0100 Subject: [PATCH] Fix issue where some note durations were not clipped --- include/humlib.h | 2 +- src/humlib.cpp | 30 +++++++++++++++--------------- src/tool-myank.cpp | 28 ++++++++++++++-------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/humlib.h b/include/humlib.h index d741c55a..4350c4ec 100644 --- a/include/humlib.h +++ b/include/humlib.h @@ -1,7 +1,7 @@ // // Programmer: Craig Stuart Sapp // Creation Date: Sat Aug 8 12:24:49 PDT 2015 -// Last Modified: Di 14 Mär 2023 21:42:31 CET +// Last Modified: Di 14 Mär 2023 22:41:15 CET // Filename: humlib.h // URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h // Syntax: C++11 diff --git a/src/humlib.cpp b/src/humlib.cpp index 58d5b88a..acdde41a 100644 --- a/src/humlib.cpp +++ b/src/humlib.cpp @@ -1,7 +1,7 @@ // // Programmer: Craig Stuart Sapp // Creation Date: Sat Aug 8 12:24:49 PDT 2015 -// Last Modified: Di 14 Mär 2023 21:42:31 CET +// Last Modified: Di 14 Mär 2023 22:41:15 CET // Filename: /include/humlib.cpp // URL: https://github.com/craigsapp/humlib/blob/master/src/humlib.cpp // Syntax: C++11 @@ -103564,25 +103564,25 @@ void Tool_myank::printDataLine(HLp line, continue; } HumNum dur = lastLineDurationsFromNoteStart[i]; - if (resolvedToken->getDuration() > dur) { - HumRegex hre; - string recip = Convert::durationToRecip(dur); - vector subtokens = resolvedToken->getSubtokens(); - for (int i=0; i<(int)subtokens.size(); i++) { - if (hre.search(subtokens[i], recipRegex)) { - string before = hre.getPrefix(); - string after = hre.getSuffix(); - hre.replaceDestructive(after, "", recipRegex, "g"); - string subtokenText; + HumRegex hre; + string recip = Convert::durationToRecip(dur); + vector subtokens = resolvedToken->getSubtokens(); + for (int i=0; i<(int)subtokens.size(); i++) { + if (hre.search(subtokens[i], recipRegex)) { + string before = hre.getPrefix(); + string after = hre.getSuffix(); + hre.replaceDestructive(after, "", recipRegex, "g"); + string subtokenText; + if (resolvedToken->getDuration() > dur) { // Add a tie start if not already in a tie group if (!hre.search(subtokens[i], "[_\\[]")) { subtokenText += "["; } - // Replace the old duration with the clipped one - subtokenText += before + recip + after; - token->replaceSubtoken(i, subtokenText); - lineChange = true; } + // Replace the old duration with the clipped one + subtokenText += before + recip + after; + token->replaceSubtoken(i, subtokenText); + lineChange = true; } } } diff --git a/src/tool-myank.cpp b/src/tool-myank.cpp index 12fe6ab4..ee390638 100644 --- a/src/tool-myank.cpp +++ b/src/tool-myank.cpp @@ -1383,25 +1383,25 @@ void Tool_myank::printDataLine(HLp line, continue; } HumNum dur = lastLineDurationsFromNoteStart[i]; - if (resolvedToken->getDuration() > dur) { - HumRegex hre; - string recip = Convert::durationToRecip(dur); - vector subtokens = resolvedToken->getSubtokens(); - for (int i=0; i<(int)subtokens.size(); i++) { - if (hre.search(subtokens[i], recipRegex)) { - string before = hre.getPrefix(); - string after = hre.getSuffix(); - hre.replaceDestructive(after, "", recipRegex, "g"); - string subtokenText; + HumRegex hre; + string recip = Convert::durationToRecip(dur); + vector subtokens = resolvedToken->getSubtokens(); + for (int i=0; i<(int)subtokens.size(); i++) { + if (hre.search(subtokens[i], recipRegex)) { + string before = hre.getPrefix(); + string after = hre.getSuffix(); + hre.replaceDestructive(after, "", recipRegex, "g"); + string subtokenText; + if (resolvedToken->getDuration() > dur) { // Add a tie start if not already in a tie group if (!hre.search(subtokens[i], "[_\\[]")) { subtokenText += "["; } - // Replace the old duration with the clipped one - subtokenText += before + recip + after; - token->replaceSubtoken(i, subtokenText); - lineChange = true; } + // Replace the old duration with the clipped one + subtokenText += before + recip + after; + token->replaceSubtoken(i, subtokenText); + lineChange = true; } } }