1
0
mirror of synced 2024-11-24 05:30:11 +01:00

Fix crash for #SECTION commands that occur before the first #BRANCHSTART (#36)

This PR adds `genpe.tja` to the test suite, a song that currently fails
due to how `tja2fumen` handles `#SECTION` commands.

We fix the problems with branching commands in
8ad2102f0a. (Making sure that any #SECTION
commands that occur before the first #BRANCHSTART are properly handled.)

This PR also contains a few refactoring commits to improve the clarity
of how the branching logic works, to make further debugging of branching
songs easier.

Fixes #33.
This commit is contained in:
Viv 2023-07-15 11:58:33 -04:00 committed by GitHub
parent ee265327de
commit fbe2fe21cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 999 additions and 22 deletions

View File

@ -51,6 +51,12 @@ def processTJACommands(tja):
measureTJAProcessed.delay = data.value * 1000 # ms -> s
elif data.name == 'branchStart':
measureTJAProcessed.branchStart = data.value
# If the measure immediately preceding a #BRANCHSTART has a #SECTION command, then remove it.
# From TJA spec: "Placing [a #SECTION command] near #BRANCHSTART or a measure before does not reset
# the accuracy for that branch. The value is calculated before it and a measure
# has not started yet at that point."
if tjaBranchesProcessed[branchName][-1].branchStart == ["#SECTION", -1, -1]:
tjaBranchesProcessed[branchName][-1].branchStart = None
elif data.name == 'barline':
currentBarline = bool(int(data.value))
measureTJAProcessed.barline = currentBarline
@ -194,11 +200,25 @@ def convertTJAToFumen(tja):
if measureTJAProcessed.branchStart:
# Determine which values to assign based on the type of branching condition
if measureTJAProcessed.branchStart[0] == 'p':
vals = [int(total_notes_branch * v * 20) if 0 <= v <= 1 # Ensure value is actually a percentage
else int(v * 100) # If it's not, pass the value as-is
for v in measureTJAProcessed.branchStart[1:]]
vals = []
for percent in measureTJAProcessed.branchStart[1:]:
# Ensure percentage is actually a percentage value
if 0 <= percent <= 1:
val = total_notes_branch * percent * 20
# If the result is very close, then round to account for lack of precision in percentage
if abs(val - round(val)) < 0.1:
val = round(val)
vals.append(int(val))
# If it isn't a percentage value, then pass it back as-is
else:
vals.append(int(percent * 100))
# If it's a drumroll then use the branch condition values as-is
elif measureTJAProcessed.branchStart[0] == 'r':
vals = measureTJAProcessed.branchStart[1:]
# If it's a #SECTION command, use the branch condition values as-is AND reset the accuracy
elif measureTJAProcessed.branchStart[0] == '#SECTION':
vals = measureTJAProcessed.branchStart[1:]
note_counter_branch = 0
# Determine which bytes to assign the values to
if currentBranch == 'normal':
idx_b1, idx_b2 = 0, 1
@ -209,8 +229,14 @@ def convertTJAToFumen(tja):
# Assign the values to their intended bytes
measureFumen.branchInfo[idx_b1] = vals[0]
measureFumen.branchInfo[idx_b2] = vals[1]
# Reset the note counter corresponding to this branch
# Reset the note counter corresponding to this branch (i.e. reset the accuracy)
total_notes_branch = 0
# NB: We update the branch condition note counter *after* we check the current measure's branch condition.
# This is because the TJA spec says:
# "The requirement is calculated one measure before #BRANCHSTART, changing the branch visually when it
# is calculated and changing the notes after #BRANCHSTART."
# So, by delaying the summation by one measure, we perform the calculation with notes "one measure before".
total_notes_branch += note_counter_branch
# Create notes based on TJA measure data

View File

@ -111,6 +111,7 @@ def parseCourseMeasures(course):
# Check if the course has branches or not
hasBranches = True if [l for l in course.data if l.name == 'BRANCHSTART'] else False
currentBranch = 'all' if hasBranches else 'normal'
branch_condition = None
flagLevelhold = False
# Process course lines
@ -133,7 +134,7 @@ def parseCourseMeasures(course):
# 2. Parse measure commands that produce an "event"
elif line.name in ['GOGOSTART', 'GOGOEND', 'BARLINEON', 'BARLINEOFF', 'DELAY',
'SCROLL', 'BPMCHANGE', 'MEASURE', 'BRANCHSTART']:
'SCROLL', 'BPMCHANGE', 'MEASURE', 'SECTION', 'BRANCHSTART']:
# Get position of the event
for branch in course.branches.keys() if currentBranch == 'all' else [currentBranch]:
pos = len(course.branches[branch][idx_m].notes)
@ -155,27 +156,31 @@ def parseCourseMeasures(course):
currentEvent = TJAData('bpm', float(line.value), pos)
elif line.name == 'MEASURE':
currentEvent = TJAData('measure', line.value, pos)
elif line.name == 'SECTION':
# If #SECTION occurs before the first #BRANCHSTART condition, then we have no percentage/drumroll values
# to use for the branchInfo bytes when writing to the fumen. So, we just use default values (-1, -1).
if branch_condition is None:
branch_condition = ['#SECTION', -1, -1]
# Otherwise, if #SECTION occurs after a #BRANCHSTART condition, then we just repeat the previous
# condition (to set the correct branchInfo bytes for this measure.)
currentEvent = TJAData('branchStart', branch_condition, pos)
elif line.name == 'BRANCHSTART':
if flagLevelhold:
continue
currentBranch = 'all' # Ensure that the #BRANCHSTART command is present for all branches
values = line.value.split(',')
if values[0] == 'r': # r = drumRoll
values[1] = int(values[1]) # # of drumrolls
values[2] = int(values[2]) # # of drumrolls
elif values[0] == 'p': # p = Percentage
values[1] = float(values[1]) / 100 # %
values[2] = float(values[2]) / 100 # %
currentEvent = TJAData('branchStart', values, pos)
branch_condition = line.value.split(',')
if branch_condition[0] == 'r': # r = drumRoll
branch_condition[1] = int(branch_condition[1]) # # of drumrolls
branch_condition[2] = int(branch_condition[2]) # # of drumrolls
elif branch_condition[0] == 'p': # p = Percentage
branch_condition[1] = float(branch_condition[1]) / 100 # %
branch_condition[2] = float(branch_condition[2]) / 100 # %
currentEvent = TJAData('branchStart', branch_condition, pos)
idx_m_branchstart = idx_m # Preserve the index of the BRANCHSTART command to re-use for each branch
# Append event to the current measure's events
for branch in course.branches.keys() if currentBranch == 'all' else [currentBranch]:
course.branches[branch][idx_m].events.append(currentEvent)
elif line.name == 'SECTION':
# Simply repeat the same #BRANCHSTART condition that happened previously
# The purpose of #SECTION is to "Reset accuracy values for notes and drumrolls on the next measure."
course.branches[branch][idx_m].events.append(TJAData('branchStart', values, pos))
# 3. Parse commands that don't create an event (e.g. simply changing the current branch)
else:

