Support "DSFin" marker on MidiPlayer - desktop
This commit is contained in:
parent
3a14870ed3
commit
790ed83ddc
2 changed files with 83 additions and 120 deletions
|
|
@ -487,6 +487,11 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
// val timestamps = _tuoTimestamps.value
|
// val timestamps = _tuoTimestamps.value
|
||||||
val tuos = _tuoList.value.drop(1)
|
val tuos = _tuoList.value.drop(1)
|
||||||
|
|
||||||
|
val hasDCDS = rawList.any { midiMarker ->
|
||||||
|
midiMarker.marker.any { text ->
|
||||||
|
text.contains(Regex("""D\.?C\.?|D\.?S\.?""", RegexOption.IGNORE_CASE))
|
||||||
|
}
|
||||||
|
}
|
||||||
val finalizedList = rawList.map { marker ->
|
val finalizedList = rawList.map { marker ->
|
||||||
val originalMarker = marker.marker
|
val originalMarker = marker.marker
|
||||||
var currentMarker = marker
|
var currentMarker = marker
|
||||||
|
|
@ -499,94 +504,57 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
val isNearEnd = index >= (tuos.size - 2)
|
val isNearEnd = index >= (tuos.size - 2)
|
||||||
// println("MARKERS:> $markerText\n")
|
// println("MARKERS:> $markerText\n")
|
||||||
|
|
||||||
val isDC = markerText.contains(Regex("""D\.?C\.?"""))
|
val isDC = markerText.trim().matches(Regex("""D\.?C\.?"""))
|
||||||
val isDS = markerText.contains(Regex("""D\.?S\.?"""))
|
val isDS = markerText.trim().matches(Regex("""D\.?S\.?"""))
|
||||||
val isFarany = markerText.trim().contains(Regex("""^(fine|fin|farany|end)$""", RegexOption.IGNORE_CASE))
|
val isFarany = markerText.trim().matches(Regex("""^(fine|fin|farany|end)$""", RegexOption.IGNORE_CASE))
|
||||||
|
val isDSFin = markerText.trim().contains(Regex("""D\.?S\.?""", RegexOption.IGNORE_CASE)) && markerText.trim().contains(Regex("""(fine|fin|farany|end)""", RegexOption.IGNORE_CASE))
|
||||||
val isRit = Regex("""rit\.?|ritard\.?|ritenuto\.?|ritardando""", RegexOption.IGNORE_CASE)
|
val isRit = Regex("""rit\.?|ritard\.?|ritenuto\.?|ritardando""", RegexOption.IGNORE_CASE)
|
||||||
val isRall = Regex("""rall\.?|rallent\.?|rallentando""", RegexOption.IGNORE_CASE)
|
val isRall = Regex("""rall\.?|rallent\.?|rallentando""", RegexOption.IGNORE_CASE)
|
||||||
|
|
||||||
if (isFarany) {
|
var searchIndex = index + 1
|
||||||
var forwardIndex = index
|
var lastValidIndex = index
|
||||||
while (forwardIndex < tuos.size) {
|
|
||||||
if (tuos.getOrNull(forwardIndex)?.sep0 == "/") {
|
|
||||||
newGridIndex = forwardIndex - 1
|
|
||||||
newMarkerList.add("Farany_GROUP_PART")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
forwardIndex++
|
|
||||||
}
|
|
||||||
println("Farany finalisé : grille $index → ${forwardIndex - 1}")
|
|
||||||
} else if (isDC) {
|
|
||||||
var found = false
|
|
||||||
var forwardIndex = index
|
|
||||||
while (forwardIndex < tuos.size) {
|
|
||||||
if (tuos.getOrNull(forwardIndex)?.sep0 == "/") {
|
|
||||||
newGridIndex = forwardIndex - 1
|
|
||||||
newMarkerList.add("${markerText.trim()}_GROUP_PART")
|
|
||||||
println("DC gp finalisé grille $newGridIndex")
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
forwardIndex++
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
newMarkerList.add(markerText)
|
|
||||||
}
|
|
||||||
} else if (isDS && isNearEnd) {
|
|
||||||
val currentNote = tuos.getOrNull(index)?.tuNotes?.getOrNull(1)?.toString() ?: ""
|
|
||||||
val nextNote = tuos.getOrNull(index + 1)?.tuNotes?.getOrNull(1)?.toString() ?: ""
|
|
||||||
|
|
||||||
if (currentNote.isBlank() && nextNote.isBlank()) {
|
while (searchIndex < tuos.size && tuos.getOrNull(searchIndex)?.tuNotes?.getOrNull(1)?.toString() == "―") {
|
||||||
var backwardIndex = index - 1
|
lastValidIndex = searchIndex
|
||||||
while (backwardIndex >= 0) {
|
searchIndex++
|
||||||
if (tuos.getOrNull(backwardIndex)?.tuNotes?.getOrNull(1)?.toString()?.isNotBlank() == true) {
|
|
||||||
newGridIndex = backwardIndex
|
|
||||||
newMarkerList.add("${if (markerText.trim() == "DSFin") "DS" else markerText.trim()}_GROUP_PART")
|
|
||||||
println("DS finalisé grille $newGridIndex")
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
backwardIndex--
|
|
||||||
|
val targetIndex = if (lastValidIndex > index) lastValidIndex else index
|
||||||
|
|
||||||
|
when {
|
||||||
|
isDSFin -> {
|
||||||
|
newGridIndex = targetIndex
|
||||||
|
newMarkerList.add("${markerText.trim()}")
|
||||||
}
|
}
|
||||||
|
isFarany -> {
|
||||||
|
newGridIndex = if(hasDCDS) {
|
||||||
|
targetIndex
|
||||||
} else {
|
} else {
|
||||||
var forwardIndex = index
|
index
|
||||||
while (forwardIndex < tuos.size) {
|
|
||||||
if (tuos.getOrNull(forwardIndex)?.sep0 == "/") {
|
|
||||||
newGridIndex = forwardIndex
|
|
||||||
newMarkerList.add("${if (markerText.trim() == "DSFin") "DS" else markerText.trim()}_GROUP_PART")
|
|
||||||
println("DS gp finalisé grille $newGridIndex")
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
forwardIndex++
|
newMarkerList.add("Farany")
|
||||||
}
|
}
|
||||||
|
isDC -> {
|
||||||
|
newGridIndex = targetIndex
|
||||||
|
newMarkerList.add("${markerText.trim()}")
|
||||||
}
|
}
|
||||||
} else if (isRit.containsMatchIn(markerText)) {
|
isDS -> {
|
||||||
var forwardIndex = index + 1
|
newGridIndex = targetIndex
|
||||||
while (forwardIndex < tuos.size) {
|
newMarkerList.add("${markerText.trim()}")
|
||||||
if (tuos.getOrNull(forwardIndex)?.sep0 == "/") {
|
}
|
||||||
currentMarker = currentMarker.copy(lastCallerMarker = forwardIndex - 1)
|
isRit.containsMatchIn(markerText) -> {
|
||||||
|
currentMarker = currentMarker.copy(lastCallerMarker = targetIndex)
|
||||||
newMarkerList.add("Ritenuto")
|
newMarkerList.add("Ritenuto")
|
||||||
break
|
|
||||||
}
|
}
|
||||||
forwardIndex++
|
isRall.containsMatchIn(markerText) -> {
|
||||||
}
|
currentMarker = currentMarker.copy(lastCallerMarker = targetIndex)
|
||||||
println("Rit finalisé : grille $index → ${forwardIndex - 1}")
|
|
||||||
|
|
||||||
} else if (isRall.containsMatchIn(markerText)) {
|
|
||||||
var forwardIndex = index + 1
|
|
||||||
while (forwardIndex < tuos.size) {
|
|
||||||
if (tuos.getOrNull(forwardIndex)?.sep0 == "/") {
|
|
||||||
currentMarker = currentMarker.copy(lastCallerMarker = forwardIndex - 1)
|
|
||||||
newMarkerList.add("Rallentando")
|
newMarkerList.add("Rallentando")
|
||||||
break
|
|
||||||
}
|
}
|
||||||
forwardIndex++
|
else -> {
|
||||||
}
|
|
||||||
println("Rall finalisé : grille $index → ${forwardIndex - 1}")
|
|
||||||
|
|
||||||
} else {
|
|
||||||
newMarkerList.add(markerText)
|
newMarkerList.add(markerText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
currentMarker.copy(
|
currentMarker.copy(
|
||||||
gridIndex = newGridIndex,
|
gridIndex = newGridIndex,
|
||||||
marker = newMarkerList
|
marker = newMarkerList
|
||||||
|
|
@ -760,7 +728,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
fun setStanza(theStanza: Int) {
|
fun setStanza(theStanza: Int) {
|
||||||
try {
|
try {
|
||||||
_stanza.value = theStanza
|
_stanza.value = theStanza
|
||||||
_showMidiCtrl.value = false
|
_mediaPlayer?.syncNavigationMonitor(this)
|
||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
_stanza.value = 0
|
_stanza.value = 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -267,9 +267,37 @@ actual class FMediaPlayer actual constructor(
|
||||||
val dcGPattern = Regex("""D\.?C\.?_GROUP_PART""")
|
val dcGPattern = Regex("""D\.?C\.?_GROUP_PART""")
|
||||||
val finReg = Regex("""(fine|fin|farany|end)""", RegexOption.IGNORE_CASE)
|
val finReg = Regex("""(fine|fin|farany|end)""", RegexOption.IGNORE_CASE)
|
||||||
|
|
||||||
markerList.forEach { marker ->
|
var i = 0
|
||||||
|
while(i < markerList.size) {
|
||||||
|
val marker = markerList[i]
|
||||||
val mTrim = marker.trim()
|
val mTrim = marker.trim()
|
||||||
|
val nextTrim = markerList.getOrNull(i + 1)?.trim() ?: ""
|
||||||
|
|
||||||
|
val hasDs = dsRegex.containsMatchIn(mTrim)
|
||||||
|
val hasDc = dcRegex.containsMatchIn(mTrim)
|
||||||
|
val hasFin = finReg.containsMatchIn(mTrim)
|
||||||
|
|
||||||
|
val isDsFin = (dsRegex.containsMatchIn(mTrim) && finReg.containsMatchIn(nextTrim))
|
||||||
|
val isDcFin = (dcRegex.containsMatchIn(mTrim) && finReg.containsMatchIn(nextTrim))
|
||||||
|
|
||||||
when {
|
when {
|
||||||
|
//DSFin
|
||||||
|
isDsFin || isDcFin -> {
|
||||||
|
val target = if (lastSegno > 0) lastSegno else 0
|
||||||
|
val combinedMarker = "$mTrim$nextTrim"
|
||||||
|
|
||||||
|
navigationSteps.add(
|
||||||
|
NavigationStep(
|
||||||
|
marker = combinedMarker,
|
||||||
|
gridIndex = currentIndex,
|
||||||
|
targetGrid = target
|
||||||
|
)
|
||||||
|
)
|
||||||
|
println("Lien $combinedMarker créé : Saut à $currentIndex vers Segno $target")
|
||||||
|
|
||||||
|
i += 2
|
||||||
|
continue
|
||||||
|
}
|
||||||
// segno
|
// segno
|
||||||
marker.contains("$") -> {
|
marker.contains("$") -> {
|
||||||
lastSegno = currentIndex
|
lastSegno = currentIndex
|
||||||
|
|
@ -304,6 +332,7 @@ actual class FMediaPlayer actual constructor(
|
||||||
)
|
)
|
||||||
println("Ritardando mémorisé à grille $currentIndex jusqu'à $endGrid")
|
println("Ritardando mémorisé à grille $currentIndex jusqu'à $endGrid")
|
||||||
}
|
}
|
||||||
|
//Rall
|
||||||
rallRegex.containsMatchIn(marker) -> {
|
rallRegex.containsMatchIn(marker) -> {
|
||||||
val endGrid = last_grid
|
val endGrid = last_grid
|
||||||
|
|
||||||
|
|
@ -320,22 +349,7 @@ actual class FMediaPlayer actual constructor(
|
||||||
println("Rallentando mémorisé à grille $currentIndex jusqu'à $endGrid")
|
println("Rallentando mémorisé à grille $currentIndex jusqu'à $endGrid")
|
||||||
}
|
}
|
||||||
//DS
|
//DS
|
||||||
dsGPattern.matches(mTrim) -> {
|
dsRegex.matches(mTrim) -> {
|
||||||
val target = if (lastSegno > 0) lastSegno else 0
|
|
||||||
var indx = if ((last_grid - currentIndex) <= 0) {
|
|
||||||
currentIndex - 1
|
|
||||||
} else currentIndex
|
|
||||||
navigationSteps.add(
|
|
||||||
NavigationStep(
|
|
||||||
marker,
|
|
||||||
gridIndex = indx,
|
|
||||||
targetGrid = target,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
println("Lien créé : $marker à grille n° $indx vers cible $target ........")
|
|
||||||
}
|
|
||||||
|
|
||||||
dsRegex.matches(mTrim) || marker == "DSFin" -> {
|
|
||||||
val target = if (lastSegno > 0) lastSegno else 0
|
val target = if (lastSegno > 0) lastSegno else 0
|
||||||
|
|
||||||
navigationSteps.add(
|
navigationSteps.add(
|
||||||
|
|
@ -347,24 +361,8 @@ actual class FMediaPlayer actual constructor(
|
||||||
)
|
)
|
||||||
println("Lien DS créé : Saut immédiat à ${midiMarker.gridIndex} vers Segno $target")
|
println("Lien DS créé : Saut immédiat à ${midiMarker.gridIndex} vers Segno $target")
|
||||||
}
|
}
|
||||||
|
|
||||||
//DC
|
//DC
|
||||||
dcGPattern.matches(mTrim) -> {
|
dcRegex.matches(mTrim) -> {
|
||||||
val indx = if ((last_grid - currentIndex) <= 0) {
|
|
||||||
currentIndex - 1
|
|
||||||
} else currentIndex
|
|
||||||
// println("monn index est $indx car dernier est $last_grid et curr $currentIndex")
|
|
||||||
navigationSteps.add(
|
|
||||||
NavigationStep(
|
|
||||||
marker,
|
|
||||||
indx,
|
|
||||||
targetGrid = 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
println("Lien créé : $marker à $indx vers cible 0 ")
|
|
||||||
}
|
|
||||||
|
|
||||||
(dcRegex.matches(mTrim) && !marker.contains("DC_GROUP_PART")) -> {
|
|
||||||
println("dernier grille $last_grid")
|
println("dernier grille $last_grid")
|
||||||
var indx = if ((last_grid - currentIndex) <= 0) {
|
var indx = if ((last_grid - currentIndex) <= 0) {
|
||||||
currentIndex /*- 1*/
|
currentIndex /*- 1*/
|
||||||
|
|
@ -378,7 +376,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
)
|
)
|
||||||
println("Lien DC créé : $marker à $indx vers le début")
|
println("Lien DC créé : $marker à $indx vers le début")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Farany
|
// Farany
|
||||||
finReg.containsMatchIn(mTrim) -> {
|
finReg.containsMatchIn(mTrim) -> {
|
||||||
val hasDcAfter = metadataList.any { m ->
|
val hasDcAfter = metadataList.any { m ->
|
||||||
|
|
@ -389,10 +386,7 @@ actual class FMediaPlayer actual constructor(
|
||||||
)
|
)
|
||||||
|
|
||||||
val hasMarker = m.marker.any { mk ->
|
val hasMarker = m.marker.any { mk ->
|
||||||
val value = mk.trim()
|
dcRegex.matches(mk.trim())
|
||||||
val ok = dcGPattern.matches(value) || dcRegex.matches(value)
|
|
||||||
println("marker=$value -> $ok")
|
|
||||||
ok
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println("after=$after, hasMarker=$hasMarker, result=${after && hasMarker}")
|
println("after=$after, hasMarker=$hasMarker, result=${after && hasMarker}")
|
||||||
|
|
@ -505,6 +499,7 @@ actual class FMediaPlayer actual constructor(
|
||||||
println("NavigationStep HairPin '$symbol' : $currentIndex→${pair.endGrid} | ${fromFactor})→${toFactor})")
|
println("NavigationStep HairPin '$symbol' : $currentIndex→${pair.endGrid} | ${fromFactor})→${toFactor})")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue