Skip to content

Commit

Permalink
Merge pull request #3873 from DDMAL/c4-fix
Browse files Browse the repository at this point in the history
Fix clef misbehaviour regarding octave change
  • Loading branch information
lpugin authored Dec 4, 2024
2 parents 3db5a20 + 67a5a42 commit 685bedb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
43 changes: 26 additions & 17 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4226,24 +4226,31 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef)
return false;
}

int clefOffset = 0;
if (clef == NULL) {
ClassIdComparison ac(CLEF);
clef = dynamic_cast<Clef *>(m_doc->GetDrawingPage()->FindPreviousChild(&ac, obj));
int clefOffset = 0;
if (clef == NULL) {
Layer *layer = vrv_cast<Layer *>(staff->FindDescendantByType(LAYER));
assert(layer);
clef = layer->GetCurrentClef();
ClassIdComparison ac(CLEF);
clef = dynamic_cast<Clef *>(m_doc->GetDrawingPage()->FindPreviousChild(&ac, obj));
if (clef == NULL) {
Layer *layer = vrv_cast<Layer *>(staff->FindDescendantByType(LAYER));
assert(layer);
clef = layer->GetCurrentClef();
}
else {
Staff *clefStaff = dynamic_cast<Staff *>(clef->GetFirstAncestor(STAFF));
assert(clefStaff);
clefOffset = round((double)(clefStaff->GetDrawingY()
- clefStaff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(clef->GetZone()->GetUlx()))
- m_view->ToLogicalY(clef->GetZone()->GetUly())));
}
}
}

data_PITCHNAME pname;
const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize);
Staff *clefStaff = dynamic_cast<Staff *>(clef->GetFirstAncestor(STAFF));
assert(clefStaff);
const int clefOffset = round((double)(clefStaff->GetDrawingY()
- clefStaff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(clef->GetZone()->GetUlx()))
- m_view->ToLogicalY(clef->GetZone()->GetUly())));

switch (clef->GetShape()) {
case CLEFSHAPE_C: pname = PITCHNAME_c; break;
case CLEFSHAPE_F: pname = PITCHNAME_f; break;
Expand Down Expand Up @@ -4283,6 +4290,8 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef)
LogWarning("Syllable/neume had no pitched children to reorder for syllable/neume %s", obj->GetID().c_str());
return true;
}

int clefOffset = 0;
if (clef == NULL) {
ClassIdComparison ac(CLEF);
clef = dynamic_cast<Clef *>(m_doc->GetDrawingPage()->FindPreviousChild(&ac, obj));
Expand All @@ -4291,17 +4300,17 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef)
assert(layer);
clef = layer->GetCurrentClef();
}
else {
Staff *clefStaff = dynamic_cast<Staff *>(clef->GetFirstAncestor(STAFF));
assert(clefStaff);
clefOffset = round((double)(clefStaff->GetDrawingY()
- clefStaff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(clef->GetZone()->GetUlx()))
- m_view->ToLogicalY(clef->GetZone()->GetUly())));
}
}

assert(clef);

data_PITCHNAME pname;
data_PITCHNAME pname = PITCHNAME_c;
const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize);
Staff *clefStaff = dynamic_cast<Staff *>(clef->GetFirstAncestor(STAFF));
assert(clefStaff);
const int clefOffset = round((double)(clefStaff->GetDrawingY()
- clefStaff->GetDrawingRotationOffsetFor(m_view->ToLogicalX(clef->GetZone()->GetUlx()))
- m_view->ToLogicalY(clef->GetZone()->GetUly())));

switch (clef->GetShape()) {
case CLEFSHAPE_C: pname = PITCHNAME_c; break;
Expand Down
4 changes: 2 additions & 2 deletions src/pitchinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ void PitchInterface::AdjustPitchForNewClef(const Clef *oldClef, const Clef *newC

int pitchDiff = -2 * (newClef->GetLine() - oldClef->GetLine());
if (oldClef->GetShape() == CLEFSHAPE_F) {
pitchDiff -= 3;
pitchDiff += 4;
}
else if (oldClef->GetShape() == CLEFSHAPE_G) {
pitchDiff -= 4;
}
if (newClef->GetShape() == CLEFSHAPE_F) {
pitchDiff += 3;
pitchDiff -= 4;
}
else if (newClef->GetShape() == CLEFSHAPE_G) {
pitchDiff += 4;
Expand Down

0 comments on commit 685bedb

Please sign in to comment.