Skip to content

Commit

Permalink
Add measure number and meterSig changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 6, 2024
1 parent 38fc4af commit c511373
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
18 changes: 10 additions & 8 deletions include/vrv/convertfunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,22 +309,24 @@ class ConvertToCmnFunctor : public DocFunctor {
std::list<Clef *> 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;
};

//----------------------------------------------------------------------------
Expand Down
17 changes: 15 additions & 2 deletions src/convertfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit c511373

Please sign in to comment.