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) {
|
class ParseULine (var line: String, var measure: Int) {
|
||||||
private var cursorX = 0
|
private var cursorX = 0
|
||||||
|
private var measureOrigin = 0
|
||||||
var parsedString = ""
|
var parsedString = ""
|
||||||
private var afterDollar = false
|
private var afterDollar = false
|
||||||
private var inComment = false
|
private var inComment = false
|
||||||
|
|
@ -18,6 +19,21 @@ class ParseULine (var line: String, var measure: Int) {
|
||||||
var blankDuration: Int = 0
|
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 {
|
fun parsed() : String {
|
||||||
val matchResult = Regex("^z([048CEKO]):(.+)$").find(line)
|
val matchResult = Regex("^z([048CEKO]):(.+)$").find(line)
|
||||||
if (matchResult != null) {
|
if (matchResult != null) {
|
||||||
|
|
@ -31,13 +47,7 @@ class ParseULine (var line: String, var measure: Int) {
|
||||||
}
|
}
|
||||||
blankDuration = cursorX
|
blankDuration = cursorX
|
||||||
line = matchResult.groups[2]!!.value
|
line = matchResult.groups[2]!!.value
|
||||||
parsedString = ":"
|
parsedString = separatorAt(cursorX).toString()
|
||||||
if (capturedChar == "0") {
|
|
||||||
parsedString = "|"
|
|
||||||
}
|
|
||||||
if (capturedChar == "8") {
|
|
||||||
parsedString = "!"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
parseUStage1()
|
parseUStage1()
|
||||||
parseUStage3()
|
parseUStage3()
|
||||||
|
|
@ -61,7 +71,11 @@ class ParseULine (var line: String, var measure: Int) {
|
||||||
inComment = false
|
inComment = false
|
||||||
val matchMeasure = Regex("^m:(\\d+)(/.*)?").find(actualComment)
|
val matchMeasure = Regex("^m:(\\d+)(/.*)?").find(actualComment)
|
||||||
if (matchMeasure != null) {
|
if (matchMeasure != null) {
|
||||||
measure = matchMeasure.groups[1]!!.value.toInt()
|
val newMeasure = matchMeasure.groups[1]!!.value.toInt()
|
||||||
|
if (newMeasure > 0) {
|
||||||
|
measure = newMeasure
|
||||||
|
measureOrigin = cursorX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
actualComment = ""
|
actualComment = ""
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -141,17 +155,7 @@ class ParseULine (var line: String, var measure: Int) {
|
||||||
cursorX += codeChar.toString().toInt()
|
cursorX += codeChar.toString().toInt()
|
||||||
}
|
}
|
||||||
if (sequence.contains(':')) {
|
if (sequence.contains(':')) {
|
||||||
val bar: Int = (cursorX / 4) % measure
|
val replacement = separatorAt(cursorX)
|
||||||
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 = '|'
|
|
||||||
}
|
|
||||||
if (replacement != ':') {
|
if (replacement != ':') {
|
||||||
sequence = sequence.replace(':', replacement)
|
sequence = sequence.replace(':', replacement)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue