#!/usr/bin/python import sys, os from subprocess import call, Popen from simpleOSC import * import socket REAPER_ARGUMENTS_FILE = '_proj_config' def setUpArgumentsFile(): previous_arguments = 0; if os.path.exists(REAPER_ARGUMENTS_FILE): #load file contents into hash f = open(REAPER_ARGUMENTS_FILE, 'r'); lines = f.readlines(); for line in lines: parts = line.split("\t"); previous_arguments[parts[0]] = parts[1]; f.close(REAPER_ARGUMENTS_FILE); return previous_arguments def writeArgumentsFile(reaper_arguments): f = open(REAPER_ARGUMENTS_FILE, 'w'); for i in reaper_arguments.keys(): f.write("%s\t%s" % (i, reaper_arguments[i])); f.close(); def getCommandlineArgs(): reaper_args = {}; if len(sys.argv) == 1: return else: midi_file_to_process = os.path.join(os.path.curdir, sys.argv[1]); if not os.path.exists(midi_file_to_process): print "please specify full path as argument" reaper_args = {"midi_source" : midi_file_to_process}; writeArgumentsFile(reaper_args); def main(): getCommandlineArgs(); #process commandline args #make sure reaper is running check = call([ 'pgrep', 'REAPER' ]); if check: Popen(['/Applications/REAPER64.app/Contents/MacOS/REAPER']) ip_address = socket.gethostbyname(socket.gethostname()) #start the client initOSCClient(ip_address, 8088) #start the server to receive messages (not yet implemented) initOSCServer(ip_address, 8808) #run main.py sendOSCMsg("/action/41061") main();