Example #1
0
        i = i + 2
    else:
        time.sleep(song[i][1] / 1000)
        output.note_off(song[i][0], 0, 0)
        i = i + 1

path = "~/data/" + str(id) + '/' + condition + '/'

# find a file name to save
path_file = "/home/teco/data/" + str(id) + '/' + condition + '/'
found_file = False
file_name = part
i = 0
while not found_file:
    # check if file exists
    if fileExists(path_file + str(file_name) + ".mid"):
        file_name = str(part) + "_" + str(i)
        i = i + 1
    else:
        found_file = True

port = subprocess.Popen("arecordmidi -l |  awk '$2 ~ /CASIO/ {print $1}'",
                        shell=True,
                        stdout=subprocess.PIPE)
x = subprocess.Popen('arecordmidi -p ' +
                     port.stdout.read().decode("utf-8").rstrip() + ' ' +
                     path_file + str(file_name) + ".mid",
                     shell=True,
                     stdout=subprocess.PIPE,
                     preexec_fn=os.setsid)
Example #2
0
            print("The condition has to be either 'gold' or 'gnew'")
            sys.exit()
    elif opt in ("-s", "--session"):
        session = arg
        if (session != "pretest" and session != "posttest"
                and session != "test"):
            print("The session has to be either '1' or '2'")
            sys.exit()

if (id == 0 and attempt == "" and condition == "" and sessiont == ""):
    print(usage)
    sys.exit()

path = "~/data/" + str(id) + '/' + condition + '/' + session + '/'
#check if file exists
if (fileExists(path + attempt + ".mid")):
    print("file exists")
    sys.exit()

port = subprocess.Popen("arecordmidi -l |  awk '$2 ~ /CASIO/ {print $1}'",
                        shell=True,
                        stdout=subprocess.PIPE)
x = subprocess.Popen('arecordmidi -p ' +
                     port.stdout.read().decode("utf-8").rstrip() + ' ' + path +
                     attempt + ".mid",
                     shell=True,
                     stdout=subprocess.PIPE,
                     preexec_fn=os.setsid)

print("Started Capture")
print("Press Enter to Stop Capture")