diff --git a/src/tja2fumen/parsers.py b/src/tja2fumen/parsers.py index a0f6f80..04abad3 100644 --- a/src/tja2fumen/parsers.py +++ b/src/tja2fumen/parsers.py @@ -279,7 +279,7 @@ def applyFumenStructureToParsedTJA(globalHeader, courseHeader, measures): # TODO: Figure out what the unknown Wii1, Wii4, and PS4 notes represent (just in case they're important somehow) -def readFumen(fumenFile, byteOrder=None): +def readFumen(fumenFile, byteOrder=None, exclude_empty_measures=False): """ Parse bytes of a fumen .bin file into nested measure, branch, and note dictionaries. @@ -432,4 +432,13 @@ def readFumen(fumenFile, byteOrder=None): break file.close() + + # NB: Official fumens often include empty measures as a way of inserting barlines for visual effect. + # But, TJA authors tend not to add these empty measures, because even without them, the song plays correctly. + # So, in tests, if we want to only compare the timing of the non-empty measures between an official fumen and + # a converted non-official TJA, then it's useful to exclude the empty measures. + if exclude_empty_measures: + song['measures'] = [m for m in song['measures'] + if m['normal']['length'] or m['advanced']['length'] or m['master']['length']] + return song diff --git a/testing/test_conversion.py b/testing/test_conversion.py index 392e71f..c86dda9 100644 --- a/testing/test_conversion.py +++ b/testing/test_conversion.py @@ -56,8 +56,8 @@ def test_converted_tja_vs_cached_fumen(id_song, tmp_path, entry_point): i_difficult_id = os.path.basename(path_out).split(".")[0].split("_")[1] i_difficulty = NORMALIZE_COURSE[{v: k for k, v in COURSE_IDS.items()}[i_difficult_id]] # noqa # 0. Read fumen data (converted vs. cached) - co_song = readFumen(path_out) - ca_song = readFumen(os.path.join(path_bin, os.path.basename(path_out))) + co_song = readFumen(path_out, exclude_empty_measures=True) + ca_song = readFumen(os.path.join(path_bin, os.path.basename(path_out)), exclude_empty_measures=True) # 1. Check song headers checkValidHeader(co_song['headerPadding']+co_song['headerMetadata'], strict=True) checkValidHeader(ca_song['headerPadding']+ca_song['headerMetadata'])