Recompute bar separators in ParseULine
This commit is contained in:
parent
c362cb42da
commit
0efed1f5af
1 changed files with 23 additions and 19 deletions
|
|
@ -2,6 +2,7 @@ package mg.dot.feufaro.solfa
|
|||
|
||||
class ParseULine (var line: String, var measure: Int) {
|
||||
private var cursorX = 0
|
||||
private var measureOrigin = 0
|
||||
var parsedString = ""
|
||||
private var afterDollar = false
|
||||
private var inComment = false
|
||||
|
|
@ -18,6 +19,21 @@ class ParseULine (var line: String, var measure: Int) {
|
|||
var blankDuration: Int = 0
|
||||
}
|
||||
|
||||
private fun separatorAt(position: Int): Char {
|
||||
val bar: Int = ((position - measureOrigin) / 4) % measure
|
||||
var replacement = ':'
|
||||
if( (bar == 2 && measure == 4 )
|
||||
|| (bar == 3 && measure in listOf(6, 9, 12))
|
||||
|| (bar in listOf(6, 9) && measure in listOf(9, 12)))
|
||||
{
|
||||
replacement = '!'
|
||||
}
|
||||
if (bar == 0) {
|
||||
replacement = '|'
|
||||
}
|
||||
return replacement
|
||||
}
|
||||
|
||||
fun parsed() : String {
|
||||
val matchResult = Regex("^z([048CEKO]):(.+)$").find(line)
|
||||
if (matchResult != null) {
|
||||
|
|
@ -31,13 +47,7 @@ class ParseULine (var line: String, var measure: Int) {
|
|||
}
|
||||
blankDuration = cursorX
|
||||
line = matchResult.groups[2]!!.value
|
||||
parsedString = ":"
|
||||
if (capturedChar == "0") {
|
||||
parsedString = "|"
|
||||
}
|
||||
if (capturedChar == "8") {
|
||||
parsedString = "!"
|
||||
}
|
||||
parsedString = separatorAt(cursorX).toString()
|
||||
}
|
||||
parseUStage1()
|
||||
parseUStage3()
|
||||
|
|
@ -61,7 +71,11 @@ class ParseULine (var line: String, var measure: Int) {
|
|||
inComment = false
|
||||
val matchMeasure = Regex("^m:(\\d+)(/.*)?").find(actualComment)
|
||||
if (matchMeasure != null) {
|
||||
measure = matchMeasure.groups[1]!!.value.toInt()
|
||||
val newMeasure = matchMeasure.groups[1]!!.value.toInt()
|
||||
if (newMeasure > 0) {
|
||||
measure = newMeasure
|
||||
measureOrigin = cursorX
|
||||
}
|
||||
}
|
||||
actualComment = ""
|
||||
} else {
|
||||
|
|
@ -141,17 +155,7 @@ class ParseULine (var line: String, var measure: Int) {
|
|||
cursorX += codeChar.toString().toInt()
|
||||
}
|
||||
if (sequence.contains(':')) {
|
||||
val bar: Int = (cursorX / 4) % measure
|
||||
var replacement = ':'
|
||||
if ( (bar == 2 && measure == 4 )
|
||||
|| (bar == 3 && measure in listOf(6, 9, 12))
|
||||
|| (bar in listOf(6, 9) && measure in listOf(9, 12)))
|
||||
{
|
||||
replacement = '!'
|
||||
}
|
||||
if (bar == 0) {
|
||||
replacement = '|'
|
||||
}
|
||||
val replacement = separatorAt(cursorX)
|
||||
if (replacement != ':') {
|
||||
sequence = sequence.replace(':', replacement)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue