diff --git a/autopon.py b/autopon.py index d88be07..9d4d24c 100755 --- a/autopon.py +++ b/autopon.py @@ -3,10 +3,10 @@ import argparse import subprocess import time -def ydotool(key, multiplier=1): - # This runs with a 100ms delay (by default, modulated by multiplier) because +def ydotool(key, delay=60, multiplier=1): + # This runs with a bit of a delay (by default, modulated by multiplier) because # Patapon -- the game, not the emulator or the input layer -- will drop inputs - # if it's any lower. + # if it's too low. subprocess.run([ "ydotool", "key", @@ -60,15 +60,17 @@ def main(): parser.add_argument('song',default="R-R-L-R-",nargs="+",choices=songs,help="The song to play. Defaults to Aria of Attack. When expressing a song, use eighth notes, dashes, and cardinal directions to designate the drums. For example, party would be \"L-R-D-U-\", and djinn would be \"D-DD-DD-\"") 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") args = parser.parse_args() # Schedule out our beat interval # 120.000 Naiive, does not work # 119.905 Still fast # 119.900 Still fast - # 119.890 + # 119.890 Just baaaaarely too fast + # 119.880 # 119.000 Wicked slow, outpaces in like 4 measures - bpm_constant = 119.890 + bpm_constant = 119.880 beat_interval = 60 / (bpm_constant * args.bpm * 2) print(f"Beat interval: {beat_interval}") @@ -90,7 +92,7 @@ def main(): lastbeat += beat_interval button = keymapping.get(key, '-') if button != '-': - ydotool(button, multiplier=args.bpm) + ydotool(key=button, delay=args.key_delay, multiplier=args.bpm) print(drummapping.get(key, '-'), end="", flush=True) else: print(" ", end="", flush=True)