From 38b6e17008e84c162ea025a18e0087ad83e8f14c Mon Sep 17 00:00:00 2001 From: dotmg Date: Sun, 10 May 2026 17:30:53 +0200 Subject: [PATCH] Triolet support for midi generation --- .../composeResources/files/config.json | 2 +- .../composeResources/files/ews-376.txt | 9 +++++++++ .../kotlin/mg/dot/feufaro/solfa/Solfa.kt | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 composeApp/src/commonMain/composeResources/files/ews-376.txt diff --git a/composeApp/src/commonMain/composeResources/files/config.json b/composeApp/src/commonMain/composeResources/files/config.json index 1995db9..8bfa415 100644 --- a/composeApp/src/commonMain/composeResources/files/config.json +++ b/composeApp/src/commonMain/composeResources/files/config.json @@ -2,8 +2,8 @@ "themeMode": "DARK", "fontSize": 18.5, "playlist": [ - "assets://ffpm-617.txt", "assets://a.txt", + "assets://ffpm-617.txt", "assets://ews-127.txt", "assets://ffpm-521.txt", "assets://ews-126.txt", diff --git a/composeApp/src/commonMain/composeResources/files/ews-376.txt b/composeApp/src/commonMain/composeResources/files/ews-376.txt new file mode 100644 index 0000000..a8d3cc1 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/files/ews-376.txt @@ -0,0 +1,9 @@ +M0:|T:What a day of victory|t:EWS 376 When at last we see the King|r:P.M|c:G|m:4/4|a:James Rowe 1865-1933|h:Charles Hutchinson Gabriel 1856-1932|u:https://hymnary.org/hymn/D1916/page/48 +U0:zC:y yy4y yy4y 44ty C/ yyy4 yyy4 y44t yC/ y62tt 624y 62ty (822) yyy4y yy4 y44tyC +N1:drmmmfmmrdddrddl,s,dmRmssrdrmmmfmmrdddrddl,s,ssmdmrdmssssmdsmdlssmfsssmdmmr--drmmmfmmrdddrddl,s,ssmdmrd +N2:s,t,ddddds,s,l,l,l,l,l,l,f,m,s,s,F,F,s,s,s,s,t,ddddds,s,l,l,l,l,l,m,f,s,t,dddl,t,s,s,dt,drddt,dddt,dddrdt,t,dddt,--l,l,dddl,s,S,t,t,l,l,l,l,m,f,s,t,dddt,t,d +N3:mfssllsdrmmffmmddddddrmt,mfssllsdrmmffmdrmfsslsfmmsfmsmffmsffsslsmrsssss--mfsrdddmmmmffmdrmfsFFffm +N4:mrdt,l,f,ddt,l,s,f,r,l,l,f,d,m,s,l,dt,ds,mrdt,l,f,ddt,l,s,f,r,l,l,t,drmmfss,d,dmrdt,dfrmmfrmdl,t,ds,s,m,d,d,s,l,f,dt,l,f,d,m,m,l,s,f,r,l,l,t,drml,l,s,s,d, +E1:When at last we see the King /and His praise in glo_ry sing,/What a day of vic_to_ry that will be!/When we reach the oth_er side /where the faith_ful shall ab_ide,/What a day of vic_to_ry that will be!/${R=}What a day of vic_to_ry, vic_to_ry, vic_to_ry!/What a day of vic_to_ry that will be!/When ho_san_nas glad we sing /in the pa_lace of the King,/What a day of vic_to_ry that will be! +E2:When we walk the streets of gold /with the hap_py saints of old,/What a day of vic_to_ry that will be!/When we join the an_gel-_throng /in the ev_er_last_ing song,/What a day of vic_to_ry that will be! +E3:When with tri_als tru_ly past /we re_ceive the crown at last,/What a day of vic_to_ry that will be!/When be_fore the King we stand /in that ev_er_last_ing land,/What a day of vic_to_ry that will be!/ 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 504df99..a745b92 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -1182,6 +1182,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository var lastNoteString = "" val midiPitch = MidiPitch(voiceNumber) var nextComment: MutableList = mutableListOf() + var trioletCount = -1 + var nextTrioletDuration = 0 fun pushMidi(typeBlock: String = "note") { if (typeBlock == "measure") { val z = midiPitch.copy() @@ -1279,6 +1281,18 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository 'D', 'R', 'F', 'S', 'T', '-', 'Z', 'z' -> { + if (trioletCount == 2) { + trioletCount = 1 + midiDuration = nextTrioletDuration / 2 + nextTrioletDuration = nextTrioletDuration - midiDuration + pushMidi() + nextDuration = nextTrioletDuration + } else if (trioletCount == 1) { + midiDuration = nextDuration + pushMidi() + trioletCount = 0 + nextTrioletDuration = 0 + } var noteString = it.toString().lowercase() if (it == 'D' || it == 'R' || it == 'F' || it == 'S') { noteString += "i" @@ -1328,6 +1342,10 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository '&' -> { commentNumber++ nextComment.add(templateComments[commentNumber]) + if (templateComments[commentNumber] == "\$T") { + nextTrioletDuration = 2 * nextDuration / 3 + trioletCount = 2 + nextDuration = nextDuration - nextTrioletDuration } } } lastIt = it