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

62 Commits

Author SHA1 Message Date
Viv
25e6d6f4d4 test_command_support.py: Catch warnings 2024-02-10 19:50:27 -05:00
Viv
1faaab9e9c Improve custom TJA testing 2024-02-10 19:50:27 -05:00
Viv
073178601f
Add proper Don/Ka types to clusters of notes (#64)
This should match most fumens. Some exceptional cases I've seen:

- [x] ~In official fumens, even-numbered clusters of 4 notes will
sometimes be ドドドド or カカカカ. Right now, my converter will always use ドドドドン
or カカカカッ, since I don't really understand the rules behind it.~ Fixed:
Now, all 16th notes and above in groups of 4 will no longer use the
don/kat ending character.
- [X] ~In official fumens, sometimes isolated notes will be grouped
together, but sometimes they will be treated as single clusters of 1.
Right now, my converter will always try to cluster isolated notes.~
Fixed: Only 4th/8th/16th/etc. notes will be clustered. Whole/half notes
will not be clustered.
- [x] ~Right now, my logic always treats big notes as their own cluster.
But, sometimes you get a cluster like `ddddD`, and right now my
converter treats this as (ドドドドン) + big DON instead of do-ko-do-ko-DON.~
Fixed: Now big notes are included in clusters.
- [x] ~For high-level Oni songs with complex groups of dense notes (e.g.
(12th/16th/24th) notes mixed with (16th/34th/32nd) notes), official
fumens seem to group them together even though they technically have
different timings. Right now, my converter will group the 32nd notes,
but treat the 16th notes as their own separate group.~ Fixed: Now
anything above an 8th note will be clustered together.
- [X] Songs with BPM gimmicks. e.g. the TJA has low base BPM, but then
everything is doubled/tripled except for one section. I can't remember
which songs have this? Something like RNG Cinderella?
- Maybe solved by
1f640c1aa1?

Fixes #41.
2024-02-03 22:32:29 -05:00
Viv
018d09d34c
Fix error when metadata fields have numbers in them (e.g. NOTESDESIGNER0) (#61)
Simple fix -- regex for metadata didn't include numbers, but does now.

Fixes #60.
2023-08-05 11:00:28 -04:00
Viv
387cbbcdfa
Make project pylint-compliant (and add pylint check to test suite) (#59) 2023-07-30 18:49:58 -04:00
Viv
c0442f3721
Fix behavior for the #LEVELHOLD command (#54)
Previously, I had translated the existing levelhold behavior in
WHMHammer's tja parsing code, assuming that it would produce the correct
behavior for fumen charts. However, that is not the case -- the behavior
is completely wrong.

So, this PR takes out all the old `flag_levelhold` behavior and instead
properly sets the `branch_info` bytes whenever #LEVELHOLD is present on
a branch.

This PR also prepares `shoto9.tja` for further testing, but I'm leaving
that for later...

Fixes #52.
2023-07-27 15:02:19 -04:00
Viv
a09bfb87d4 Add test for 2P commands 2023-07-24 16:55:52 -04:00
Viv
6eb3676343 Add double Kusudama test 2023-07-24 16:46:21 -04:00
Viv
276bd0b70c Add semi-support for sim-specific notes 2023-07-24 16:28:49 -04:00
Viv
a4c9fb2b18 Add support for A/B notes (hands) 2023-07-24 15:57:58 -04:00
Viv
e799e35629
test_conversion.py: Fix Pylint warnings 2023-07-24 01:00:15 +00:00
Viv
cee3819efa testing/: Add test case for missing balloons 2023-07-23 12:15:05 -04:00
Viv
a979b4104a testing/: Add test case for missing balloons 2023-07-23 11:24:18 -04:00
Viv
ca9b0d0332 testing/: Move convert() into conftest.py 2023-07-23 10:20:28 -04:00
Viv
9a24b90618 Add new test for checking dummy TJA errors 2023-07-23 10:11:42 -04:00
Viv
60a9e249cd parsers.py: Rename read_fumen function 2023-07-21 23:18:09 -04:00
Viv
356bb7b036
Update codebase to adhere to flake8 and add linting check (#51) 2023-07-21 22:57:18 -04:00
Viv
000125eb10
Ensure that header branch bytes are correctly set for all branching cases (#50)
Some backstory:

- In [#45](https://github.com/vivaria/tja2fumen/pull/45), I reworked the
header parsing code to make sure every header value was correctly
identified.
- In [#46](https://github.com/vivaria/tja2fumen/pull/46), I changed how
the "branch point" header bytes were set by checking if a song contained
only drumroll branching conditions. This fixed drumroll-only songs like
BATTLE NO. 1, Shoutoku Taiko, etc.

However, I missed a corner case in #46 -- songs with `#BRANCHSTART
p,0,0` should still be considered "drumroll only". As well, I neglected
to consider the "percentage only" songs. So, I fixed the header bytes
there, too.

Then, to confirm that my changes do in fact produce correct headers, I
enabled the check for `branch_points` for (most) of the songs in the
test suite. The tests pass. :)
2023-07-20 21:58:58 -04:00
Viv
5ce313ca83 Rename advanced -> professional 2023-07-19 23:45:59 -04:00
Viv
1777100d3d test_conversion: Add HP bytes to test suite
Will need to comment out the remaining header bytes and test them for the existing songs.
2023-07-19 22:59:07 -04:00
Viv
48718b2303
Fix variable case (camelCase -> snake_case + CONST_CASE) (#47)
Wouldn't have been possible without
https://gist.github.com/Mizzlr/eec29687704aa81bf61dfccda36ddb8c.

Fixes #8 .
2023-07-19 21:50:09 -04:00
Viv
9ce1d76ca3
Fix branching behavior for #BRANCHSTART r songs (#46)
This PR updates the behavior for songs with drumroll branching
conditions (`#BRANCHSTART r`)

The changes include:

- Correctly setting the `branchInfo` bytes for branching conditions that
occur _after_ the first condition.
- Correctly setting the `branch_points` bytes in the header when there
are only drumroll conditions.
- Correctly setting the `branch_ratio` bytes in the header when total
notes differ between branches.
- Correctly handling #SECTION commands for a number of different corner
cases:
    1. #SECTION occurs on its own without a #BRANCHSTART
    2. #BRANCHSTART occurs with a #SECTION command
3. #BRANCHSTART occurs without a #SECTION command (and is first branch
condition)
4. #BRANCHSTART occurs without a #SECTION command (and is NOT first
branch condition)


Note: I've added `shoto9` to the test suite, but the TJA file is
structured in a way that the number of measures doesn't match the number
of fumen measures. The TJA needs to be reworked, but that's okay,
because its purpose was just to check that the branching bytes were
correct.

Fixes #40.
2023-07-19 16:47:08 -04:00
Viv
2a6d1c3df5
Overhaul header metadata code with new FumenHeader Python class (plus use ints, not bytes) (#45)
Previously, I had to reverse engineer many of the bytes in a valid fumen
header. This meant that I was often working with literal byte values, as
well as guessing at what things meant, calling them "padding" or
"unknown".

However, thanks to #44, I now have a TON of knowledge about the correct
purpose of each byte in the header. This lets me properly document each
value's purpose, and it also lets me parse 4-byte groups as ints, rather
than dealing with individual raw bytes.

In summary, the changes in this PR are:

- Create a new `FumenHeader` class with individual (correctly-named!)
attributes for each 4-byte integer.
- Parse and write the fumen header as one big 520-byte chunk, instead of
handling the header in smaller increments.
- Remove a bunch of dead lines of code that were hardcoding specific
byte values, and replace them with proper integer values.
- Vastly simplify the test for valid headers by removing checks against
individual bytes..

Necessary for #40.
Fixes #44.
2023-07-19 14:36:58 -04:00
Viv
fbe2fe21cc
Fix crash for #SECTION commands that occur before the first #BRANCHSTART (#36)
This PR adds `genpe.tja` to the test suite, a song that currently fails
due to how `tja2fumen` handles `#SECTION` commands.

We fix the problems with branching commands in
8ad2102f0a. (Making sure that any #SECTION
commands that occur before the first #BRANCHSTART are properly handled.)

This PR also contains a few refactoring commits to improve the clarity
of how the branching logic works, to make further debugging of branching
songs easier.

Fixes #33.
2023-07-15 11:58:33 -04:00
Viv
cd755bd646
Replace all {song, branch, measure, note} dictionaries with classes (#32)
This refactor will hopefully pave the way for further refactors that
will make this code easier to understand and work with.

Fixes #9.
2023-07-11 21:30:55 -04:00
Viv
bd27e9dade
Add new LUTs to cover the remaining soul gauge bytes (12/13, 16/17) (#31)
Fixes #14.
2023-07-11 08:07:30 -04:00
Viv
6baf2e55f2 Add gimcho.tja to test suite 2023-07-10 00:08:59 -04:00
Viv
2dec26d2bf
Add support for #BRANCHSTART p,999,999 and #SECTION commands via imcanz.tja (#30)
This PR adds a new chart to the test suite (`imcanz.tja`) that uses
`p,0,0`, `p,999,999` _and_ `#SECTION` commands:

- `p,0,0`: Forces the chart into the Master branch (since it's
impossible to fail a 0% accuracy requirement)
- `p,999,999`: Forces the chart into the Normal branch (since it's
impossible to pass a 999% accuracy requirement)
- `#SECTION`: Resets accuracy values for notes and drumrolls on the next
measure. (In practice, this just means that the branch condition is
repeated on the next measure, at least according to the official fumen I
have.)

Note: Only the Oni and Hard difficulties have actually been added to the
test suite. The Normal and Easy charts were too broken to easily match
the official fumens. They will need a lot of work to fix charting
errors, so I'm leaving them commented out for now.

Fixes #27.
2023-07-09 19:56:57 -04:00
Viv
57edc7aecf Simplify how #BPMCHANGEs adjust the fumenOffset
Before:

- If there was a #BPMCHANGE, tana's adjustment would be applied to _the current measure's duration_. This would result in very strange looking, impossible durations (e.g. negative)
- Additionally, this method required us to look ahead to the _next_ measure to determine the adjustment.
- Finally, it required us to keep track of two different durations: measureDurationBase (unadjusted) and measureDuration (adjusted)

After:

- Instead, we now leave the measureDuration as purely as "unadjusted".
- Then, we apply the "BPMCHANGE adjustment" _only_ when computing the fumenOffset start of the next measure.
- This requires us to keep track of both the start *and* end fumenOffset (where end = start + duration)
- However, this greatly simplifies and clarifies the code, since we:
  - No longer need to "look ahead" to the next measure to compute the offset adjustment.
  - No longer need to keep track of two different measureDurations (adjusted/unadjusted)
  - Only need to work with a single pair of measures at a time (measureFumen, measureFumenPrev)
  - The measure duration (and fumenOffsetEnd) times are now more comprehensible, since any negative offsets are only applied to the fumenOffsetStart value of the next measure.

After:
2023-07-09 15:51:04 -04:00
Viv
ab7708e740 testing/: Tighten up tolerance for fumenOffset/pos 2023-07-08 18:44:37 -04:00
Viv
7b31516438 Fix P2/2P bug and add clsca to the test suite
Fixes #13.
2023-07-08 18:44:37 -04:00
Viv
b874d5c412
Fix inaccurate method for computing the fumenOffset values for the initial measures (#28)
- Before: 'OFFSET' = 2nd measure fumenOffset
- After: ('OFFSET'-Full measure duration) = 1st measure fumenOffset

Both methods will produce the same results if no #MEASURE/#BPMCHANGE
commands are present in the first two measures. However, if these
commands ARE present, then you will get wildly different results.

This change doesn't affect 4/6 tests, but for 2/6 tests there were
#MEASURE/#BPMCHANGE commands. For these songs, I had erroneously "fixed"
the OFFSET values, when they were correct all along. So, I reverted them
back to their original values.

Fixes #25.
2023-07-06 23:38:10 -04:00
Viv
a95b8e7ab1
Add support for #DELAY commands (#24)
This PR adds support for `#DELAY` commands, and adds a fumen-TJA pair
for `linda` to test this.

Fixes #5.
2023-07-05 23:53:48 -04:00
Viv
ce633253ee
Add support for multiplayer charts (STYLE:{Single,Double}, # START {P1,P2}) (#23)
This PR adds support for multiplayer charts, and adds a new multiplayer
TJA/fumen combo for testing.

This PR is quite small, because the only work that needed to be done is
parsing the course metadata. Once the TJA lines are split into courses,
the actual course-by-course parsing logic is identical to the songs that
came before.

Fixes #6.
2023-07-05 16:03:41 -04:00
Viv
d9b1476f4d
Add remaining support for branches (#BRANCHSTART r) (#21)
This PR adds the remaining changes needed to support branching TJA
songs.

- Properly handling `r` (drumroll) based branching conditions
- Handling commands that come after a measure end but _before_ the first
`#BRANCHSTART` command. (This was not previously covered by
`hol6po.tja`.)

As well, it adds a bit of cleanup/refactoring to the changes from the
previous branch PR (#20).

To test these changes, another new branching TJA-fumen pair is added to
the test suite.
2023-07-02 00:00:36 -04:00
Viv
4e613d7237
Add partial support for branches (#BRANCHSTART P, no R, no #SECTION) (#20)
This PR adds partial branch support -- enough to correctly convert
`hol6po.tja`, but likely not enough to convert other songs.

Partially addresses #2.
2023-07-01 17:41:23 -04:00
Viv
e2b0ac3e50 testing/: Remove outdated comments 2023-06-30 17:37:38 -04:00
Viv
1510a62bf5 tests/: Add WIP test for soul-gauge byte LUTs 2023-06-29 21:24:55 -04:00
Viv
6d2f5a73bb Add comments to TJA test files
- Documenting the purpose of each song in the test suite
- Testing that comments are handled correctly
2023-06-29 20:51:13 -04:00
Viv
2ed0f92a69 Revert "tests: Import from src.tja2fumen"
This reverts commit af91e9fe47.

I was mistaken. Importing from src is _not_ necessary to perform PyCharm coverage tests. Instead, the package must be installed in editable mode.
2023-06-29 20:34:39 -04:00
Viv
3e33d5c634 Fix errors in ia6cho charts
The official fumen had some issues where a note ended up in the wrong measure:

- Expected: pos 0.0 on the next measure
- Actual: pos 645 on the prev measure (impossible pos)

They're the same pos, but only pos 0.0 is possible to express in TJA charts, so the fumens themselves had to be updated.

Also, the TJA chart had errors, too:

- The BPMs/SCROLLs in the BPMCHANGE section were incorrect
- Some drumrolls were too short

Fixing these errors caused the failing test to pass.
2023-06-29 19:47:25 -04:00
Viv
ea701a5c63 tests/: Increase the tolerance for drumroll duration
Again, I encountered a large mismatch where an official fumen didn't land on the expected beat.
2023-06-29 19:47:25 -04:00
Viv
91ad789d10 tests/: Don't halt early if there's a len(notes) mistmatch 2023-06-29 19:47:25 -04:00
Viv
712cdc0a14 tests/: Don't halt early if there's a len(measures) mismatch 2023-06-29 19:47:25 -04:00
Viv
8b302e876f tests/: Use readable name for song variables 2023-06-29 19:47:25 -04:00
Viv
3f981236e3 tests/: Add sorting for generated songs
This makes things nicer to debug, since we're following an expected order.
2023-06-29 15:40:05 -04:00
Viv
305b70eb27 tests/: Compare only the non-empty measures 2023-06-29 15:39:39 -04:00
Viv
0bef98c10d Stop hardcoding song['length']
Instead, rely on len(song['measures') as the single source of truth for measures
2023-06-29 15:19:51 -04:00
Viv
6286a3a78d Reorder test functions 2023-06-29 15:19:51 -04:00
Viv
af91e9fe47 tests: Import from src.tja2fumen
This will _actually_ perform an in-place test run, rather than importing from the installed package. This is necessary for PyCharm's coverage to ework correctly.
2023-06-29 14:10:25 -04:00