diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt index 0aed48a..3d1cfb8 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -2421,6 +2421,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository } var lastIt = ' ' var lastSignificantIt = ' ' + var beatPos = 0 val newN = POneVoiceNote() val lineRepeated = REGEX_REPETITION.replace(line) { matchResult -> val (charIterated, iteration) = matchResult.destructured @@ -2440,7 +2441,15 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository if (nextDuration > 0 && lastIt != '-') { midiDuration += nextDuration } + if (lastNoteString.isNotEmpty() + && midiDuration == 0 + && nextDuration == 0 + && beatPos in 1..59 + ) { + midiDuration = 60 - beatPos + } nextDuration = 60 + beatPos = 0 } } @@ -2459,6 +2468,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository } '.' -> { + beatPos = 30 if (lastIt == ';' || lastSignificantIt == ';') { pushMidi() lastNoteString = "z" @@ -2466,8 +2476,12 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository nextDuration = 30 } if (lastSignificantIt == '-') { - midiDuration += 30 - nextDuration - nextDuration = 30 + if (nextDuration > 30) { + midiDuration += 30 - nextDuration + nextDuration = 30 + } else { + nextDuration = (30 - nextDuration).coerceAtLeast(0) + } } else { if (nextDuration == 0) { if (midiDuration == 0) { @@ -2486,6 +2500,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository } ';' -> { + beatPos = if (beatPos < 15) 15 else if (beatPos < 30) 30 else 45 if ((lastIt == '.' || lastSignificantIt == '.') && lastNoteString == "z" && midiDuration == 0) { pushMidi() lastNoteString = "z" @@ -2493,7 +2508,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository nextDuration = 15 } if (lastSignificantIt == '-') { - midiDuration += 15 - nextDuration + if (nextDuration > 15) { + midiDuration += 15 - nextDuration + } nextDuration = 15 } else { if (nextDuration == 0) {