vivaria / tja2fumen

Mod tool to convert TJA chart files (.tja) into .bin files compatible with official games
https://pypi.org/project/tja2fumen/
MIT License
14 stars 1 forks source link

Does `OFFSET` really correspond to the second measure's `fumenOffset`? #25

Closed vivaria closed 1 year ago

vivaria commented 1 year ago

Right now, my converter assumes that OFFSET directly corresponds to the second measure's fumenOffset. See:

While this holds for the majority of cases, sometimes an ESE song will be off by anywhere between 0-25ms. Normally, I just correct the TJA file so that it matches the official fumen's OFFSET value.

But, what if I should be leaving the TJA offset values as-is? ((There may be some interaction with #BPMCHANGE commands that cause OFFSET to not line up with the second measure's fumenOffset.))

So, I will need to see how these "wrong OFFSET" songs play on TJAPlayers, and compare that to how they play on TDMX, to make sure that my fumenOffset calculations are correct.

vivaria commented 1 year ago

Does OFFSET really correspond to the second measure's fumenOffset?

ANS: No. Very much no.

sometimes an ESE song will be off by anywhere between 0-25ms.

While it was difficult to pinpoint before due to the small desync times, I've found a song that is now way off: SUPERNOVA.

The measure durations (i.e. the time between each fumenOffset) are identical. It's just the offset as a whole that's way off. So, my assumptions around OFFSET are definitely off.

Here is the relevant part of the Ura chart:

#BARLINEOFF
#MEASURE 1/4
580000,

#BARLINEON
#MEASURE 4/4
40040040,
,

My hunch is that it has to do with the #MEASURE commands, as butou5.tja was off a little too before I corrected the .tja file, and its first measures include #MEASURE commands as well.

Maybe OFFSET corresponds to the fumenOffset value of the first full (4/4) measure. But, since the second measure of the chart occurs only after 1/4 of a measure has passed, then the offset values are way off..

vivaria commented 1 year ago

Maybe OFFSET corresponds to the fumenOffset value of the first full (4/4) measure. But, since the second measure of the chart occurs only after 1/4 of a measure has passed, then the offset values are way off..

This is exactly it.

If I subtract by an extra 3/4 of a measure (i.e. 3/4 * 1132), then I get the "correct" fumenOffset values (-1003, -720, 1544).

So, in other words:

# Formula
fumenOffset[2] = OFFSET - (measureDuration * (1 - time_sig[1]))

# In practice:
fumenOffset[2] = 129 - (1132 * (1 - 1/4))
fumenOffset[2] = 129 - 849
fumenOffset[2] = -720

And, because most of the time time_sig[1] is 4/4, then there's no adjustment to the OFFSET value.