From c511373e25431d1a0eaa95bb3479e686d31aa643 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 6 Nov 2024 11:04:06 +0100 Subject: [PATCH] Add measure number and meterSig changes --- include/vrv/convertfunctor.h | 18 ++++++++++-------- src/convertfunctor.cpp | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/vrv/convertfunctor.h b/include/vrv/convertfunctor.h index 94e1141acb..b7de6edf5e 100644 --- a/include/vrv/convertfunctor.h +++ b/include/vrv/convertfunctor.h @@ -309,22 +309,24 @@ class ConvertToCmnFunctor : public DocFunctor { std::list m_clefs; /** The first clef encountered in the layer */ Clef *m_layerClef; - // The target system, measure, staff & layer + /** The target system, measure, staff & layer */ System *m_targetSystem; - // The current Mensur and Proport + /** The current Mensur and Proport */ AlignMeterParams m_currentParams; - // List of duration element potentially splitted across measures + /** List of duration element potentially splitted across measures */ ListOfObjects m_durationElements; - // Bracket span for ligature, which also acts as a flag + /** Bracket span for ligature, which also acts as a flag */ BracketSpan *m_ligature; - // Bracket span for coloration, which also acts as a flag + /** Bracket span for coloration, which also acts as a flag */ BracketSpan *m_coloration; - // Proportion tuplet + /** Proportion tuplet */ Tuplet *m_proportTuplet; - // The current staffN + /** The current staffN */ Staff *m_currentStaff; - // The current startid (empty string means beginning of the measure and tstamp 0.0) + /** The current startid (empty string means beginning of the measure and tstamp 0.0) */ std::string m_startid; + /** The number of CMN measures generated */ + int m_n; }; //---------------------------------------------------------------------------- diff --git a/src/convertfunctor.cpp b/src/convertfunctor.cpp index 5e9eb48bf5..4d27c708e6 100644 --- a/src/convertfunctor.cpp +++ b/src/convertfunctor.cpp @@ -375,6 +375,7 @@ ConvertToCmnFunctor::ConvertToCmnFunctor(Doc *doc, System *targetSystem, Score * m_targetSystem = targetSystem; m_score = score; m_currentStaff = NULL; + m_n = 0; } FunctorCode ConvertToCmnFunctor::VisitChord(Chord *chord) @@ -548,6 +549,7 @@ FunctorCode ConvertToCmnFunctor::VisitMeasure(Measure *measure) while (time < next) { MeasureInfo measureInfo(time, measureDuration); Measure *cmnMeasure = new Measure(); + cmnMeasure->SetN(std::to_string(++m_n)); measureInfo.m_measure = cmnMeasure; if ((time + measureInfo.m_duration) > next) { measureInfo.m_duration = next - time; @@ -559,8 +561,19 @@ FunctorCode ConvertToCmnFunctor::VisitMeasure(Measure *measure) time = time + measureDuration; if ((time >= next) && (mensurIter != mensurs.end())) { time = next; - measureDuration = this->CalcMeasureDuration((*mensurIter).m_mensur); currentMensur = (*mensurIter).m_mensur; + Fraction duration = this->CalcMeasureDuration(currentMensur); + if (duration != measureDuration) { + ScoreDef *scoreDef = new ScoreDef(); + MeterSig *meterSig = new MeterSig(); + meterSig->IsAttribute(true); + meterSig->SetUnit(2); + Fraction count = duration / Fraction(DURATION_2); + meterSig->SetCount({ { count.GetNumerator() }, MeterCountSign::None }); + scoreDef->AddChild(meterSig); + m_targetSystem->AddChild(scoreDef); + } + measureDuration = duration; std::advance(mensurIter, 1); next = (mensurIter == mensurs.end()) ? totalTime : (*mensurIter).m_time; } @@ -1036,7 +1049,7 @@ void ConvertToCmnFunctor::ConvertMensur(const Mensur *mensur) str += (mensur->GetSign() == MENSURATIONSIGN_C) ? "C" : "O"; if (mensur->GetOrient() == ORIENTATION_reversed) str += "r"; if (mensur->HasSlash()) str += "|"; - if (mensur->HasDot()) str += std::string(mensur->GetDot(), '.'); + if (mensur->HasDot()) str += "."; } if (mensur->HasNum()) { str += std::to_string(mensur->GetNum());