932
testing/data/genpe.tja Normal file
View File

@ -0,0 +1,932 @@
BPM:130.809005737305
OFFSET:-2.185
COURSE:Edit
LEVEL:10
STYLE:Single
BALLOON:
SCOREINIT:380
SCOREDIFF:90
#START
300000200200101010100000300000200200101010100000,
#BPMCHANGE 126.651481628418
100020002000100020002000500000000000000000000000,
#BPMCHANGE 133.79866027832
000000000000000000000000000000000000000000000000,
#BPMCHANGE 134.100387573242
008000000000000000000000000000000000000000000000,
#BPMCHANGE 125.664978027344
#SCROLL 1.05999994277954
100000000000200000200000100000200200200000100000,
#BPMCHANGE 127.921951293945
#SCROLL 1.03999996185303
100000000000000000200000200000000000000000200200,
#BPMCHANGE 130.834686279297
#SCROLL 1
100000000000200000200000100000200200200000100000,
#BPMCHANGE 131.710662841797
#MEASURE 2/4
100000000000200000200000,
#BPMCHANGE 130.000137329102
#MEASURE 4/4
#BARLINEOFF
100000100100200010102000100200100100200010102000,
#BARLINEON
100100100200200100200100200100200200100200000000,
#GOGOSTART
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200100100100200000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200100100100200000,
#MEASURE 2/4
100200100100200200100200,
#GOGOEND
#MEASURE 4/4
#BARLINEOFF
100100101010200100100100100100101010200100100100,
#BARLINEON
100100101010200100100100200100200100200100200100,
100100101010200100100100100100101010200100100100,
100100101010200100100100200100200100200100200100,
#MEASURE 2/4
100200100100200200100200,
#MEASURE 4/4
#BARLINEOFF
100000001010200100200200100200200100200200100000,
#BARLINEON
101010000000202020000000101010000000200200100000,
100000001010200100200200100200200100200200100000,
101010000000202020000000101010000000300000000000,
#GOGOSTART
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200100100100200000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200100100100200000,
#GOGOEND
#MEASURE 2/4
100200100100200200100200,
#MEASURE 4/4
#BARLINEOFF
100000200100100200000100100200200100100000200100,
#BARLINEON
100000200100100200000100100200200100200100100200,
100000200100100200000100100200200100100000200100,
100000200100100200000100100200200100200100100200,
100000200100100200000100100200200100100000200100,
100000200100100200000100100200200100200100100200,
100000200100100200000100100200200100100000100200,
200100100200100200200100100200100200200100100200,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100010200000,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100100200000,
100000200000100100200000100010200010100010200010,
100000000000000000000000100000000000100000100000,
100100100100200100100200100100100100200100100200,
100100100100200100100200100200100100201010100000,
#MEASURE 2/4
300000300000200200200200,
#GOGOSTART
#MEASURE 4/4
#BARLINEOFF
100000101010200100000100100000101010200100000100,
#BARLINEON
100000101010200100000100100100200200100100200000,
100000101010200100000100100000101010200100000100,
100000101010200100000100100100200200100100200000,
#GOGOEND
#MEASURE 2/4
100200100100200200100200,
#MEASURE 4/4
#BARLINEOFF
100100101010200100100100100100101010200100100100,
#BARLINEON
100100101010200100100100200100200100200100200100,
100100101010200200100100100100101010200200100100,
100100101010200200100100200100200100200100200100,
#MEASURE 2/4
100200100100200200100200,
#MEASURE 4/4
#BARLINEOFF
100000200100100200000100100200000200100100200100,
#BARLINEON
100000200100100200000100100200000100100200200100,
100000200100100200000100100200000200100100200100,
100000200100100200000100100200000100100200200100,
100000200100100200000100100200100100200000200100,
100000200100100200000100100200100100200000200100,
200000200100100200000200000200100100200000200000,
100200000200200200000200200200000200000300000000,
100000200100100200000100100200200100100000200100,
100000200100100200000200200100100200200000200100,
100000200100100200000100100200200100100000200100,
100000200100100200000200200100100200200000200100,
100000200100100200000100100200100200200100200100,
100000200100100200000100100200100200200100200100,
100000200200100100000000200200100100000000200000,
100100000000200000100100000200000100000300000000,
#GOGOSTART
100000101010200100000100100000101010200100000100,
100000101010200100100200100100200100200000000000,
100000101010200100000100100000101010200100000100,
100000101010200100100200100100200100200000000100,
#SECTION
#BRANCHSTART p, 52.85412, 73.99577
#N
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100000100508000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#E
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100100100508000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#M
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100000100200000000000300000000100,
100000201010200100100100100000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#BRANCHEND
#END
// NB: I currently do not have an official fumen
// that has the correct 2P charts, so I've
// commented them out for now.
//STYLE:Double
//BALLOON:8
//SCOREINIT:380
//SCOREDIFF:90
//
//#START P1
//300000000000000000000000600000000008000000000000,
//#BPMCHANGE 126.651481628418
//100000000000300000000000500000000000000000000000,
//#BPMCHANGE 133.79866027832
//000000000000000000000000000000000000000000000000,
//#BPMCHANGE 134.100387573242
//008000000000000000000000000000000000000000000000,
//#BPMCHANGE 125.664978027344
//#SCROLL 1.01999998092651
//000000000000000000000000100000100000100000100000,
//#BPMCHANGE 127.921951293945
//#SCROLL 1
//200000000000000000200000200000000000000000000000,
//#BPMCHANGE 130.834686279297
//#SCROLL 0.980000019073486
//000000000000000000000000000000000000000000000000,
//#BPMCHANGE 131.710662841797
//#SCROLL 1
//#MEASURE 2/4
//000000000000000000000000,
//#BPMCHANGE 130.000137329102
//#MEASURE 4/4
//100000000000200000000000100000100100200000000000,
//700000000000000000000000008000000000100200000000,
//#GOGOSTART
//100000100100200000000000100000100100200000000000,
//100000100100200000000000000000200000000000200000,
//100000000000200000100100100000000000200000100100,
//100000000000200000100000100100100000100100100000,
//#MEASURE 2/4
//300000000000000000000000,
//#GOGOEND
//#MEASURE 4/4
//000000100100200000100100000000100100200000100100,
//000000100100200000100100100000100000100000100000,
//100000200000100100000000100000200000100100000000,
//100000200000100100000000100000100000100000100000,
//#MEASURE 2/4
//100100100000100100100000,
//#MEASURE 4/4
//100000000100100000200000100000000000000000000000,
//100100000000200200000000100100000000200200200000,
//100000000000200000000000100100200000000000000000,
//100100000000200200000000100100000000300000000000,
//#GOGOSTART
//100000000000200000100100100000000000200000100100,
//100000000000200000100000100100100000100100100000,
//100000100100200000000000100000100100200000000000,
//100000100100200000100000000000200000000000200000,
//#GOGOEND
//#MEASURE 2/4
//300000000000000000000000,
//#MEASURE 4/4
//100000000100100000000100100000000100100000200000,
//100000000100100000000100100000000100100000200000,
//100000000100100000000100100000000100100000200000,
//100000000100100000000000100000000100000000200000,
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//000000000000000000000000200200200200200000000000,
//000000000000200200200200100000000000000000000000,
//100000200000100100100000100000200000100100100000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100000200000100100100000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100000200000100100100000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100000200000100100100000,
//000000000000100100100000000000000000100100100100,
//100000000000000000000000100000000000100000000000,
//100100100100000000000000100100100100000000000000,
//200200200200000000000000200200200200000000000000,
//#MEASURE 2/4
//300000000000000000000000,
//#GOGOSTART
//#MEASURE 4/4
//100000100100200000000000100000100100200000000000,
//100000100100200000000000000000200000000000200000,
//100000000000200000100100100000000000200000100100,
//100000000000200000100000100100100000100100100000,
//#GOGOEND
//#MEASURE 2/4
//300000000000000000000000,
//#MEASURE 4/4
//000000100100200200100100000000100100200200100100,
//000000100100200200100100100000100000100000100000,
//100000200000100100000000100000200000100100000000,
//100000200000100100000000100000100000100000100000,
//#MEASURE 2/4
//100100100000100100100000,
//#MEASURE 4/4
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000100100000200000,
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000100100000200000,
//000000000000000000000000000000000000200000200000,
//100000000000100000000000100000100000000300000000,
//100000000100200000000000100200100000200000000000,
//100000000100200000000000100200100000200000000000,
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000200200000200000,
//100000000100200000000000100200100000200000000000,
//100000000100200000000000100200100000100000000000,
//000000100000100100000000000000000000000000100000,
//100100000000000000000000000000100000000300000000,
//#GOGOSTART
//100000100100200000000000100000100100200000000000,
//100000100100200000000000100000000000300000000000,
//100000000000200000100100100000000000200000100100,
//100000000000200000100100100000000000000000000000,
//100000100100100100000100100000000000300000000000,
//100000000000200000100000100000000000300000000000,
//100000100100100100000100100000000000300000000000,
//100000100100200200000200100000000000000000000000,
//#GOGOEND
//000000000000000000000000000000000000000000000000,
//000000000000000000000000000000000000000000000000,
//#END
//
//BALLOON:8
//SCOREINIT:690
//SCOREDIFF:90
//
//#START P2
//600000000008000000000000300000000000000000000000,
//#BPMCHANGE 126.651481628418
//100000000000300000000000500000000000000000000000,
//#BPMCHANGE 133.79866027832
//000000000000000000000000000000000000000000000000,
//#BPMCHANGE 134.100387573242
//008000000000000000000000000000000000000000000000,
//#BPMCHANGE 125.664978027344
//#SCROLL 1.01999998092651
//000000000000000000000000000000000000000000000000,
//#BPMCHANGE 127.921951293945
//#SCROLL 1
//000000000000000000000000000000000000000000000000,
//#BPMCHANGE 130.834686279297
//#SCROLL 0.980000019073486
//100000000000000000000000100000100000100000100000,
//#BPMCHANGE 131.710662841797
//#SCROLL 1
//#MEASURE 2/4
//200000000000200000200000,
//#BPMCHANGE 130.000137329102
//#MEASURE 4/4
//100000000000200000000000100000100100200000000000,
//700000000000000000000000008000000000100200000000,
//#GOGOSTART
//100000000000200000100100100000000000200000100100,
//100000000000200000100000100100100000100100100000,
//100000100100200000000000100000100100200000000000,
//100000100100200000000000000000200000000000200000,
//#MEASURE 2/4
//300000000000000000000000,
//#GOGOEND
//#MEASURE 4/4
//100000200000100100000000100000200000100100000000,
//100000200000100100000000100000100000100000100000,
//000000100100200000100100000000100100200000100100,
//000000100100200000100100100000100000100000100000,
//#MEASURE 2/4
//100100100000100100100000,
//#MEASURE 4/4
//100000000000200000000000100100200000000000000000,
//100100000000200200000000100100000000200200200000,
//100000000100100000200000100000000000000000000000,
//100100000000200200000000100100000000300000000000,
//#GOGOSTART
//100000100100200000000000100000100100200000000000,
//100000100100200000000000000000200000000000200000,
//100000000000200000100000100000000000200000100000,
//100000000000200000100000100100100000100100100000,
//#GOGOEND
//#MEASURE 2/4
//300000000000000000000000,
//#MEASURE 4/4
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100000000100000000200000,
//100000000100100000000100100000000100100000200000,
//100000000100100000000100100000000100100000200000,
//100100100100100000000000000000000000000000100100,
//100100100000000000000000000000000000000000000000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100000200000100100100000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100100100000100100100000,
//100000200000000000200000100000200000000000200000,
//100000200000100100100000100000200000100100100000,
//100000200000000000200000100000200000000000200000,
//100100100000000000000000100100100100000000000000,
//100000000000000000000000100000000000100000000000,
//000000000000200200200200000000000000200200200200,
//000000000000100100100100000000000000100100100000,
//#MEASURE 2/4
//300000000000000000000000,
//#GOGOSTART
//#MEASURE 4/4
//100000000000200000100100100000000000200000100100,
//100000000000200000100000100100100000100100100000,
//100000100100200000000000100000100100200000000000,
//100000100100200000100000100100100000100100100000,
//#GOGOEND
//#MEASURE 2/4
//300000000000000000000000,
//#MEASURE 4/4
//100000200000100100000000100000200000100100000000,
//100000200000100100000000100000100000100000100000,
//000000100100200200100100000000100100200200100100,
//000000100100200200100100100000100000100000100000,
//#MEASURE 2/4
//100100100000100100100000,
//#MEASURE 4/4
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000200200000200000,
//100000000000200000000000100200100000200000000000,
//100000000000200000000000100200100000200000000000,
//000000000000000000000000000000000000200000200000,
//100000000000100000000000100000100000000300000000,
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000100100000200000,
//100000000100200000000000100200100000200000000000,
//100000000100200000000000100200100000200000000000,
//100000200100100000000100100000000100100000200000,
//100000200100100000000100100000000100100000200000,
//000000000000000000000000100000100100000000000000,
//000000000000100000100100000000100000000300000000,
//#GOGOSTART
//100000000000200000100100100000000000200000100100,
//100000000000200000100100100000000000000000000000,
//100000100100200000000000100000100100200000000000,
//100000100100200000000000100000000000300000000000,
//100000000000200000100000100000000000300000000000,
//100000100100100100000100100000000000300000000000,
//100000000000200000100000100000000000300000000000,
//100000100100200200000200100000000000000000000000,
//#GOGOEND
//000000000000000000000000000000000000000000000000,
//000000000000000000000000000000000000000000000000,
//#END
COURSE:Oni
LEVEL:8
BALLOON:
SCOREINIT:410
SCOREDIFF:107
#START
100000000000000000000000100000000000000000000000,
#BPMCHANGE 126.651481628418
100000000000100000000000500000000000000000000000,
#BPMCHANGE 133.79866027832
000000000000000000000000000000000000000000000000,
#BPMCHANGE 134.100387573242
008000000000000000000000000000000000000000000000,
#BPMCHANGE 125.664978027344
#SCROLL 1.01999998092651
000000000000000000000000100000100000100000100000,
#BPMCHANGE 127.921951293945
#SCROLL 1
200000000000000000200000200000000000000000000000,
#BPMCHANGE 130.834686279297
#SCROLL 0.980000019073486
000000000000000000000000100000100000100000100000,
#BPMCHANGE 131.710662841797
#SCROLL 1
#MEASURE 2/4
200000000000200000200000,
#BPMCHANGE 130.000137329102
#MEASURE 4/4
100000100100200000000000100200100100200000000000,
100100100200000100000100000100000100100200000000,
#GOGOSTART
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
#MEASURE 2/4
100000100100100100100100,
#GOGOEND
#MEASURE 4/4
000000100100200000100100000000100100200000100100,
000000100100200000100100100000100000100000100000,
000000100100200000100100000000100100200000100100,
000000100100200000100100100000100000100000100000,
#MEASURE 2/4
100000100000200200100100,
#MEASURE 4/4
100000000100100100200200100000000000000000000000,
100100000000200200000000100100000000200200100000,
100000000100100100200200100000000000000000000000,
100100000000200200000000100100100000300000000000,
#GOGOSTART
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
#GOGOEND
#MEASURE 2/4
100000200200200200200200,
#MEASURE 4/4
100000000100100000000100100000000100100000200000,
100000000100100000000100100000000100100200200100,
100000000100100000000100100000000100100000200000,
100000000100100000000100100200200100100200200100,
100000000100100000000100100000000100100000200000,
100000000100100000000100100000000100100200200100,
100000000100100000000100100200200100100000100200,
200100100000100200200100100000000000000000000000,
100000200000100100200000100000200000100100200000,
100000200000100100200000100000200000100100200000,
100000200000100100200000100000200000100100200000,
100000200000100100200000100100200100100100200100,
100000200000100100200000100000200000100100200000,
100000200000100100200000100000200000100100200000,
100000200000100100200000100000200000100100200000,
100100200100100100200100100100100100100100100100,
100000000000000000000000100000000000100000000000,
100000100000200000100200100000100000200000100200,
100000100000200000100200100200100000100100100000,
#MEASURE 2/4
300000000000000000000000,
#GOGOSTART
#MEASURE 4/4
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100100200000100100200000,
#GOGOEND
#MEASURE 2/4
100000100100100100100100,
#MEASURE 4/4
100000100100200000100100100000100100200000100100,
100000100100200000100100100000100000100000100000,
100000100100200200100100100000100100200200100100,
100000100100200200100100100000100000100000100000,
#MEASURE 2/4
100000100000100100100100,
#MEASURE 4/4
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000200200000200200,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
200000200000000200000200000200000000200000200000,
100200000200200200000200200200000200000300000000,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000200000200100100,
100000200100100200000100100200000100100000200100,
100000200100100200000100100200000100100000200100,
000000200000100100000000200000100100000000200000,
100100000000200000100100000000100000000300000000,
#GOGOSTART
100000100100200100000100100000100100200100000100,
100000100100200100000100100000000000300000000000,
100000100100200100000100100000100100200100000100,
100000100100200100000100100000000000300000000000,
100000100100200100000100100000000000300000000000,
100000100100200100000100100000000000300000000000,
100000100100200100000100100000000000300000000000,
100000100100100100000100100000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#END
COURSE:Hard
LEVEL:7
BALLOON:8
SCOREINIT:430
SCOREDIFF:105
#START
100000000000000000000000100000000000000000000000,
#BPMCHANGE 126.651481628418
100000000000100000000000500000000000000000000000,
#BPMCHANGE 133.79866027832
000000000000000000000000000000000000000000000000,
#BPMCHANGE 134.100387573242
008000000000000000000000000000000000000000000000,
#BPMCHANGE 125.664978027344
#SCROLL 1.01999998092651
000000000000000000000000100000100000100000100000,
#BPMCHANGE 127.921951293945
#SCROLL 1
200000000000000000200000200000000000000000000000,
#BPMCHANGE 130.834686279297
#SCROLL 0.980000019073486
100000000000000000000000100000100000100000100000,
#BPMCHANGE 131.710662841797
#SCROLL 1
#MEASURE 2/4
200000000000200000200000,
#BPMCHANGE 130.000137329102
#MEASURE 4/4
100000000000200000000000100000100100200000000000,
700000000000000000000000008000000000100200000000,
#GOGOSTART
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
#MEASURE 2/4
300000000000000000000000,
#GOGOEND
#MEASURE 4/4
000000100100200000100100000000100100200000100100,
000000100100200000100100100000100000100000100000,
000000100100200000100100000000100100200000100100,
000000100100200000100100100000100000100000100000,
#MEASURE 2/4
100000100000100100100000,
#MEASURE 4/4
100000000100100000200000100000000000000000000000,
100100000000200200000000100100000000200200200000,
100000000100100000200000100000000000000000000000,
100100000000200200000000100100100000300000000000,
#GOGOSTART
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
#GOGOEND
#MEASURE 2/4
300000000000000000000000,
#MEASURE 4/4
100000000100100000000100100000000100100000200000,
100000000100100000000100100000000100100000200000,
100000000100100000000100100000000100100000200000,
100000000100100000000000200000000200000000200000,
100000000100100000000100100000000100100000200000,
100000000100100000000100100000000100100000200000,
100100100100100000000000200200200200200000100100,
100100100000200200200200100000000000000000000000,
100000200000100100100000100000200000100100100000,
100000200000100100100000100000200000100100100000,
100000200000100100100000100000200000100100100000,
100000200000100100100000100100100000100100100000,
100000200000100100100000100000200000100100100000,
100000200000100100100000100000200000100100100000,
100000200000100100100000100000200000100100100000,
100100100000100100100000100100100100100100100100,
100000000000000000000000100000000000100000000000,
100000100000200000000200100000100000200000000200,
100000100000200000000200100100100000100100100000,
#MEASURE 2/4
300000000000000000000000,
#GOGOSTART
#MEASURE 4/4
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
100000100100200000000000100000100100200000000000,
100000100100200000000000100100100000100100100000,
#GOGOEND
#MEASURE 2/4
300000000000000000000000,
#MEASURE 4/4
000000100100200000100100000000100100200000100100,
000000100100200000100100100000100000100000100000,
000000100100200200100100000000100100200200100100,
000000100100200200100100100000100000100000100000,
#MEASURE 2/4
300000000000000000000000,
#MEASURE 4/4
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000200200000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
200000200000000200000200000200000000200000200000,
100000000000100000000000100000100000000300000000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000200200000200000,
100000200100100000000100100000000100100000200000,
100000200100100000000100100000000100100000200000,
000000100000100100000000100000100100000000100000,
100100000000100000100100000000100000000300000000,
#GOGOSTART
100000100100200000000000100000100100200000000000,
100000100100200000000000100000000000300000000000,
100000100100200000000000100000100100200000000000,
100000100100200000000000100000000000300000000000,
100000100100100100000100100000000000300000000000,
100000100100200200000200200000000000300000000000,
100000100100100100000100100000000000300000000000,
100000100100200200000200100000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#END
COURSE:Normal
LEVEL:5
BALLOON:
SCOREINIT:720
SCOREDIFF:235
#START
300000000000000000000000300000000000000000000000,
#BPMCHANGE 126.651481628418
100000000000100000000000500000000000000000000000,
#BPMCHANGE 133.79866027832
000000000000000000000000000000000000000000000000,
#BPMCHANGE 134.100387573242
008000000000000000000000000000000000000000000000,
#BPMCHANGE 125.664978027344
#SCROLL 1.01999998092651
100000000000000000000000200000000000000000000000,
#BPMCHANGE 127.921951293945
#SCROLL 1
100000100000000000000000200000000000000000000000,
#BPMCHANGE 130.834686279297
#SCROLL 0.980000019073486
100000000000000000000000200000000000000000000000,
#BPMCHANGE 131.710662841797
#SCROLL 1
#MEASURE 2/4
100000100000000000000000,
#BPMCHANGE 130.000137329102
#MEASURE 4/4
500000000000000000000000000000000000000000000008,
000000000000000000000000000000000000000000000000,
#GOGOSTART
100000100000100000000000100000000000100000000000,
100000000000100000100000100000000000000000000000,
100000100000100000000000100000000000100000000000,
100000000000100000100000100000000000000000000000,
#GOGOEND
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
000000000000100100000000000000000000100100000000,
000000000000000000000000100000100000100000100000,
000000000000200200000000000000000000200200000000,
000000000000000000000000100000100000100000100000,
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000200000000000000000000000,
100100000000000000000000200200000000000000000000,
100000000000000000000000200000000000000000000000,
100100000000000000000000200200000000000000000000,
#GOGOSTART
100000100000100000000000100000000000100000000000,
100000000000100000100000100000000000000000000000,
100000100000100000000000100000000000100000000000,
100000000000100000100000100000000000000000000000,
#GOGOEND
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000100100000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000200200000000000000100100,
100000000100000000000000000000000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000100000100000100000000000,
000000000000000000000000000000000000000000000000,
100000100000000000200000000000000000000000000000,
100000000000200000000000000000000000000000000000,
100000100000000000000000100000100000000000000000,
100000100000000000000000000000000000000000000000,
100000100000000000200000000000000000000000000000,
100000000000200000000000000000000000000000000000,
100000100000000000000000100000100000000000000000,
500000000000000000000000000000000000000000000008,
000000000000000000000000300000000000300000000000,
100000000000200000000000000000000000000000000000,
100000000000200000000000100000000000000000000000,
#MEASURE 2/4
000000000000000000000000,
#GOGOSTART
#MEASURE 4/4
100000100000100000000000100000100000100000000000,
100000000000100000100000100000000000000000000000,
100000100000100000000000100000100000100000000000,
100000000000100000100000100000000000000000000000,
#GOGOEND
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
000000000000100100000000000000000000100100000000,
000000000000000000000000100000100000100000100000,
000000000000100100000000000000000000100100000000,
000000000000000000000000100000100000100000100000,
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000100000000000000000000000,
100000100000000000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000100000000000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
200000000000200000000000200000000000000000000000,
000000000000000000000000000000000000000000000000,
100000000000100000000000100000100000000000000000,
100000000000000000000000100000000000000000000000,
100000100000000000000000200000000000000000000000,
100000000000000000000000100000000000000000000000,
100000100000000000000000200000000000000000000000,
100000000000200000000000100000000000200000000000,
100000000000200000000000100000000000200000000000,
100000000000000000000000100000000100000000100000,
000100000000100000000000000000000000000000000000,
#GOGOSTART
100000100000100000000000100000100000100000000000,
100000000000100000100000100000000000000000000000,
100000100000100000000000100000100000100000000000,
100000000000100000100000100000000000000000000000,
100000100000100000000000100000000000300000000000,
100000100000100000000000100000000000300000000000,
100000100000100000000000100000000000300000000000,
100000100000100000000000300000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#END
COURSE:Easy
LEVEL:4
BALLOON:10
SCOREINIT:650
SCOREDIFF:245
#START
300000000000000000000000300000000000000000000000,
#BPMCHANGE 126.651481628418
100000000000100000000000500000000000000000000000,
#BPMCHANGE 133.79866027832
000000000000000000000000000000000000000000000000,
#BPMCHANGE 134.100387573242
008000000000000000000000000000000000000000000000,
#BPMCHANGE 125.664978027344
#SCROLL 1.01999998092651
100000000000000000000000200000000000000000000000,
#BPMCHANGE 127.921951293945
#SCROLL 1
100000000000000000000000100000000000000000000000,
#BPMCHANGE 130.834686279297
#SCROLL 0.980000019073486
100000000000000000000000200000000000000000000000,
#BPMCHANGE 131.710662841797
#SCROLL 1
#MEASURE 2/4
100000000000000000000000,
#BPMCHANGE 130.000137329102
#MEASURE 4/4
500000000000000000000000000000000000000000000008,
000000000000000000000000000000000000000000000000,
#GOGOSTART
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
#MEASURE 2/4
000000000000000000000000,
#GOGOEND
#MEASURE 4/4
100000000000000000000000100000000000000000000000,
100000000000000000000000300000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000000000000000300000000000000000000000,
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000200000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000000000000000200000000000000000000000,
100000000000100000000000100000000000000000000000,
#GOGOSTART
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
#GOGOEND
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000100100000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000000000000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000100100000000000000000000,
100000000000000000000000700000000000000000000000,
000000000000000000000000000080000000000000000000,
100000000000000000000000100000100000000000000000,
100000000000100000000000000000000000000000000000,
100000000000000000000000100000100000000000000000,
100000000000100000000000000000000000000000000000,
100000000000000000000000100000100000000000000000,
100000000000100000000000000000000000000000000000,
100000100000000000000000100000100000000000000000,
500000000000000000000000000000000000000000000008,
000000000000000000000000000000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000100000000000,
#MEASURE 2/4
000000000000000000000000,
#GOGOSTART
#MEASURE 4/4
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
#GOGOEND
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000100000000000000000000000,
100000000000000000000000300000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000000000000000300000000000000000000000,
#MEASURE 2/4
000000000000000000000000,
#MEASURE 4/4
100000000000000000000000100000000000000000000000,
100000100000000000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000100000000000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
200000000000200000000000200000000000000000000000,
000000000000000000000000000000000000000000000000,
100000000000100000000000100000100000000000000000,
100000000000000000000000000000000000000000000000,
100000100000000000000000200000000000000000000000,
100000000000000000000000000000000000000000000000,
100000100000000000000000200000000000000000000000,
100000000000200000000000100000000000000000000000,
100000000000200000000000100000000000000000000000,
100000000000000000000000500000000000000000000000,
000000000000000000000000000008000000000000000000,
#GOGOSTART
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000000000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000100000000000100000000000000000000000,
100000000000100000000000300000000000000000000000,
#GOGOEND
000000000000000000000000000000000000000000000000,
000000000000000000000000000000000000000000000000,
#END

