Skip to content

Commit

Permalink
ENG-14: Fix barlines on multi-staff parts
Browse files Browse the repository at this point in the history
This commit fixes the handling of (non-repeat) barlines on grand staves
by creating a barline for each staff in the part, and setting the
_spanStaff property of the first barline of each multi-staff part.
Also updates the relevant tests.
  • Loading branch information
iveshenry18 committed May 28, 2021
1 parent 6246995 commit cfbbea8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 11 additions & 4 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -3258,12 +3258,12 @@ static bool determineBarLineType(const QString& barStyle, const QString& repeat,
* Create a barline of the specified type.
*/

static std::unique_ptr<BarLine> createBarline(Score* score, const int track, const BarLineType type, const bool visible, const QString& barStyle)
static std::unique_ptr<BarLine> createBarline(Score* score, const int track, const BarLineType type, const bool visible, const QString& barStyle, bool spanStaff)
{
std::unique_ptr<BarLine> barline(new BarLine(score));
barline->setTrack(track);
barline->setBarLineType(type);
barline->setSpanStaff(0);
barline->setSpanStaff(spanStaff);
barline->setVisible(visible);
if (barStyle == "tick") {
barline->setSpanFrom(BARLINE_SPAN_TICK1_FROM);
Expand Down Expand Up @@ -3378,8 +3378,15 @@ void MusicXMLParserPass2::barline(const QString& partId, Measure* measure, const
|| barStyle == "dotted"
|| barStyle == "light-light"
|| barStyle == "regular") {
auto b = createBarline(measure->score(), track, type, visible, barStyle);
addBarlineToMeasure(measure, tick, std::move(b));
// Add barline to the first voice of every staff in the part,
// and span every barline except the last
int nstaves = _pass1.getPart(partId)->nstaves();
for (int i = 0; i < nstaves; ++i ) {
bool spanStaff = i < nstaves - 1;
int currentTrack = track + (i * VOICES);
auto b = createBarline(measure->score(), currentTrack, type, visible, barStyle, spanStaff);
addBarlineToMeasure(measure, tick, std::move(b));
}
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions mtest/musicxml/io/testBarlinesGrandStaff_ref.mscx
Expand Up @@ -190,7 +190,7 @@
</Rest>
<BarLine>
<subtype>dotted</subtype>
<span>0</span>
<span>1</span>
</BarLine>
</voice>
</Measure>
Expand Down Expand Up @@ -218,7 +218,7 @@
</Rest>
<BarLine>
<subtype>double</subtype>
<span>0</span>
<span>1</span>
</BarLine>
</voice>
</Measure>
Expand Down Expand Up @@ -296,7 +296,7 @@
</Rest>
<BarLine>
<subtype>double</subtype>
<span>0</span>
<span>1</span>
</BarLine>
</voice>
</Measure>
Expand Down Expand Up @@ -474,6 +474,9 @@
<durationType>measure</durationType>
<duration>1/1</duration>
</Rest>
<BarLine>
<subtype>dotted</subtype>
</BarLine>
</voice>
</Measure>
<Measure>
Expand All @@ -498,6 +501,9 @@
<durationType>measure</durationType>
<duration>1/1</duration>
</Rest>
<BarLine>
<subtype>double</subtype>
</BarLine>
</voice>
</Measure>
<Measure>
Expand Down Expand Up @@ -572,6 +578,9 @@
<durationType>measure</durationType>
<duration>1/1</duration>
</Rest>
<BarLine>
<subtype>double</subtype>
</BarLine>
</voice>
</Measure>
<Measure>
Expand Down

0 comments on commit cfbbea8

Please sign in to comment.