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

fix #18425 - part containing key with more than 6 accidentals #18453

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
5 changes: 5 additions & 0 deletions src/engraving/rw/read400/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,11 @@ void TRead::read(KeySig* s, XmlReader& e, ReadContext& ctx)
if (sig.custom() && sig.customKeyDefs().empty()) {
sig.setMode(KeyMode::NONE);
}
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
if (p && !s->concertPitch() && (sig.key() > 6 || sig.key() < -6)
&& p->preferSharpFlat() == PreferSharpFlat::AUTO && !p->instrument(s->tick())->transpose().isZero()) {
p->setPreferSharpFlat(PreferSharpFlat::NONE);
}

s->setKeySigEvent(sig);
}
Expand Down
5 changes: 5 additions & 0 deletions src/engraving/rw/read410/tread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,11 @@ void TRead::read(KeySig* s, XmlReader& e, ReadContext& ctx)
if (sig.custom() && sig.customKeyDefs().empty()) {
sig.setMode(KeyMode::NONE);
}
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
if (p && !s->concertPitch() && (sig.key() > 6 || sig.key() < -6)
&& p->preferSharpFlat() == PreferSharpFlat::AUTO && !p->instrument(s->tick())->transpose().isZero()) {
p->setPreferSharpFlat(PreferSharpFlat::NONE);
}

s->setKeySigEvent(sig);
}
Expand Down
4 changes: 4 additions & 0 deletions src/importexport/bb/internal/bb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ Err importBB(MasterScore* score, const QString& name)
Interval v = staff->part()->instrument(tick)->transpose();
if (!v.isZero() && !score->style().styleB(Sid::concertPitch)) {
cKey = transposeKey(key, v);
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
if ((key > 6 || key < -6) && staff->part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
staff->part()->setPreferSharpFlat(PreferSharpFlat::NONE);
}
}
ke.setConcertKey(cKey);
ke.setKey(key);
Expand Down
7 changes: 6 additions & 1 deletion src/importexport/capella/internal/capella.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,13 @@ static Fraction readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, const
Key tKey = Key(o->signature);
Key cKey = tKey;
Interval v = score->staff(staffIdx)->part()->instrument(tick)->transpose();
if (!v.isZero() && score->style().styleB(mu::engraving::Sid::concertPitch)) {
if (!v.isZero() && !score->style().styleB(mu::engraving::Sid::concertPitch)) {
cKey = transposeKey(tKey, v);
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
Part* part = score->staff(staffIdx)->part();
if ((tKey > 6 || tKey < -6) && part->preferSharpFlat() == PreferSharpFlat::AUTO) {
part->setPreferSharpFlat(PreferSharpFlat::NONE);
}
}
okey.setConcertKey(cKey);
okey.setKey(tKey);
Expand Down
4 changes: 4 additions & 0 deletions src/importexport/midi/internal/midiimport/importmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ void MTrack::processMeta(int tick, const MidiEvent& mm)
Interval v = staff->part()->instrument(t)->transpose();
if (!v.isZero() && !cs->style().styleB(Sid::concertPitch)) {
cKey = transposeKey(tKey, v);
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
if ((tKey > 6 || tKey < -6) && staff->part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
staff->part()->setPreferSharpFlat(PreferSharpFlat::NONE);
}
}
ke.setConcertKey(cKey);
ke.setKey(tKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3826,6 +3826,11 @@ void MusicXMLParserPass2::key(const QString& partId, Measure* measure, const Fra
Interval v = _pass1.getPart(partId)->instrument()->transpose();
if (!v.isZero() && !_score->style().styleB(Sid::concertPitch)) {
cKey = transposeKey(tKey, v);
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
Part* part = _pass1.getPart(partId);
if ((tKey > 6 || tKey < -6) && part->preferSharpFlat() == PreferSharpFlat::AUTO) {
part->setPreferSharpFlat(PreferSharpFlat::NONE);
}
}
key.setConcertKey(cKey);
key.setKey(tKey);
Expand Down
4 changes: 4 additions & 0 deletions src/importexport/ove/internal/importove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,10 @@ void OveToMScore::convertSignatures()
Interval v = staff.part()->instrument(tick)->transpose();
if (!v.isZero() && !m_score->style().styleB(Sid::concertPitch)) {
cKey = transposeKey(key, v);
// if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
if ((key > 6 || key < -6) && staff.part()->preferSharpFlat() == PreferSharpFlat::AUTO) {
staff.part()->setPreferSharpFlat(PreferSharpFlat::NONE);
}
}
ke.setConcertKey(cKey);
ke.setKey(key);
Expand Down