Ejemplo n.º 1
0
    def set_mic(self, mic_name=None):
        # select a new live input
        from onyx.audio.liveaudio import inputs, default_input, LiveAudioSource, device_info
        if mic_name is not None:
            mic_id = None
            if isinstance(mic_name, str):
                for id, chan, name, manu in inputs():
                    if name.lower().find(mic_name.lower()) != -1:
                        mic_id = id
                        break
            if mic_id is None:
                print 'no microphone matching %r' % mic_name
                return
        else:
            mic_id = default_input()
        assert mic_id is not None
        new_mic = LiveAudioSource(mic_id, verbose=False)

        # remove the old input
        if self.current_mic is not None:
            state = self.current_mic.state
            sendee = self.current_mic.sendee
            self.current_mic.done()
        else:
            state = sendee = None

        self.current_mic = new_mic
        if sendee is not None:
            self.current_mic.set_sendee(sendee)
            # XXX knows too much about LiveAudioSource
            if state == 'running':
                self.current_mic.start()
        global start, stop
        start = doer(self.current_mic.start)
        stop = doer(self.current_mic.stop)
        # hack to avoid printing the first time the mic is set, which happens
        # when the module is loaded, and which messes up doctesting verification
        if not (state is sendee is None):
            print ', '.join(device_info(mic_id))
Ejemplo n.º 2
0
 def list(self):
     from onyx.audio.liveaudio import inputs
     for id, chan, name, manu in inputs():
         print name