Fix bug midi duration when ",D|)" and ":(D,D.D,D|)" note ":m,:f,;-.-;--l,:"

This commit is contained in:
Hasinjato 2026-11-24 14:45:35 +03:00
parent ffc525fe27
commit 1aa11747b5

View file

@ -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 == '-') {
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 == '-') {
if (nextDuration > 15) {
midiDuration += 15 - nextDuration
}
nextDuration = 15
} else {
if (nextDuration == 0) {