From 469e65a9f422440affd073ea21ae0775244ad2ad Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Thu, 1 Aug 2024 12:43:09 -0400 Subject: [PATCH] Calculate clef displacement when inserting custos Refs: https://github.com/DDMAL/Neon/issues/1235 --- src/editortoolkit_neume.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/editortoolkit_neume.cpp b/src/editortoolkit_neume.cpp index 341b04c5aa8..ad87ab2b311 100644 --- a/src/editortoolkit_neume.cpp +++ b/src/editortoolkit_neume.cpp @@ -4247,6 +4247,14 @@ bool EditorToolkitNeume::AdjustPitchFromPosition(Object *obj, Clef *clef) } pi->SetOct(3); + // The default octave = 3, but the actual octave is calculated by + // taking into account the displacement of the clef + int octave = 3; + if (clef->GetDis() && clef->GetDisPlace()) { + octave += (clef->GetDisPlace() == STAFFREL_basic_above ? 1 : -1) * (clef->GetDis() / 7); + } + pi->SetOct(octave); + const int staffSize = m_doc->GetDrawingUnit(staff->m_drawingStaffSize); const int pitchDifference