-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix instrument change clef not reacting to concert pitch toggle #32499
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,22 +97,20 @@ | |||||||||||||||||
| Interval oldV = part->instrument(tickStart)->transpose(); | ||||||||||||||||||
| Interval oldKv = staff()->transpose(tickStart); | ||||||||||||||||||
| Interval v = instrument->transpose(); | ||||||||||||||||||
| bool concPitch = style().styleB(Sid::concertPitch); | ||||||||||||||||||
|
Check warning on line 100 in src/engraving/dom/instrchange.cpp
|
||||||||||||||||||
|
|
||||||||||||||||||
| // change the clef for each staff | ||||||||||||||||||
| for (size_t i = 0; i < part->nstaves(); i++) { | ||||||||||||||||||
| ClefType oldClefType = concPitch ? part->instrument(tickStart)->clefType(i).concertClef | ||||||||||||||||||
| : part->instrument(tickStart)->clefType(i).transposingClef; | ||||||||||||||||||
| ClefType newClefType = concPitch ? instrument->clefType(i).concertClef | ||||||||||||||||||
| : instrument->clefType(i).transposingClef; | ||||||||||||||||||
| // Introduce cleff change only if the new clef *symbol* is different from the old one | ||||||||||||||||||
| if (ClefInfo::symId(oldClefType) != ClefInfo::symId(newClefType)) { | ||||||||||||||||||
| // If instrument change is at the start of a measure, use the measure as the element, as this will place the instrument change before the barline. | ||||||||||||||||||
| ClefTypeList oldClefTypeList = part->instrument(tickStart)->clefType(i); | ||||||||||||||||||
| ClefTypeList newClefTypeList = instrument->clefType(i); | ||||||||||||||||||
| if (ClefInfo::symId(oldClefTypeList.concertClef) != ClefInfo::symId(newClefTypeList.concertClef) | ||||||||||||||||||
| || ClefInfo::symId(oldClefTypeList.transposingClef) != ClefInfo::symId(newClefTypeList.transposingClef)) { | ||||||||||||||||||
| int cp = static_cast<int>(newClefTypeList.concertClef); | ||||||||||||||||||
| int tp = static_cast<int>(newClefTypeList.transposingClef); | ||||||||||||||||||
| int packedData = 1000 + (cp & 0xFF) + ((tp & 0xFF) << 8); | ||||||||||||||||||
|
Comment on lines
+107
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Extract IC clef packing into shared constants/helper. Line 109 uses inline Refactor direction- int cp = static_cast<int>(newClefTypeList.concertClef);
- int tp = static_cast<int>(newClefTypeList.transposingClef);
- int packedData = 1000 + (cp & 0xFF) + ((tp & 0xFF) << 8);
+ constexpr int kIcClefPackOffset = 1000;
+ constexpr int kIcClefMask = 0xFF;
+ const int cp = static_cast<int>(newClefTypeList.concertClef);
+ const int tp = static_cast<int>(newClefTypeList.transposingClef);
+ const int packedData = kIcClefPackOffset + (cp & kIcClefMask) + ((tp & kIcClefMask) << 8);📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| EngravingItem* element = rtick().isZero() ? toEngravingItem(findMeasure()) : toEngravingItem(this); | ||||||||||||||||||
| score()->undoChangeClef(part->staff(i), element, newClefType, true); | ||||||||||||||||||
| score()->undoChangeClef(part->staff(i), element, newClefTypeList.concertClef, packedData); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // Change key signature if necessary. CAUTION: not necessary in case of octave-transposing! | ||||||||||||||||||
| if ((v.chromatic - oldV.chromatic) % 12) { | ||||||||||||||||||
| for (size_t i = 0; i < part->nstaves(); i++) { | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -500,7 +500,7 @@ class Score : public EngravingObject, public muse::Contextable | |||||
| void undoChangeTuning(Note*, double); | ||||||
| void undoChangeUserMirror(Note*, DirectionH); | ||||||
| void undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent); | ||||||
| void undoChangeClef(Staff* ostaff, EngravingItem*, ClefType st, bool forInstrumentChange = false, Clef* clefToRelink = nullptr); | ||||||
| void undoChangeClef(Staff* ostaff, EngravingItem*, ClefType st, int forInstrumentChange = false, Clef* clefToRelink = nullptr); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Type change from While Consider:
Proposed minimal fix for default value- void undoChangeClef(Staff* ostaff, EngravingItem*, ClefType st, int forInstrumentChange = false, Clef* clefToRelink = nullptr);
+ void undoChangeClef(Staff* ostaff, EngravingItem*, ClefType st, int forInstrumentChange = 0, Clef* clefToRelink = nullptr);For a more robust API, consider introducing a small struct or enum to encapsulate the instrument-change clef data instead of relying on magic-number packing in a public interface. 📝 Committable suggestion
Suggested change
|
||||||
| bool undoPropertyChanged(EngravingItem* item, Pid propId, const PropertyValue& propValue, | ||||||
| PropertyFlags propFlags = PropertyFlags::NOSTYLE); | ||||||
| void undoPropertyChanged(EngravingObject*, Pid, const PropertyValue& v, PropertyFlags ps = PropertyFlags::NOSTYLE); | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compare full clef types instead of glyph IDs.
Line 105 and Line 106 compare only
ClefInfo::symId(...). Different clef types can share the same symbol, so required IC clef updates may be skipped.Proposed fix
📝 Committable suggestion