Create a gist now

Instantly share code, notes, and snippets.

anonymous /wave_converter_automator
Created Apr 8, 2014

Automating Sample-loading for the Roland SP-404SX
'''
Usage:
sikuli-ide --stderr --run wave_converter_automator.sikuli/ --args ~/Downloads/*.wav
'''
import subprocess
import sys
import os.path
import time
key="HKEY_CURRENT_USER\Software\Roland\SP-404SX Wave Converter\Preference"
def assign_wav_to_pad(linux_path, pad_num):
print "linux_path:", linux_path, "pad_num:", pad_num
linux_dir=os.path.dirname(linux_path)
print "linux_dir:", linux_dir # ':'.join(x.encode('hex') for x in linux_dir)
# subprocess.check_output() isn't available
p=subprocess.Popen(['winepath', '--windows', linux_dir], stdout=subprocess.PIPE)
windows_dir=p.communicate()[0][:-1] # trim trailing linefeed from stdout
print "windows_dir:", windows_dir
subkey="Directory"
subprocess.call(["wine", "reg", "add", key, "/v", subkey, "/d", windows_dir])
subkey="File"
subprocess.call(["wine", "reg", "add", key, "/v", subkey, "/d", os.path.basename(linux_path)])
time.sleep(5) # magic
if(pad_num==0):
click(Pattern("1396801355688.png").similar(0.94))
elif(pad_num==1):
click(Pattern("1396801336951.png").similar(0.94))
elif(pad_num==2):
click(Pattern("1396799757191.png").similar(0.94))
elif(pad_num==3):
click(Pattern("1396812360780.png").similar(0.94))
elif(pad_num==4):
click(Pattern("1396812371773.png").similar(0.94))
elif(pad_num==5):
click(Pattern("1396812414896.png").similar(0.94))
elif(pad_num==6):
click(Pattern("1396812424542.png").similar(0.94))
elif(pad_num==7):
click(Pattern("1396812434877.png").similar(0.94))
elif(pad_num==8):
click(Pattern("1396812443773.png").similar(0.94))
elif(pad_num==9):
click(Pattern("1396812452040.png").similar(0.94))
elif(pad_num==10):
click(Pattern("1396812461861.png").similar(0.94))
elif(pad_num==11):
click(Pattern("1396812469312.png").similar(0.94))
click(Pattern("Imam-1.png").similar(0.84))
time.sleep(3) # magic
click("1396845898737.png")
time.sleep(5) # TODO: wait for loading to complete (note reg.exe is slow enough to provide a delay)
#sys.exit(888)
def main(argv):
print "sys.argv:", sys.argv
# puzzle: worth capturing wine dbg output?
p = subprocess.Popen(["wine", "/home/tz/.wine/drive_c/Program Files (x86)/Roland/SP-404SXWaveConverter/SP1.exe"])
if( len(sys.argv) > 1 ):
# args were passed from cli
print "invoked by cli"
for idx, cur_wav in enumerate(sys.argv[1:]):
assign_wav_to_pad(cur_wav, idx)
else:
# probably invoked from gui ide
print "invoked by gui ide"
assign_wav_to_pad("/home/tz/Desktop/cwill_03-06-14/fly_shit_4bars.wav", 0)
assign_wav_to_pad("/home/tz/Desktop/cwill_03-06-14/TroyBoi - Souls_3.wav", 1)
if __name__ == "__main__":
main(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment