From 0a3a4ae4e6c13ddeff2132dd1a6f46c183133c01 Mon Sep 17 00:00:00 2001 From: Viv Date: Fri, 2 Jun 2023 16:33:48 -0400 Subject: [PATCH] `converters.py`: Fix bug with measure BPM adjustment The adjustment occurs between ANY BPM shifts, and not just mid-measure BPM shifts. The reason I missed this is because my test song, Rokuchounen, ONLY contains mid-measure BPM shifts, and no BPM shifts that start exactly on the measure. --- tja2fumen/converters.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tja2fumen/converters.py b/tja2fumen/converters.py index 85a1570..6993cd3 100644 --- a/tja2fumen/converters.py +++ b/tja2fumen/converters.py @@ -113,10 +113,11 @@ def convertTJAToFumen(fumen, tja): # - measureDurationBase: The "base" measure duration, computed using a single BPM value. # - measureDuration: The actual measure duration, which may be adjusted if there is a mid-measure BPM change. measureDurationBase = measureDuration = (4 * 60_000 * measureSize * measureRatio / measureTJA['bpm']) - # The following adjustment accounts for mid-measure BPM changes. (!!! Discovered by tana :3 !!!) - if measureRatio != 1.0: - measureTJANext = tja['measures'][idx_m+1] - measureDuration -= (4 * 60_000 * ((1 / measureTJANext['bpm']) - (1 / measureTJA['bpm']))) + # The following adjustment accounts for BPM changes. (!!! Discovered by tana :3 !!!) + if idx_m != len(tja['measures'])-1: + measureTJANext = tja['measures'][idx_m + 1] + if measureTJA['bpm'] != measureTJANext['bpm']: + measureDuration -= (4 * 60_000 * ((1 / measureTJANext['bpm']) - (1 / measureTJA['bpm']))) # Apply the change in offset to the overall offset to get the measure offset # This is a bodge I'm using just for Rokuchounen to Ichiya Monogatari