Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU3 Backend] ENG-57: Remove preliminary chord charts #8530

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,59 @@ static void resetTuplets(Tuplets& tuplets)
}

//---------------------------------------------------------
// cleanFretDiagrams
//---------------------------------------------------------
/**
PVG scores sometimes display fretboards for all chords at
the beginning. These often fail to translate correctly to
MusicXML, so we delete them here.
*/

static void cleanFretDiagrams(Measure* measure)
{
if (measure->no() > 0)
return;
// Case 1: Dummy hidden first measure with all fretboards attached
bool isDummyMeasure = toMeasureBase(measure)->lineBreak();
for (Segment* s = measure->first(SegmentType::ChordRest); s; s = s->next(SegmentType::ChordRest)) {
if (!isDummyMeasure) break;
for (Element* e : s->elist()) {
if (e && e->isChord() && e->visible()) {
isDummyMeasure = false;
break;
}
}
}
if (isDummyMeasure) {
for (Segment* s = measure->first(SegmentType::ChordRest); s; s = s->next(SegmentType::ChordRest)) {
for (Element* e : s->annotations()) {
if (e->isFretDiagram()) {
s->remove(e);
delete e;
}
}
}
}

// Case 2: All the fretboards attached to first beat
Segment* firstBeat = measure->first(SegmentType::ChordRest);
QList<FretDiagram*> beat1FretDiagrams;
int fretDiagramsTrack = -1;
for (Element* e : firstBeat->annotations()) {
if (e->isFretDiagram()
&& (fretDiagramsTrack == e->track() || fretDiagramsTrack == -1)) {
beat1FretDiagrams.append(toFretDiagram(e));
fretDiagramsTrack = e->track();
}
}
if (beat1FretDiagrams.length() > 1 && fretDiagramsTrack != -1) {
for (FretDiagram* fd : beat1FretDiagrams) {
firstBeat->remove(fd);
delete fd;
}
}
}
//---------------------------------------------------------
// initPartState
//---------------------------------------------------------

Expand Down Expand Up @@ -1626,6 +1679,7 @@ void MusicXMLParserPass2::scorePartwise()
_score->lastMeasure()->setEndBarLineType(BarLineType::NORMAL, 0);

_score->connectArpeggios();
cleanFretDiagrams(_score->firstMeasure());
}

//---------------------------------------------------------
Expand Down
Loading