diff --git a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt index e017e0f..4fd3030 100644 --- a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt +++ b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt @@ -499,7 +499,7 @@ actual class FMediaPlayer actual constructor( val finReg = Regex("""(fine|fin|farany|end)""", RegexOption.IGNORE_CASE) val modulaRegex = Regex("""D(ô|o)?\s*dia\s*(C|Db|D|Eb|E|F|Gb|G|Ab|A|Bb|B)""", RegexOption.IGNORE_CASE) - val tempoRegex = Regex("""^♩\s*=\s*(\d+)""", RegexOption.IGNORE_CASE) + val tempoRegex = Regex("""^(?:♩|P)\s*[:=]\s*(\d+)""", RegexOption.IGNORE_CASE) metadataList.forEach { midiMarker -> val ci = midiMarker.gridIndex ?: 0 val last_grid = sharedScreenModel.getTotalGridCount() diff --git a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt index 2a386c2..619cfea 100644 --- a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt +++ b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt @@ -692,12 +692,12 @@ private suspend fun generatePdfToBytes( drawFermata(cs, colX + colWidth / 2 - 5f, markerY - 2f, 0.3f) } - if (markerText.contains("♩")) { - val textPart = markerText.replace("♩", "BPM") + if (markerText.contains("P:")) { + val textPart = markerText cs.beginText() cs.setFont(italicBoldFont, fontSize) cs.newLineAtOffset(colX, markerY) - cs.setFont(boldFont, fontSize-3f) + cs.setFont(boldFont, fontSize) cs.showText(textPart) cs.endText() } diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/midi/MidiWriterforEXport.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/midi/MidiWriterforEXport.kt index 36a1427..80c105e 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/midi/MidiWriterforEXport.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/midi/MidiWriterforEXport.kt @@ -94,7 +94,7 @@ class MidiWriterforEXport constructor(private val fileRepository: FileRepositor var pendingHairpinStartTick: Long? = null val modulaRegex = Regex("""D(ô|o)?\s*dia\s*(C|Db|D|Eb|E|F|Gb|G|Ab|A|Bb|B)""", RegexOption.IGNORE_CASE) - val tempoRegex = Regex("""^♩\s*=\s*(\d+)""", RegexOption.IGNORE_CASE) + val tempoRegex = Regex("""^(?:♩|P)\s*[:=]\s*(\d+)""", RegexOption.IGNORE_CASE) markers.forEach { midiMarker -> val gridIdx = (midiMarker.gridIndex ?: 0) * 480L diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/PTemplate.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/PTemplate.kt index 2daa9e9..77ebd25 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/PTemplate.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/PTemplate.kt @@ -68,7 +68,7 @@ fun parseMarkers(rawText: String): List { .replace(Regex("""(D\.?S\.?)\s*(al\s*Coda)""", RegexOption.IGNORE_CASE), "D.S.alCoda") val allStaticMarkers = getAllMarker().sortedByDescending { it.length } - val tempoRegex = Regex("""^(♩\s*=\s*\d+)""", RegexOption.IGNORE_CASE) + val tempoRegex = Regex("""^(?:♩|P)\s*[:=]\s*(\d+)""", RegexOption.IGNORE_CASE) val modulaRegex = Regex("""^(D(?:ô|o)?\s*dia\s*(?:C|Db|D|Eb|E|F|Gb|G|Ab|A|Bb|B))""", RegexOption.IGNORE_CASE) val measureRegex = Regex("""^\d+\s*/\s*\d+""") @@ -78,7 +78,8 @@ fun parseMarkers(rawText: String): List { val tempoMatch = tempoRegex.find(remaining) if (tempoMatch != null) { - tokens.add(tempoMatch.value) + val bpm = tempoMatch.groupValues[1] + tokens.add("♩=$bpm") remaining = remaining.substring(tempoMatch.value.length) continue } 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 78c457b..44104ad 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -482,9 +482,13 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository "\${c:$lettre}" } else { markerClean.split(Regex("\\s+")).filter { it.isNotEmpty() }.joinToString(" ") { part -> - when (part) { - "𝄐" -> "\$Q" - else -> "\${$part}" + val trimmed = part.trim() + when { + trimmed == "𝄐" -> "\$Q" + else -> { + val formattedPart = trimmed.replace("♩", "P") + "\${$formattedPart}" + } } } } diff --git a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt index 8216b7c..976f3c5 100644 --- a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt +++ b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt @@ -260,7 +260,7 @@ actual class FMediaPlayer actual constructor( val ritRegex = Regex("""rit\.?|ritard\.?|ritenuto\.?|ritardando""", RegexOption.IGNORE_CASE) val rallRegex = Regex("""rall\.?|rallent\.?|rallentando""", RegexOption.IGNORE_CASE) val modulaRegex = Regex("""D(ô|o)?\s*dia\s*(C|Db|D|Eb|E|F|Gb|G|Ab|A|Bb|B)""", RegexOption.IGNORE_CASE) - val tempoRegex = Regex("""^♩\s*=\s*(\d+)""", RegexOption.IGNORE_CASE) + val tempoRegex = Regex("""^(?:♩|P)\s*[:=]\s*(\d+)""", RegexOption.IGNORE_CASE) metadataList.forEach { midiMarker -> val currentIndex = midiMarker.gridIndex ?: 0 diff --git a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt index c0e4373..895407a 100644 --- a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt +++ b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/pdf/PdfExport.kt @@ -908,18 +908,18 @@ private suspend fun generatePdfToBytes( ) } - if (markerText.contains("♩")) { - val textPart = markerText.replace("♩", "BPM") + if (markerText.contains("P:")) { + val textPart = markerText cs.beginText() cs.setFont(italicBoldFont, fontSize) cs.newLineAtOffset(colX, markerY) - cs.setFont(boldFont, fontSize-3f) + cs.setFont(boldFont, fontSize) cs.showText(textPart) cs.endText() } // marqueur - if (markerText.isNotBlank() && !markerText.contains("𝄐") && !markerText.contains("♩")) { + if (markerText.isNotBlank() && !markerText.contains("𝄐") && !markerText.contains("P:")) { val dsRegex = Regex("""D\.?S\.?""") val dcRegex = Regex("""D\.?C\.?""")