converters.py
: Rework the logic for measure offsets
To compute the first measure's offset, I currently subtract the first measure's duration from the TJA's OFFSET value. However, I realized that you actually have to subtract the *second* measure's duration from the TJA offset value. (For 99% of songs, the first two measures will have the same duration, so that's why the bug slipped by.) Fixes #4.
This commit is contained in:
parent
35ee48200f
commit
e053e1ad7a
@ -122,16 +122,15 @@ def convertTJAToFumen(fumen, tja):
|
|||||||
if measureTJA['bpm'] != measureTJANext['bpm']:
|
if measureTJA['bpm'] != measureTJANext['bpm']:
|
||||||
measureDuration -= (4 * 60_000 * ((1 / measureTJANext['bpm']) - (1 / measureTJA['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
|
# Compute the millisecond offset for each measure
|
||||||
# This is a bodge I'm using just for Rokuchounen to Ichiya Monogatari
|
|
||||||
# Its first measure happens _before_ the first barline
|
|
||||||
# So, we actually need to shift the offsets by 1 to get everything to line up
|
|
||||||
if idx_m == 0:
|
if idx_m == 0:
|
||||||
# Compute fumen offset for the first measure that has a barline
|
pass # NB: Pass for now, since we need the 2nd measure's duration to compute the 1st measure's offset
|
||||||
fumenOffset = float(tja['metadata']['offset']) * -1000
|
|
||||||
measureFumen['fumenOffset'] = fumenOffset - measureDuration
|
|
||||||
else:
|
else:
|
||||||
# Just refer back to the previous offset
|
# Compute the 1st measure's offset by subtracting the 2nd measure's duration from the tjaOffset
|
||||||
|
if idx_m == 1:
|
||||||
|
fumenOffset = float(tja['metadata']['offset']) * 1000 * -1
|
||||||
|
tjaConverted['measures'][-1]['fumenOffset'] = fumenOffset - measureDuration
|
||||||
|
# Use the previous measure's offset plus the previous duration to compute the current measure's offset
|
||||||
measureOffsetPrev = tjaConverted['measures'][-1]['fumenOffset']
|
measureOffsetPrev = tjaConverted['measures'][-1]['fumenOffset']
|
||||||
measureFumen['fumenOffset'] = measureOffsetPrev + measureDurationNext
|
measureFumen['fumenOffset'] = measureOffsetPrev + measureDurationNext
|
||||||
measureDurationNext = measureDuration
|
measureDurationNext = measureDuration
|
||||||
|
Loading…
Reference in New Issue
Block a user