From 44064f5317b5a29c917383a305827d457161718b Mon Sep 17 00:00:00 2001 From: Hasinjato Date: Mon, 15 Jun 2026 13:53:56 +0300 Subject: [PATCH] Fix! Implement visual note Transposition by Clicking on SongKey --- .../src/commonMain/kotlin/mg/dot/feufaro/solfa/Transpose.kt | 6 ++++-- .../src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Transpose.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Transpose.kt index db108b3..a4c51e8 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Transpose.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Transpose.kt @@ -61,10 +61,12 @@ class Transpose { val remaining = token.drop(separators.length) val totalAlter = interval + currentModulationInterval - + val rawIndex = (0 + totalAlter) % 12 + val targetKeyIndex = if (rawIndex < 0) rawIndex + 12 else rawIndex + val calculatedToKey = keyToNumber[targetKeyIndex] val transposedBody = NOTE_UNIT_REGEX.replace(remaining) { matchResult -> val fullNote = matchResult.value - transpose(note = fullNote, fromKey = "C", toKey = "C", alter = totalAlter) + transpose(note = fullNote, fromKey = "C", toKey = calculatedToKey) } val result = separators + transposedBody diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt index b632a88..b1122db 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt @@ -248,7 +248,8 @@ fun MainScreenWithDrawer( var isEyeVisible by remember { mutableStateOf(false) } val keysOrder = Transpose.keyToNumber val songKeyIndex = keysOrder.indexOf(songKey).takeIf { it != -1 } ?: 0 - val tempUiKey = keysOrder[(songKeyIndex + tempInterval + 24) % 12] + val rawKeyIndex = (songKeyIndex + tempInterval) % 12 + val tempUiKey = keysOrder[if (rawKeyIndex < 0) rawKeyIndex + 12 else rawKeyIndex] val appliedInterval by sharedScreenModel.transpositionInterval.collectAsState() val isPendingChange = tempInterval != appliedInterval val isCurrentlyTransposed = appliedInterval != 0