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

converters.py: Only subtract drumroll pos for single-measure drumroll

Commit 1953ffbc23 fixes one issue but introduced another:

 - Subtracting the drumrolls original position only makes sense if the drumroll starts and ends in the same measure.
 - If the drumroll spans multiple measures, though, then the original position is irrelevant, since we want to add the duration from the start of the next measure (i.e. pos=0).

 So, this commit makes sure to only subtract the position if the drumroll isn't a multi-measure drumroll.

 ((NB: This could probably be handled without using a new 'multimeasure' key, but I'm going to wait until the class refactor to tackle this.))

 Fixes #16.
This commit is contained in:
Viv 2023-06-03 14:57:11 -04:00
parent 1953ffbc23
commit 35ee48200f

View File

@ -151,9 +151,15 @@ def convertTJAToFumen(fumen, tja):
# Note positions must be calculated using the base measure duration (that uses a single BPM value)
# (In other words, note positions do not take into account any mid-measure BPM change adjustments.)
note_pos = measureDurationBase * (data['pos'] - measureTJA['pos_start']) / measureLength
# The duration of the current drumroll is the position of the drumroll-end note.
# Handle the note that represents the end of a drumroll/balloon
if data['value'] == "EndDRB":
currentDrumroll['duration'] += (note_pos - currentDrumroll['pos'])
# If a drumroll spans a single measure, then add the difference between start/end position
if 'multimeasure' not in currentDrumroll.keys():
currentDrumroll['duration'] += (note_pos - currentDrumroll['pos'])
# Otherwise, if a drumroll spans multiple measures, then we want to add the duration between
# the start of the measure (i.e. pos=0.0) and the drumroll's end position.
else:
currentDrumroll['duration'] += (note_pos - 0.0)
# 1182, 1385, 1588, 2469, 1568, 752, 1568
currentDrumroll['duration'] = float(int(currentDrumroll['duration']))
currentDrumroll = None
@ -193,6 +199,7 @@ def convertTJAToFumen(fumen, tja):
if currentDrumroll:
if currentDrumroll['duration'] == 0.0:
currentDrumroll['duration'] += (measureDurationBase - currentDrumroll['pos'])
currentDrumroll['multimeasure'] = True
else:
currentDrumroll['duration'] += measureDurationBase