BIN
testing/data/genpe.zip Normal file

Binary file not shown.

View File

@ -12,6 +12,7 @@ from tja2fumen.constants import COURSE_IDS, NORMALIZE_COURSE, simpleHeaders, byt
@pytest.mark.parametrize('id_song', [
pytest.param('genpe'),
pytest.param('gimcho'),
pytest.param('imcanz'),
pytest.param('clsca'),
@ -84,15 +85,28 @@ def test_converted_tja_vs_cached_fumen(id_song, tmp_path, entry_point):
assert_song_property(co_measure, ca_measure, 'fumenOffsetStart', i_measure, abs=0.15)
assert_song_property(co_measure, ca_measure, 'gogo', i_measure)
assert_song_property(co_measure, ca_measure, 'barline', i_measure)
assert_song_property(co_measure, ca_measure, 'branchInfo', i_measure)
# NB: KAGEKIYO's fumen has some strange details that can't be replicated using the TJA charting format.
# So, for now, we use a special case to skip checking A) notes for certain measures and B) branchInfo
if id_song == 'genpe':
# A) The 2/4 measures in the Ura of KAGEKIYO's official Ura fumen don't match the wikiwiki.jp/TJA
# charts. In the official fumen, the note ms offsets of branches 5/12/17/etc. go _past_ the duration of
# the measure. This behavior is impossible to represent using the TJA format, so we skip checking notes
# for these measures, since the rest of the measures have perfect note ms offsets anyway.
if i_difficult_id == "x" and i_measure in [5, 6, 12, 13, 17, 18, 26, 27, 46, 47, 51, 52, 56, 57]:
continue
# B) The branching condition for KAGEKIYO is very strange (accuracy for the 7 big notes in the song)
# So, we only test the branchInfo bytes for non-KAGEKIYO songs:
else:
assert_song_property(co_measure, ca_measure, 'branchInfo', i_measure)
# 3b. Check measure notes
for i_branch in ['normal', 'advanced', 'master']:
co_branch = co_measure.branches[i_branch]
ca_branch = ca_measure.branches[i_branch]
# NB: We check for branching before checking speed as fumens store speed changes even for empty branches
if co_branch.length == 0:
continue
assert_song_property(co_branch, ca_branch, 'speed', i_measure, i_branch)
# NB: We only check speed for non-empty branches, as fumens store speed changes even for empty branches
if co_branch.length != 0:
assert_song_property(co_branch, ca_branch, 'speed', i_measure, i_branch)
# NB: We could assert that len(notes) is the same for both songs, then iterate through zipped notes.
# But, if there is a mismatched number of notes, we want to know _where_ it occurs. So, we let the
# comparison go on using the max length of both branches until something else fails.