polish change_sync_bias.py
This commit is contained in:
parent
34415a8062
commit
00279aff9d
1 changed files with 23 additions and 2 deletions
|
@ -1,10 +1,29 @@
|
||||||
|
R"""
|
||||||
|
Add or subtract the standard ITG sync bias (9 milliseconds)
|
||||||
|
to all of the sync offsets in a pack.
|
||||||
|
|
||||||
|
This script updates the offsets of both SM and SSC simfiles,
|
||||||
|
including any SSC charts with their own timing data.
|
||||||
|
|
||||||
|
If you actually intend to use this script in practice,
|
||||||
|
you may want to keep track of which packs you've already adjusted
|
||||||
|
using a text file in each pack directory or some other system.
|
||||||
|
|
||||||
|
Usage examples:
|
||||||
|
|
||||||
|
# Convert a pack from "null sync" to "ITG sync"
|
||||||
|
python change_sync_bias.py +9 "C:\StepMania\Songs\My Pack"
|
||||||
|
|
||||||
|
# Convert a pack from "ITG sync" to "null sync"
|
||||||
|
python change_sync_bias.py -9 "C:\StepMania\Songs\My Pack"
|
||||||
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import sys
|
import sys
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import simfile
|
import simfile
|
||||||
from simfile.dir import SimfilePack
|
import simfile.dir
|
||||||
|
|
||||||
|
|
||||||
class ChangeSyncBiasArgs:
|
class ChangeSyncBiasArgs:
|
||||||
|
@ -58,6 +77,8 @@ def change_sync_bias(simfile_path: str, args: ChangeSyncBiasArgs):
|
||||||
input_filename=f"{simfile_path}",
|
input_filename=f"{simfile_path}",
|
||||||
backup_filename=f"{simfile_path}~",
|
backup_filename=f"{simfile_path}~",
|
||||||
) as sf:
|
) as sf:
|
||||||
|
print(f"Processing {simfile_path}")
|
||||||
|
|
||||||
# Always adjust the simfile's offset
|
# Always adjust the simfile's offset
|
||||||
adjust_offset(sf, delta)
|
adjust_offset(sf, delta)
|
||||||
|
|
||||||
|
@ -74,7 +95,7 @@ def main(argv):
|
||||||
|
|
||||||
# Iterate over SimfileDirectory objects from the pack
|
# Iterate over SimfileDirectory objects from the pack
|
||||||
# so that we can easily get the .sm and/or .ssc paths
|
# so that we can easily get the .sm and/or .ssc paths
|
||||||
for simfile_dir in SimfilePack(args.pack).simfile_dirs():
|
for simfile_dir in simfile.dir.SimfilePack(args.pack).simfile_dirs():
|
||||||
|
|
||||||
# Try to update whichever formats exist
|
# Try to update whichever formats exist
|
||||||
for simfile_path in [simfile_dir.sm_path, simfile_dir.ssc_path]:
|
for simfile_path in [simfile_dir.sm_path, simfile_dir.ssc_path]:
|
||||||
|
|
Loading…
Reference in a new issue