Example #1
0
    def run(self):
        self.running = True
        pypm.Initialize()
        self.in_device = pypm.Input(self.in_device_id)
        self.out_device = pypm.Output(self.out_device_id)

        self.clear()

        #    try:
        #      while self.running:
        #        self.read_buttons()
        #    finally:
        #      print("Shutting down.")
        #      self.in_device.Close()
        #      self.out_device.Close()
        #      pypm.Terminate()
        #
        #    return

        try:
            while self.running:
                self.set_pattern(0)
                time.sleep(self.wait)
                self.set_pattern(1)
                time.sleep(self.wait)

        finally:
            print("Shutting down.")
            self.clear()
            self.in_device.Close()
            self.out_device.Close()
            pypm.Terminate()
Example #2
0
def main( argv ):
	pypm.Initialize()
	deviceInput = None
	deviceOutput = None
	blockAddress = None
	latency = 0
	try:
		opts, args = getopt.getopt( argv, "i:o:b:", [ "input=", "output=", "blockAddress=" ] )
		for opt, arg in opts:
			if opt in ( "-i", "--input" ):
				deviceInput = arg
			elif opt in ( "-o", "--output" ):
				deviceOutput = arg
			elif opt in ( "-b", "--blockAddress" ):
				blockAddress = arg
		if deviceInput == None or deviceOutput == None or blockAddress == None:
			usage()
			sys.exit( 2 )
	except getopt.GetoptError:
		usage()
		sys.exit( 2 )

	SysexTest( deviceInput, deviceOutput, blockAddress, latency )

	pypm.Terminate()
Example #3
0
def main(config):
    pypm.Initialize()
    if config.device:
        d = find_device(config.device)
    else:
        d = (config.indevice, config.outdevice)
    if not d is None or not (d[0] is None or d[1] is None):
        #    try:
        #      in_device = pypm.Input(d[0])
        #    except:
        #      print("Error: Could not open input device.")
        #      pypm.Terminate()
        #      return
        #
        #    try:
        #      out_device = pypm.Output(d[1])
        #    except:
        #      print("Error: Could not open output device.")
        #      pypm.Terminate()
        #      return
        print d
        uidriver = MidiDriver(d[0], d[1])
        if config.verbose:
            uidriver = DebugDriver(uidriver)

        try:
            time.sleep(2)
            print 'Life()'
            life = Life(uidriver)
            print 'run()'
            life.run(1)
            print 'Done.'
        except Exception as e:
            traceback.print_exc()
        finally:
            uidriver.clear()
            uidriver.close()
            pypm.Terminate()
            return
    else:
        print 'No input/output device found.  Exiting.'
Example #4
0
 def __destroy__(self):
     pypm.Terminate()
Example #5
0
 def __dealloc__(self):
     pypm.Terminate()
 def Disconnect(self):
     pypm.Terminate()
     self.lights = None
     self.connect_label['fg'] = 'red'
     self.connect_label['text'] = 'disconnected'
Example #7
0
 def __del__(self):
     self.stop()
     pypm.Terminate()
Example #8
0
    MidiOut.Write(ChordList)
    while pypm.Time() < MidiTime + 1000 + len(chord) * 1000 : pass
    ChordList = []
    # seems a little odd that they don't update MidiTime here...
    for i in range(len(chord)):
        ChordList.append([[0x90,chord[i],0], MidiTime + 1000 * i])
    MidiOut.Write(ChordList)
    print("Sending SysEx messages...")
    # sending with timestamp = 0 should be the same as sending with
    # timestamp = pypm.Time()
    dummy = raw_input("ready to send a SysEx string with timestamp = 0 ... (type RETURN):")
    MidiOut.WriteSysEx(0,'\xF0\x7D\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\xF7')
    dummy = raw_input("ready to send a SysEx list with timestamp = pypm.Time() ... (type RETURN):")
    MidiOut.WriteSysEx(pypm.Time(), [0xF0, 0x7D, 0x10, 0x11, 0x12, 0x13, 0xF7])
    dummy = raw_input("ready to close and terminate... (type RETURN):")
    del MidiOut

# main code begins here
pypm.Initialize() # always call this first, or OS may crash when you try to open a stream
x=0
while (x<1) | (x>2):
    print """
enter your choice...
1: test input
2: test output
    """
    x=int(raw_input())
    if x==1: TestInput()
    else: TestOutput()
    pypm.Terminate()
Example #9
0
 def terminate(self):
     pypm.Terminate()