vivaria / tja2fumen

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

Use more specific don/ka types when writing to fumen (ド, コ, ドン, カッ, カ) #41

Closed vivaria closed 7 months ago

vivaria commented 1 year ago

Since TJA files use only a single number to represent dons and kas (1 and 2 respectively), I have only been writing a single type of don/ka to the converted .bin file.

However, official fumens actually have 3 types of dons and 2 types of kas. And, different types will be used depending on how the dons and kas are grouped together:

image

Theoretically, my converter could track if a note is part of a triplet/quad/etc. and write the different notes accordingly. But, it might be quite tricky to programmatically detect groupings of notes.

Maybe what I could do is track "time since last note". If the time decreases (i.e. notes are closer together), we enter a "grouping". If the time stays the same, then we're still within the grouping. If the time increases (i.e. notes are further apart), we have exited the grouping. But, I don't know how foolproof that is if we consider BPMCHANGE commands, etc. 🤔

vivaria commented 7 months ago

I assume that the logic goes like this:

This was mostly wrong -- see PR for the real logic - Single notes just use ド (do) and カ (ka) - Groupings of 2 or more will always end on ドン (don) and カッ (ka~tsu) - If there are multiple don notes in a row in a grouping, they'll alternate between ド (do) and コ (ko) For example: - DD -> ドドン -> Do-don - DDD -> ドコドン -> Do-ko-don - DDDDD -> ドコドコドン -> Do-ko-do-ko-don - KDK -> Is this カドカッ (Ka-do-katsu) or カドカッ (Ka-ko-katsu)? Presumably the former, right? - DDK -> Actually this is ドドカッ (Do-do-katsu)! Surprising! (It seems like コ is only used in groups of 3+ dons that end on a ドン) - DDDDK -> ドドドドカッ -> Do-do-do-do-katsu Groupings seem to include any set of notes with identical durations between them, e.g.: ![image](https://github.com/vivaria/tja2fumen/assets/76574898/78d352f8-15eb-442f-a76e-fb23c284f501) (Note the katsu at the end, even when notes are spaced out)

I will have to be quite careful when keeping track of note groupings (tracking between-measure groupings, making sure to properly identify when a grouping ends, etc.).

vivaria commented 7 months ago

It looks like there are a handful of approaches for clustering in 1D (see this SO answer). Many of them are using numpy / scipy, though, whereas ideally I would want to implement something in pure Python to keep the distributed binary size small.

I do think that the 1D clustering problem here is quite a bit simpler than the cases described on SO:

So, maybe I can come up with some sort of simplified algorithm to group the notes, given some assumptions. For example: