Beispiel #1
0
    def __init__(self, num_channels, listen_func=None, input_func=None):
        super(Audio, self).__init__()

        assert (num_channels == 1 or num_channels == 2)
        self.num_channels = num_channels
        self.listen_func = listen_func
        self.input_func = input_func
        self.audio = pyaudio.PyAudio()

        out_dev, in_dev, buffer_size, sr = self._get_parameters()
        Audio.sample_rate = sr

        # create stream
        self.stream = self.audio.open(format=pyaudio.paFloat32,
                                      channels=num_channels,
                                      frames_per_buffer=buffer_size,
                                      rate=Audio.sample_rate,
                                      output=True,
                                      input=input_func != None,
                                      output_device_index=out_dev,
                                      input_device_index=in_dev)

        self.generator = None
        self.cpu_time = 0
        core.register_terminate_func(self.close)
Beispiel #2
0
   def __init__(self, listener = None):
      super(Audio, self).__init__()

      self.audio = pyaudio.PyAudio()
      out_idx = self._find_device_name("Built-in Output")
      in_idx = self._find_device_name("C-Media USB Headphone Set")


      self.stream = self.audio.open(format = pyaudio.paFloat32,
                                    channels = kOutputChannels,
                                    frames_per_buffer = 512,
                                    rate = kSamplingRate,
                                    output = True,
                                    input = False,
                                    output_device_index = out_idx,
                                    input_device_index = in_idx,
                                    stream_callback = self._callback)

      self.stream2 = self.audio.open(format = pyaudio.paFloat32,
                                    channels = 1,
                                    frames_per_buffer = 512,
                                    rate = kSamplingRate,
                                    output = True,
                                    input = True,
                                    output_device_index = out_idx,
                                    input_device_index = in_idx,
                                    stream_callback = self._callback2)

      self.gain = .5
      self.generators = []
      self.listener = listener
      core.register_terminate_func(self.close)
   def __init__(self, listener = None):
      super(Audio, self).__init__()

      self.audio = pyaudio.PyAudio()
      dev_idx = self._find_best_output()

      self.stream = self.audio.open(format = pyaudio.paFloat32,
                                    channels = kOutputChannels,
                                    frames_per_buffer = 512,
                                    rate = kSamplingRate,
                                    output = True,
                                    input = False,
                                    output_device_index = None,
                                    stream_callback = self._callback)
      self.gain = .5
      self.generators = []
      self.listener = listener
      core.register_terminate_func(self.close)
Beispiel #4
0
   def __init__(self, listener = None):
      super(Audio, self).__init__()

      self.audio = pyaudio.PyAudio()
      dev_idx = self._find_best_output()

      self.stream = self.audio.open(format = pyaudio.paFloat32,
                                    channels = kOutputChannels,
                                    frames_per_buffer = 512,
                                    rate = kSamplingRate,
                                    output = True,
                                    input = False,
                                    output_device_index = dev_idx,
                                    stream_callback = self._callback)
      self.gain = .5
      self.generators = []
      self.listener = listener
      core.register_terminate_func(self.close)
Beispiel #5
0
    def __init__(self, remote_ip=None, pos_type=kBody):
        super(Kinect, self).__init__()

        self.pos_type = pos_type

        # Synapse is running on a remote machine:
        if remote_ip:
            listen_ip = socket.gethostbyname(socket.gethostname())
            listen_port = 12345

            send_ip = remote_ip
            send_port = 12321

        # Synapse is running locally on this machine, using localhost
        else:
            listen_ip = 'localhost'
            listen_port = 12345

            send_ip = 'localhost'
            send_port = 12346

        self.server = OSCServer((listen_ip, listen_port))
        self.server.addMsgHandler('/tracking_skeleton',
                                  self.callback_tracking_skeleton)
        self.server.addMsgHandler('default', self.callback_ignore)

        # create the client, which sends control messages to Synapse
        self.client = OSCClient()
        self.client.connect((send_ip, send_port))

        # member vars
        self.active_joints = {}
        self.last_heartbeat_time = 0
        self.done_running = False

        # start the server listening for messages
        self.start()

        core.register_terminate_func(self.close)
Beispiel #6
0
   def __init__(self, remote_ip = None):
      super(Kinect, self).__init__()

      core.register_terminate_func(self.close)

      # Synapse is running on a remote machine:
      if remote_ip:
         listen_ip = socket.gethostbyname(socket.gethostname())
         listen_port = 12345

         send_ip = remote_ip
         send_port = 12321

      # Synapse is running locally on this machine, using localhost
      else:
         listen_ip = 'localhost'
         listen_port = 12345

         send_ip = 'localhost'
         send_port = 12346

      self.server = OSCServer( (listen_ip, listen_port) )
      self.server.addMsgHandler( '/tracking_skeleton', self.callback_tracking_skeleton )
      self.server.addMsgHandler( 'default', self.callback_ignore )

      # create the client, which sends control messages to Synapse
      self.client = OSCClient()
      self.client.connect( (send_ip, send_port) )

      # member vars
      self.active_joints = {}
      self.last_heartbeat_time = 0
      self.done_running = False

      # start the server listening for messages
      self.start()