diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 0504e64..c646009 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -56,7 +56,7 @@ kotlin { implementation(libs.bundles.voyager) implementation(libs.cafe.voyager.koin) implementation(libs.androidx.material.icons.extended) - + implementation(kotlin("stdlib-jdk8")) } commonTest.dependencies { implementation(libs.kotlin.test) diff --git a/composeApp/src/commonMain/composeResources/files/config.json b/composeApp/src/commonMain/composeResources/files/config.json index c09f282..eee531d 100644 --- a/composeApp/src/commonMain/composeResources/files/config.json +++ b/composeApp/src/commonMain/composeResources/files/config.json @@ -2,22 +2,22 @@ "themeMode": "DARK", "fontSize": 18.5, "playlist": [ - "assets://ffpm-16.txt", + "assets://ffpm-33.txt", + "assets://ff-8.txt", + "assets://ffpm-444-2.txt", + "assets://ffpm-760.txt", + "assets://ews-456.txt", + "assets://ffpm-51.txt", "assets://ffpm-428.txt", "assets://ffpm-449.txt", "assets://ffpm-489.txt", "assets://ffpm-21.txt", "assets://ffpm-179.txt", "assets://ff-33.txt", - "assets://ffpm-297.txt", - "assets://ffpm-33.txt", - "assets://ff-8.txt", - "assets://ffpm-444-2.txt", - "assets://ffpm-760.txt", - "assets://ews-456.txt" + "assets://ffpm-297.txt" ], "buttonContainerColorHex": "#FFFF8855", "buttonContentColorHex": "#FF000055", "buttonDisabledContainerColorHex": "#FF888888", "buttonDisabledContentColorHex": "#FF5555AA" -} \ No newline at end of file +} diff --git a/composeApp/src/commonMain/composeResources/files/ffpm-33.txt b/composeApp/src/commonMain/composeResources/files/ffpm-33.txt index b68e93e..0f9e81e 100644 --- a/composeApp/src/commonMain/composeResources/files/ffpm-33.txt +++ b/composeApp/src/commonMain/composeResources/files/ffpm-33.txt @@ -5,5 +5,5 @@ N2:#m,dsdsdtsT/lSlllfm/ssstddd/dtssFs---/dsdsdtsT/lSltlfm/ssstddd/ddsdts N3:#t,smlmsfm-/d7/dtdrmlm/ssmrdr---/smlmsfm-/d7/dtdrmlm/lsmsfm N4:#d,d4ssd-/f6d/mrmsd'lm/dt,drrsfmr/d4ssd-/f6d/mrmsd'lm/fssss,d Y1:Tompo ô, tsy takatray/Ny hasoan’ny antranao;/Zava-mahagaga\ anay/Ny fiti_avanao./He, mpanota izahay/Nefa haso_avinao;/Avotr’aina azonay;/Misaotra no atao. -Y2:Tompo ô, Mpanjakanay/Fatratra ny herinao/Ts’isy zavatra izay/Ma\hasakana Anao!/Nefa mora fo Hianao/Fa mandefitra\ aminay,/Ko_a dia misaotra\ Anao/Fa afaka izahay. +Y2:Tompo ô, Mpanjakanay/Fatratra ny herinao/Ts’isy zavatra izay/Ma\hasakana Anao!/Nefa mora fo Hianao/Fa mandefitra\ aminay,/Ko_a dia misaotra\ Anao/Fa afaka\ izahay. Y3:Tompo Andriamanitray,/Avy izahay izao/Raiso ny fi_ainanay;/Anao, ka anjakao./Tompo ô, tsy takatray/Ny hasoan’ny antranao;/Zava-mahagaga\ anay/Ny fiti_avanao. diff --git a/composeApp/src/commonMain/composeResources/files/ffpm-428.txt b/composeApp/src/commonMain/composeResources/files/ffpm-428.txt index c244bd0..7b1f65e 100644 --- a/composeApp/src/commonMain/composeResources/files/ffpm-428.txt +++ b/composeApp/src/commonMain/composeResources/files/ffpm-428.txt @@ -4,7 +4,7 @@ N1:s#s,mmdssSldfrmdd #l,sFl'smdlltdmrlr sm--dd--dfmrfm #t,sllllmmrdr smdddfmrfm N2:#s,sdddssSldltdssdtrdtslltldtlt zzdd--ssTldlrdrdlll ddtlttds sTldtrdslsltdtlld-tt s N3:mssmmmmfmrssmmmRfmsm mmsFFFFszzsm--mmmdmrs ssmDDmFFFFsrsm mmdmrssmfrmfsrmrslsfm N4:#r,dddddddfsltd-d d6 llmr4szzdd--d,d,sfslt dtllllr4stddd dsfsltdmfsltdtlfs-ssd -Y1:Reko i\zao ry Tompo izany antsonao,/Mi_antso izany mpanompo mba ho irakao!${R=}Inty,_3inty_3inty a\ho Jeso/Inty, inty, iraho a\ho Jeso/Ekeko re ny\ ho miaramilanao/Ho vonona hanao ny sitrakao, ka ira\ho! +Y1:Reko i\zao ry Tompo izany antsonao,/Mi_antso izany mpanompo mba ho irakao!${R=}Inty,_2inty_2inty a\ho Jeso/Inty, inty, iraho a\ho Jeso/Ekeko re ny\ ho miaramilanao/Ho vonona hanao ny sitrakao, ka ira\ho! Y2:O di_ovy Tompo izany molotro/Ka ny fo madio hanompo no atolotro! Y3:Tsy hande\ha irery fa hiaraka\ Aminao/Ka dia mba ome_o ny hery sy Fanahinao! -Y4:Reko i\zao ny toky hoe: «Momba a\hy Ianao »/Ry Jesosy Tompo sy Zoky, vonona aho izao! +Y4:Reko i\zao ny toky hoe: «Momba a\hy Ianao»/Ry Jesosy Tompo sy Zoky, vonona\ a\ho izao! diff --git a/composeApp/src/commonMain/composeResources/files/ffpm-49-1.txt b/composeApp/src/commonMain/composeResources/files/ffpm-49-1.txt new file mode 100644 index 0000000..b8593ae --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/ffpm-49-1.txt @@ -0,0 +1,10 @@ +M0:|c:C|m:4/4|r:8.7.8.7.4.7.|t:FFPM 49 : Mba jereo ny Tompontsika|a:C. Wesley 1707-1788 Nad. J. Richardson, 1844-1922 (dikany malalaka)|h:H. Smart, 1813-1879 +U0:z0:44446244/4444 448/ 444(22)/6244/444(22)448/62446244/44(22)(22)4(22)8 +N1:#msmdsm'rds/llsdsfm/smds-m'rdt/dtltdtls/#srrtsmrdl/fmr-d-dt-d +N2:#t,mdsms4/d4rtd/mdssfmfmm/m4-sFs/s5mff/lsf-mfs-fm +N3:#sdssddtdd/ldslsss/ddss-dtlS/lSmrdrdt/ttrtdTld/rsltd-rr-d +N4:ddmdsfmm/#s,ffmltsd/d's'mmrdrmm/l'mdl-rrs/s'4ddff/rmf#dsl-ss,-d +Y1:Mba jereo ny Tompontsika/Avy ao an-danitra/Indro avy amin-kery/Ao amin’ny rahona./${R=}Halelo_ia! Halelo_ia!/Ambarao ny heriny. +Y2:‘Zay rehetra fahavalo/Efa resiny tokoa;/Mifali_a, ry anjely!/Mihobia, ry olona! +Y3:Fony mbola teto Izy,/Satro-tsilo nentiny;/‘Zao ny satro-bolamena/Mendrika ny lohany; +Y4:Vo_a_eso mafy Izy./Be ny fahori_any/Fa izao, asandratra\ Izy/Ambarao ny hajany!/Ao amin’ny rahona. diff --git a/composeApp/src/commonMain/composeResources/files/ffpm-49-2.txt b/composeApp/src/commonMain/composeResources/files/ffpm-49-2.txt new file mode 100644 index 0000000..8c1930a --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/ffpm-49-2.txt @@ -0,0 +1,10 @@ +M0:|c:Ab|m:4/4 Moderato|r:8.7.8.7.4.7.|t:FFPM 49 : Mba jereo ny Tompontsika|a:C. Wesley 1707-1788 Nad. J. Richardson, 1844-1922 (dikany malalaka)|h:Ch. Rasoanaivo 1876-1966 +U0:zC:y 6244 48/y 6244 C/y 6244 48/y 6244 C/y 4yyy 46z2/y 4yyy 48/y 4yyy 46z2/y 6244 C +N1:#m,dddslsfm/mmddttl/#s,ssdrmfs'm/mmrdtls/ssd--d-d4/ssr--r-r3s/ssm#d--f-ssls/ffmmrrd +N2:#d,m4fmrd/ddllSSl/#r,ssstdtdd/ddsssFs/z3ssllssls/z3ssFFl3s/z3TTllTTld/ttdds3 +N3:#l,d6td/ddmmrrd/ffms5/s3mrdt/z3mmffmmfm/z3ttlldddt/z3ssffmmfs/s4ffm +N4:#d,d8/ddllmml/#s,ttdsdrmd/ddtlrr,s/z3d8/z3ssr,5sz3/d6fm/rrdm,ssd +Y1:Mba jereo ny Tompontsika/Avy ao an-danitra/Indro avy amin-kery/Ao amin’ny rahona./${R=}Halelo_3ia!_2Halelo_ia!_Halelo_3ia!_2Halelo_ia!_Halelo_3ia!_2Halelo_ia!_/Ambarao ny heriny. +Y2:‘Zay rehetra fahavalo/Efa resiny tokoa;/Mifali_a, ry anjely!/Mihobia, ry olona! +Y3:Fony mbola teto Izy,/Satro-tsilo nentiny;/‘Zao ny satro-bolamena/Mendrika ny lohany; +Y4:Vo_a_eso mafy Izy./Be ny fahori_any/Fa izao, asandratra\ Izy/Ambarao ny hajany!/Ao amin’ny rahona. diff --git a/composeApp/src/commonMain/composeResources/files/ffpm-51.txt b/composeApp/src/commonMain/composeResources/files/ffpm-51.txt new file mode 100644 index 0000000..b63135b --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/ffpm-51.txt @@ -0,0 +1,11 @@ +M0:|c:C|m:6/4|r:P.M.|t:FFPM 51 Raha tonga anio ny Tompo|a:Ramasitera 1881-1979|h:Ira D. Sankey 1840-1908 +U0:z0:8484 (44)484/ 8484 84C/ 8484 (44)484/ (44)484 (44)4C/ 84(44)4 84(84)/ 84(44)4 84(84)/ 8484 84(44)4/ 8484 (44)4C +N1:#m mfsssltdd/rdtlsr,m/ mfsssltdd/ rdlsdtdrd/ rdtltdlsd/ rdtltdFsf/ mfsm'rdltd/ ssldtdrd +N2:#t,drmmf-sss/ ffffmtd/ drmmf-ssm/ f-fmmrmfm/ fmf-rmfm-/ fmf-rmrr-/ drmsfff-f/ smdrrmfm +N3:#s ssddtdrdd/ l3ds3/ ssddtdrdd/ l-ddss-ss/ tdrds3ds/ tdrdssdt-/ ssdTlldSl/ dddls-td +N4:d4s-fmm/ f4ss, d/d4s-fmd/f-fdds-s,d/ s3-sd3-/ s3-sdrs,-/ d4f3-f/ mdfrs-s,d +Y1:Raha tonga\ anio ny Tompo/Amin-kery lehibe,/Ka arahin’ny mpanompo/Sy anjely maro be!${R=}Moa ho faly hi_anao/Moa ho faly hi_anao/Ka hidera ny Mpamonjy/I\zay nanavotra\ aina\ anao ? +Y2:He, ho simba sy ho rava/I\zao rehetra àry\ izao!/Ka hifankahita tava/Ny natao sy ny Mpanao/Fiv : Moa ho faly hianao sns… +Y3:Maso maro no hijery/I\lay nijaly fahizay,/Fa ny mino Azy\ ihany/No ho faly ra\hatrizay !/Fiv : Moa ho faly hianao sns… +Y4:Re\hefa tonga re ny Tompo/Mba hitsara\ izay natao,/Hitomany ny tsy mino/Fa hanatrika\ Azy ao !/Fiv : Moa ho faly hianao sns… +Y5:O, avi_a re ry Tompo/Mba hanjaka aminay!/Hahatonga\ anay mpanompo/Hiara-paly Aminao!/${R!}O Avi_a, ô avia, O Avi_a, ô avia,/Fa ny olonao rehetra/Dia maniry\ indrindra\ Anao! diff --git a/composeApp/src/commonMain/composeResources/files/timepart.xsl b/composeApp/src/commonMain/composeResources/files/timepart.xsl new file mode 100644 index 0000000..d1571ab --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/timepart.xsl @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt index 1345d1a..0fd4aca 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/MusicXML.kt @@ -168,7 +168,6 @@ class MusicXML(private val fileRepository: FileRepository) { } val duration = noteNode.duration // 8 === type==half val voiceNumber = 2 - ((noteNode.voice ?: 1) % 2) - noteNode.lyric.forEach { } // todo number/syllabic/text val chord = noteNode.chord // !null = accord (same note) if (chord == null) { voiceAlter = 0 @@ -195,6 +194,9 @@ class MusicXML(private val fileRepository: FileRepository) { else -> "z" } solfaXML.addNote(voiceNumber+voiceAlter, timePointer, duration ?: 0, nextNote, numPart, beam, dollarMarkers) + noteNode.lyric.forEach { + solfaXML.addLyrics(timePointer, it) + } // todo number/syllabic/text dollarMarkers = mutableListOf() /*noteNode.notations?.forEach {notationsNode -> }*/ diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXML.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXML.kt index 141c86c..889628e 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXML.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXML.kt @@ -5,7 +5,7 @@ class SolfaXML { private var meta: MutableMap = mutableMapOf() var tuo: MutableList = mutableListOf() var currentKey = "C" - var curBeam: MXBeam? = null + var curBeam: Pair = Pair(-1,null) var curMarkers: MutableList = mutableListOf() var startTuplet = false fun setMeta(key: String, value: String?) { @@ -36,38 +36,48 @@ class SolfaXML { addTuo(new) return new } - fun addTuo(newTuo: SolfaXMLTuo) { - if (curBeam != null) { - if (curBeam?.content == "begin") { - newTuo.addMarker("(") + fun applyBeam(tuo: SolfaXMLTuo) { + if (curBeam.second != null) { + if (curBeam.second?.content == "begin") { + tuo.addMarker(curBeam.first, "(") } - if (curBeam?.content == "end") { - newTuo.addMarker(")") + if (curBeam.second?.content == "end") { + tuo.addMarker(curBeam.first, ")") } if (startTuplet) { - newTuo.addMarker("t") + tuo.addMarker(curBeam.first, "t") startTuplet = false } + curBeam = Pair(-1, null) } if (curMarkers.isNotEmpty()) { curMarkers.forEach { - newTuo.addMarker("\\$\\{$it\\}") + tuo.addMarker(curBeam.first,"\\$\\{$it\\}") } + curMarkers = mutableListOf() } - curBeam = null - curMarkers = mutableListOf() + } + fun addTuo(newTuo: SolfaXMLTuo) { + applyBeam(newTuo) tuo.add(newTuo) } + fun editTuoNote(tuo: SolfaXMLTuo, voiceNumber: Int, note: String) { + tuo.setNote(voiceNumber, note) + applyBeam(tuo) + } fun addNote(voiceNumberIn: Int, timePointer: Int, duration: Int, note: String, numPart: Int? = 1, beam: MXBeam? = null, dollarMarkers: MutableList = mutableListOf()) { - curBeam = beam - if (curBeam != null) { - println(curBeam) + if (duration == 0) { + return + } + val voiceNumber = 2 * ((numPart ?: 1) - 1) + (2 - (voiceNumberIn % 2)) + curBeam = Pair(voiceNumber, beam) + if (curBeam.second != null) { + println("$timePointer $curBeam") } curMarkers = dollarMarkers val tuoEdit: SolfaXMLTuo = tuo.find { foundTuo -> timePointer >= foundTuo.timeLapse && timePointer < (foundTuo.timeLapse + foundTuo.duration) } ?: newTuo(timePointer, duration) - val voiceNumber = 2 * ((numPart ?: 1) - 1) + (2 - (voiceNumberIn % 2)) val lapse1 = tuoEdit.timeLapse val lapse2 = timePointer val lapse3 = timePointer + duration @@ -81,10 +91,7 @@ class SolfaXML { if (duration1 > 0) { val newTuo = tuoEdit.clone(lapse1, duration1) addTuo(newTuo) - } - if (duration3 > 0) { - val newTuo = tuoEdit.clone(lapse3, duration3, newNote = "+") - addTuo(newTuo) + tuoEdit.resetMarkers() } if (duration2 > 0) { if (duration3 > 0) { @@ -92,15 +99,27 @@ class SolfaXML { } if (duration1 > 0) { tuoEdit.oneNote.forEachIndexed { itVoice, itNote -> - tuoEdit.setNote(itVoice, "+") + editTuoNote(tuoEdit, itVoice, "+") } } - tuoEdit.setNote(voiceNumber, note) + editTuoNote(tuoEdit, voiceNumber, note) + } + if (duration3 > 0) { + val newTuo = tuoEdit.clone(lapse3, duration3, newNote = "+") + newTuo.resetMarkers() + addTuo(newTuo) } if (duration4 > 0) { + println("addNote recursion") addNote(voiceNumber, lapse4, duration4, "+", numPart) } } + fun addLyrics(timePointer: Int, lyric: MXLyric) { + val tuoEdit: SolfaXMLTuo? = tuo.find { foundTuo -> + timePointer == foundTuo.timeLapse + } + tuoEdit?.addLyrics(lyric) + } fun toSolfa(measureLength: Int, firstMeasureLength: Int) { val metaString = "M0:|" + meta.map { (key, value) -> "$key:" + value.replace('|', '!') @@ -121,6 +140,27 @@ class SolfaXML { uString += ":" println(metaString) + var curTimeLapse = 0 + val tuoIterator = tuo.iterator() + while (tuoIterator.hasNext()) { + val currentTuo = tuoIterator.next() + var tuoSelect: SolfaXMLTuo? = currentTuo + while (currentTuo.timeLapse >= curTimeLapse) { + if (currentTuo.timeLapse > curTimeLapse) { + tuoSelect = tuo.find { foundTuo -> + foundTuo.timeLapse == curTimeLapse + } + if (tuoSelect == null) { + curTimeLapse ++ + break + } + } + if (tuoSelect!!.duration in (0..32)) { + uString += letters[tuoSelect.duration] + } + curTimeLapse += tuoSelect.duration + } + } println(uString) } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXMLTuo.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXMLTuo.kt index bd051dd..5de22c5 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXMLTuo.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/musicXML/SolfaXMLTuo.kt @@ -3,12 +3,18 @@ package mg.dot.feufaro.musicXML data class SolfaXMLTuo ( var timeLapse: Int = 0, var duration: Int = 0, - var markers: MutableList = mutableListOf(), + var markers: MutableList> = mutableListOf(), var oneNote: MutableList = mutableListOf(), val lyrics: MutableList = mutableListOf() ) { - fun addMarker(marker: String) { - markers += marker + fun resetMarkers() { + markers = mutableListOf() + } + fun addMarker(voiceNumber: Int, marker: String) { + while (markers.size <= voiceNumber) { + markers.add(mutableListOf()) + } + markers[voiceNumber].add(marker) } fun setTime(newTimeLapse: Int?, newDuration: Int?): SolfaXMLTuo { if (newTimeLapse != null) timeLapse = newTimeLapse @@ -28,7 +34,7 @@ data class SolfaXMLTuo ( fun clone( timeLapse: Int = this.timeLapse, duration: Int = this.duration, - markers: MutableList = this.markers.toMutableList(), + markers: MutableList> = this.markers.toMutableList(), oneNote: MutableList = this.oneNote.toMutableList(), newNote: String? = null ): SolfaXMLTuo { @@ -42,10 +48,13 @@ data class SolfaXMLTuo ( } fun addLyrics(mxLyrics: MXLyric) { val number = mxLyrics.number ?: -1 - val text = mxLyrics.text ?: "" + var text = mxLyrics.text ?: "" while(lyrics.size <= number) { lyrics.add(lyrics.size, "") } + if (mxLyrics.syllabic in listOf("begin", "middle")) { + text += "-" + } lyrics[number] = text } } \ No newline at end of file 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 26bf1bd..d784476 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -23,13 +23,12 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository val REGEX_TEMPLATE_COMMENT = Regex("(\\$[A-Z]|\\$\\{[^\\}]*\\})") val REGEX_REPETITION = Regex("([zdrmfslt-](?>[',]*))([1-9][0-9]*)", RegexOption.IGNORE_CASE) val REGEX_PARSE_META = Regex("\\|(?=[a-z]:)") - val REGEX_LYRICS_COMMENT = Regex("\\$\\{([^\\}]:[^\\}]*)\\}") + val REGEX_LYRICS_COMMENT = Regex("\\$\\{([^\\}]:[^\\}]*)\\}|\\$\\{R!\\}") val REGEX_LYRICS_REPETITION = Regex("_(\\d)") - val REGEX_VOWELS_STAGE1 = Regex("[aeiouyòàéỳ,;\\.\\-:!\\)](?![ aeiouyòàéỳ,;\\.\\-:!\\)])", RegexOption.IGNORE_CASE) - val REGEX_VOWELS_STAGE2 = Regex("([aeiouyòàéỳ,;\\.\\-:!])__", RegexOption.IGNORE_CASE) + val REGEX_VOWELS_STAGE1 = Regex("[aeiouyòàéỳ](?![,;\\.\\-:!\\?\\}»_]*([ aeiouyòàéỳ/]|_[1-9]))", RegexOption.IGNORE_CASE) + val REGEX_VOWELS_STAGE2 = Regex("(?<=[aeiouyòàéỳ])_([,;\\.\\-:!\\?\\}»_]+)", RegexOption.IGNORE_CASE) val REGEX_VOWELS_STAGE3 = Regex("_([\\?\\!:,;\\.»\\)]+)") val REGEX_MALAGASY_MN = Regex("([aeio])_([nm])([tdjkbp])") - val REGEX_MALAGASY_MN_DASHED = Regex("([aeio][nm])\\-([tdjkbp])") val REGEX_MALAGASY_MN_STAGE2 = Regex("_([mn])-") } var nextTIndex: Int = -1 @@ -118,6 +117,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository T.clear() N.clear() L.clear() + refrainBeginsAt = -1 unparsedNote.clear() templateString = "" nextTIndex = -1 @@ -417,7 +417,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository private fun loadL(stanzaNumber: Int, lyrics: String) { try { getLyricsComments(lyrics) - var loadedLyrics = lyrics.replace(REGEX_LYRICS_COMMENT, "") + val loadedLyrics = lyrics.replace(REGEX_LYRICS_COMMENT, "") .replace(REGEX_LYRICS_REPETITION) { matchResult -> val repeating = matchResult.destructured.match.groupValues[1] "_".repeat(repeating.toString().toInt()) @@ -428,7 +428,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository arrayLyrics.forEachIndexed { i, lyricsItem -> addLyricsItem(stanzaNumber, i, lyricsItem) } - if (refrainBeginsAt > 0 && stanzaNumber > 1) { + if (refrainBeginsAt > 0 && stanzaNumber > 1 && !lyrics.contains($$"${R!}")) { copyRefrainToStanza(stanzaNumber) } @@ -451,14 +451,19 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository if (stanzaNumber > sharedScreenModel.nbStanzas.value) { sharedScreenModel.setNbStanzas(stanzaNumber) } + lyricsComment.clear() } // loadY is a smart lyrics parser for Malagasy language private fun loadY(intKey: Int, lyrics: String) { + lyricsComment.clear() val loadedLyrics = lyrics - .replace(REGEX_MALAGASY_MN_DASHED, "$1-\\\\$2") + .also { println(it)} .replace(REGEX_VOWELS_STAGE1, "$0_") + .also { println(it)} .replace(REGEX_VOWELS_STAGE2, "$1_") + .also { println(it)} .replace(REGEX_VOWELS_STAGE3, "$1_") + .also { println(it)} .replace(" ", " _") .replace("_\\ _", " ") .replace("_\\", "") @@ -468,7 +473,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository .replace(REGEX_MALAGASY_MN_STAGE2, "$1-_") .replace("_n'", "n'_") getLyricsComments(loadedLyrics) - loadL(intKey, loadedLyrics.replace(REGEX_LYRICS_COMMENT, "")) + loadL(intKey, loadedLyrics) } // loadE is a smart Lyrics parser for English language private fun loadE(intKey: Int, lyrics: String) {