Пример #1
0
        print("%d: %s" % (i + 1, ins[i]))
    inDev = ins[int(input("Select input device: ")) - 1]
else:
    inDev = mido.get_input_names()[0]

if "-o" in argv:
    print("[+] List of output devices")
    for i in range(len(ins)):
        print("%d: %s" % (i + 1, outs[i]))
    outDev = ins[int(input("Select output device: ")) - 1]
else:
    outDev = mido.get_output_names()[0]

### Connecting to input and output devices
print("Testing inDev and outDev")
if p.connect(inDev, outDev):
    if verbose:
        print("PASSED")
else:
    if verbose:
        print("FAILED")

### Connecting recorder with piano
print("Testing recorder and piano connection")
if rec.setPiano(p):
    if rec.piano == p and rec.handler == p.input.callback:
        if verbose:
            print("PASSED")
    else:
        if verbose:
            print("FAILED")
Пример #2
0
if "-i" in argv:
    print("[+] List of input devices")
    for i in range(len(ins)):
        print("%d: %s" % (i + 1, ins[i]))
    inDev = ins[int(input("Select input device: ")) - 1]
else:
    inDev = mido.get_input_names()[0]

if "-o" in argv:
    print("[+] List of output devices")
    for i in range(len(outs)):
        print("%d: %s" % (i + 1, outs[i]))
    outDev = ins[int(input("Select output device: ")) - 1]
else:
    outDev = mido.get_output_names()[0]
piano.connect(inDev, outDev)

## Setup Recorder
rec = Recorder()
if not rec.setPiano(piano):
    exit("Could not connect to piano!")

## Setup players/buttons
nButtons = 9
buttons = {}
for i in range(nButtons):
    buttons[i] = Button(piano, rec)

## Run test
print("0-9 to press button")
print("q to quit")