예제 #1
0
 def __init__(self,device, queue):
     threading.Thread.__init__(self, name="midireader")
     pypm.init()
     self._input = pypm.Input(device)
     self._stopevent = threading.Event()
     self._sleepperiod = 1.0
     self._queue = queue
예제 #2
0
	def __init__(self, queue):
		global inputs
		global outputs
		
		self.queue = queue
		self.stop = False
		self.initflag = threading.Event()
		threading.Thread.__init__(self)
		
		pm.init()
		
		for i in range(0,pm.get_count()):
			dev = {}
			dev["info"] = pm.get_device_info(i)
			dev["name"] = dev["info"][1]
			dev["input"] = dev["info"][2]
			
			if dev["input"] == 1:
				dev["obj"] = pm.Input(i)
				inputs.append(dev)
			else:
				dev["obj"] = pm.Output(i)
				outputs.append(dev)
		
		self.initflag.set()
예제 #3
0
 def __init__(self,device):
     threading.Thread.__init__(self, name="dispatcher")
     pypm.init()
     self._input = pypm.Input(device)
     self._stopevent = threading.Event()
     self._sleepperiod = 1.0
     self.file = None
     self.file_obj = None
     self.logger = None
     self.observers = {}
예제 #4
0
  def __init__(self):
    gtk.DrawingArea.__init__(self)

    self.keys = read_keys()

    self.set_flags(gtk.CAN_FOCUS)

    self.connect("expose-event", self.expose)

    # Init pyportmidi
    pyportmidi.init()
    count = pyportmidi.get_count()
    devices = []
    for id in range(count):
      dev = pyportmidi.get_device_info(id)
      if dev[2]:
        d = list(dev)
        d.append(id)
        devices.append(d)
    if devices:
      print "Choose your MIDI device:"
      for dev in devices:
        print "ID: %d, %s interface is %s"%(dev[5], dev[0], dev[1])
    else:
      print "Sorry, no MIDI input device found. :("
      exit(1)

    dev = int(raw_input("Your choice: "))

    try:
      self.dev = pyportmidi.Input(dev)
    except:
      print "Invalid ID or bad MIDI device."
      exit(1)

    # Timeout for MIDI device
    gobject.timeout_add(0, self.midi_timeout)

    # Timeout for refresh screen
    gobject.timeout_add(0, self.expose_timeout)
예제 #5
0
파일: __init__.py 프로젝트: manno23/Hydra
    def run(self):

        t = threading.Thread(target=self.server.serve_forever)
        t.daemon = True
        t.start()

        pyportmidi.init()

        print('\n\n')
        print('\t _   ___   _____________  ___  ')
        print('\t| | | \ \ / /  _  \ ___ \/ _ \ ')
        print('\t| |_| |\ V /| | | | |_/ / /_\ \\')
        print('\t|  _  | \ / | | | |    /|  _  |')
        print('\t| | | | | | | |/ /| |\ \| | | |')
        print('\t\_| |_/ \_/ |___/ \_| \_\_| |_/')
        print('\n')
        print('\t          HAS BEGUN...')
        print('\n\n')
        print('Ctl-c to exit.')


        # This is the event loop that processes network/midi events
        while True:
            try:
                # Get items off the network queue
                try:
                    msg = self.msg_queue.get(timeout=1/15)
                    self.cm.handle_message(self.mh, msg)
                except queue.Empty:
                    pass

                # Get items from the midi buffer
                self.cm.handle_midi(self.mh)

            except KeyboardInterrupt:
                break