diff --git a/autopon.py b/autopon.py index 9d4d24c..7358207 100755 --- a/autopon.py +++ b/autopon.py @@ -61,6 +61,7 @@ def main(): parser.add_argument('--bpm',type=float,default=1,help="Multiplier for the BPM. Change if you're running the game at a higher speed") parser.add_argument('--iterations',type=int,default=10000,help="Number of iterations of the sequence to run. Defaults to 10,000") parser.add_argument('--key-delay',type=int,default=60,help="Number of milliseconds to hold each key down for. Defaults to 100. Tune if you're getting dropped inputs or if the program can't keep up") + parser.add_argument('--startup-delay',type=int,default=0,help="Number of milliseconds by which we should \"start early\". Adjust this value if, despite syncing on-beat, the program is late. The program will never be early -- if it feels like it is, it's just WAY late") args = parser.parse_args() # Schedule out our beat interval @@ -71,8 +72,14 @@ def main(): # 119.880 # 119.000 Wicked slow, outpaces in like 4 measures bpm_constant = 119.880 + print(f"Game BPM: {bpm_constant} BPM * {args.bpm}") beat_interval = 60 / (bpm_constant * args.bpm * 2) - print(f"Beat interval: {beat_interval}") + print(f"Beat interval: {beat_interval * 1000}ms per eighth note") + # This sanity check of min() ensures that we'll never delay by more than a + # beat. Honestly, delaying by a beat makes no sense, but delaying by more + # than one makes even less. + startup_delay = min(beat_interval * 2, args.startup_delay / 1000) + print(f"Startup delay: {startup_delay * 1000}ms") # Set up the environment sequence='--------' + '--------'.join(args.song) @@ -82,7 +89,7 @@ def main(): # Wait for user confirmation input("Press enter on-beat to sync up with Patapon...") - synctime = time.perf_counter() + synctime = time.perf_counter() + startup_delay # Play da notes while remaining_iterations > 0: