${R!} stops copying Refrain
This commit is contained in:
parent
4ed0266d7f
commit
a196ed4322
2 changed files with 26 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
"themeMode": "DARK",
|
"themeMode": "DARK",
|
||||||
"fontSize": 18.5,
|
"fontSize": 18.5,
|
||||||
"playlist": [
|
"playlist": [
|
||||||
|
"assets://a.txt",
|
||||||
"assets://ffpm-617.txt",
|
"assets://ffpm-617.txt",
|
||||||
"assets://ews-127.txt",
|
"assets://ews-127.txt",
|
||||||
"assets://ffpm-521.txt",
|
"assets://ffpm-521.txt",
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import mg.dot.feufaro.getConfigDirectoryPath
|
||||||
import mg.dot.feufaro.launchFilePicker
|
import mg.dot.feufaro.launchFilePicker
|
||||||
import mg.dot.feufaro.midi.MidiPitch
|
import mg.dot.feufaro.midi.MidiPitch
|
||||||
import mg.dot.feufaro.midi.MidiWriterKotlin
|
import mg.dot.feufaro.midi.MidiWriterKotlin
|
||||||
import java.io.File
|
import kotlin.math.min
|
||||||
|
|
||||||
//@todo: split voices (ffpm19/ews22) ${S:mfs} in N4:, idem ffpm-212
|
//@todo: split voices (ffpm19/ews22) ${S:mfs} in N4:, idem ffpm-212
|
||||||
//@todo: ffpm-172-2 ${O:1} non fonctionnel
|
//@todo: ffpm-172-2 ${O:1} non fonctionnel
|
||||||
|
|
@ -34,6 +34,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
private val O: MutableMap<Int, MutableList<String>> = mutableMapOf()
|
private val O: MutableMap<Int, MutableList<String>> = mutableMapOf()
|
||||||
private val unparsedNote = mutableListOf<String>()
|
private val unparsedNote = mutableListOf<String>()
|
||||||
private var refrainBeginsAt = -1
|
private var refrainBeginsAt = -1
|
||||||
|
private var refrainEndsAt = -1
|
||||||
|
private var refrainMaxStanza = -1
|
||||||
private var smartLyricsType = "L"
|
private var smartLyricsType = "L"
|
||||||
private val pitches = mutableListOf<MidiPitch>()
|
private val pitches = mutableListOf<MidiPitch>()
|
||||||
|
|
||||||
|
|
@ -48,7 +50,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
val REGEX_TEMPLATE_COMMENT = Regex("(\\$[A-Z]|\\$\\{[^\\}]*\\})")
|
val REGEX_TEMPLATE_COMMENT = Regex("(\\$[A-Z]|\\$\\{[^\\}]*\\})")
|
||||||
val REGEX_REPETITION = Regex("([zwdrmfslt-](?>[',]*))([1-9][0-9]*)", RegexOption.IGNORE_CASE)
|
val REGEX_REPETITION = Regex("([zwdrmfslt-](?>[',]*))([1-9][0-9]*)", RegexOption.IGNORE_CASE)
|
||||||
val REGEX_PARSE_META = Regex("\\|(?=[a-z]:)")
|
val REGEX_PARSE_META = Regex("\\|(?=[a-z]:)")
|
||||||
val REGEX_LYRICS_COMMENT = Regex("\\$\\{([^\\}][^:]*:([^\\}]*))\\}|\\$\\{R!\\}")
|
val REGEX_LYRICS_COMMENT = Regex("\\$\\{([^\\}][^:]*:([^\\}]*))\\}")
|
||||||
val REGEX_LYRICS_REPETITION = Regex("_(\\d+)")
|
val REGEX_LYRICS_REPETITION = Regex("_(\\d+)")
|
||||||
val REGEX_VOWELS_STAGE1 =
|
val REGEX_VOWELS_STAGE1 =
|
||||||
Regex("[aeiouyòàéìỳ](?![,;\\.\\-:!\\?\\}»_\"]*([ aeiouyòàéìỳ/]|_[1-9]))", RegexOption.IGNORE_CASE)
|
Regex("[aeiouyòàéìỳ](?![,;\\.\\-:!\\?\\}»_\"]*([ aeiouyòàéìỳ/]|_[1-9]))", RegexOption.IGNORE_CASE)
|
||||||
|
|
@ -205,6 +207,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
}
|
}
|
||||||
pitches.clear()
|
pitches.clear()
|
||||||
refrainBeginsAt = -1
|
refrainBeginsAt = -1
|
||||||
|
refrainEndsAt = -1
|
||||||
|
refrainMaxStanza = -1
|
||||||
unparsedNote.clear()
|
unparsedNote.clear()
|
||||||
templateString = ""
|
templateString = ""
|
||||||
nextTIndex = -1
|
nextTIndex = -1
|
||||||
|
|
@ -750,6 +754,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadLyrics(stanzaNumber: Int, lyrics: String) {
|
private fun loadLyrics(stanzaNumber: Int, lyrics: String) {
|
||||||
|
defineRefrainMaxStanza(99999)
|
||||||
val overrideIterator: MutableMap<Int, Iterator<String>> = mutableMapOf()
|
val overrideIterator: MutableMap<Int, Iterator<String>> = mutableMapOf()
|
||||||
try {
|
try {
|
||||||
val lyrics = getLyricsComments(lyrics)
|
val lyrics = getLyricsComments(lyrics)
|
||||||
|
|
@ -801,7 +806,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
}
|
}
|
||||||
addLyricsItem(stanzaNumber, i, originalLyrics)
|
addLyricsItem(stanzaNumber, i, originalLyrics)
|
||||||
}
|
}
|
||||||
if (refrainBeginsAt > 0 && stanzaNumber > 1 && !lyrics.contains($$"${R!}")) {
|
if (refrainBeginsAt >= 0 && stanzaNumber > 1) {
|
||||||
copyRefrainToStanza(stanzaNumber)
|
copyRefrainToStanza(stanzaNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -901,10 +906,19 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
|
|
||||||
private fun defineRefrainFrom(tuoNumber: Int) {
|
private fun defineRefrainFrom(tuoNumber: Int) {
|
||||||
refrainBeginsAt = tuoNumber
|
refrainBeginsAt = tuoNumber
|
||||||
|
refrainEndsAt = 99999
|
||||||
|
refrainMaxStanza = 99999
|
||||||
|
}
|
||||||
|
private fun defineRefrainTo(tuoNumber: Int) {
|
||||||
|
refrainEndsAt = tuoNumber
|
||||||
|
}
|
||||||
|
private fun defineRefrainMaxStanza(tuoNumber: Int) {
|
||||||
|
refrainMaxStanza = tuoNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyRefrainToStanza(stanzaNumber: Int) {
|
private fun copyRefrainToStanza(stanzaNumber: Int) {
|
||||||
for (i in refrainBeginsAt..L.size - 1) {
|
val refrainMax = min(min(refrainEndsAt - 1, L.size - 1), refrainMaxStanza - 1)
|
||||||
|
for (i in refrainBeginsAt..refrainMax) {
|
||||||
L[i].setLyrics(stanzaNumber, L[i].getLyrics(1))
|
L[i].setLyrics(stanzaNumber, L[i].getLyrics(1))
|
||||||
L[i].copyAlternativeLyrics(1, stanzaNumber)
|
L[i].copyAlternativeLyrics(1, stanzaNumber)
|
||||||
}
|
}
|
||||||
|
|
@ -920,6 +934,13 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
defineRefrainFrom(i)
|
defineRefrainFrom(i)
|
||||||
}
|
}
|
||||||
lyricsItem.replace($$"${R=}", "")
|
lyricsItem.replace($$"${R=}", "")
|
||||||
|
} else if (lyricsItem.contains($$"${R!}")) {
|
||||||
|
if (stanzaNumber == 1) {
|
||||||
|
defineRefrainTo(i)
|
||||||
|
} else {
|
||||||
|
defineRefrainMaxStanza(i)
|
||||||
|
}
|
||||||
|
lyricsItem.replace($$"${R!}", "")
|
||||||
} else {
|
} else {
|
||||||
lyricsItem
|
lyricsItem
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue