From 80ec72db26db16978097b86b61526af75a8b560e Mon Sep 17 00:00:00 2001 From: Craig Stuart Sapp Date: Fri, 19 Jan 2024 22:08:12 -0800 Subject: [PATCH] Implementation for issue https://github.com/humdrum-tools/verovio-humdrum-viewer/issues/872 --- include/vrv/iohumdrum.h | 1 + src/iohumdrum.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/vrv/iohumdrum.h b/include/vrv/iohumdrum.h index f5ac61083e2..f9c31a1d954 100644 --- a/include/vrv/iohumdrum.h +++ b/include/vrv/iohumdrum.h @@ -893,6 +893,7 @@ class HumdrumInput : public vrv::Input { int getKeySignatureNumber(const std::string &humkeysig); int getStaffNumForSpine(hum::HTp token); bool checkIfReversedSpineOrder(std::vector &staffstarts); + bool hasOmdText(int startline, int endline); // header related functions: /////////////////////////////////////////// void createHeader(); diff --git a/src/iohumdrum.cpp b/src/iohumdrum.cpp index b22b2b746ce..96ed8b17f2f 100644 --- a/src/iohumdrum.cpp +++ b/src/iohumdrum.cpp @@ -9684,6 +9684,15 @@ void HumdrumInput::checkForOmd(int startline, int endline) } } + bool omdTextQ = hasOmdText(startline, endline); + + if (omdTextQ) { + // Do not print the !!!OMD: reference record since there is an + // alternate !!LO:TX:omd: entry that will be printed (expected + // to be attached to a time signature for now). + return; + } + if (!value.empty()) { Tempo *tempo = new Tempo(); hum::HTp token = infile.token(index, 0); @@ -9714,6 +9723,28 @@ void HumdrumInput::checkForOmd(int startline, int endline) } } +////////////////////////////// +// +// HumdrumInput::hasOmdText -- Check for global layout text that should +// be used instead of any OMD reference record. +// + +bool HumdrumInput::hasOmdText(int startline, int endline) +{ + hum::HumdrumFile &infile = m_infiles[0]; + hum::HumRegex hre; + for (int i = startline; i <= endline; i++) { + if (infile[i].hasSpines()) { + continue; + } + hum::HTp token = infile.token(i, 0); + if (hre.search(token, "^!!LO:TX.*:omd(:|$)")) { + return true; + } + } + return false; +} + ////////////////////////////// // // HumdrumInput::addChildBackMeasureOrSection -- Add to the current measure, or add to section