view_with_band_pass_filter.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:tdoa 作者: xiongyihui 项目源码 文件源码
def start(self, quit_event=None, show=None):
        stream = self.pyaudio_instance.open(
            rate=RATE,
            frames_per_buffer=FRAMES,
            format=pyaudio.paInt16,
            channels=2,
            input=True,
            # output_device_index=1,
            stream_callback=self._callback)

        self.event.clear()
        if not quit_event:
            quit_event = threading.Event()

        phat = [0] * (2 * direction_n + 1)
        while not (quit_event.is_set() or self.event.is_set()):
            try:
                data = self.queue.get()

                buf = np.fromstring(data, dtype='int16')
                tau, cc = gcc_phat(buf[0::2] * window, buf[1::2] * window, fs=RATE, max_tau=max_tau, interp=1)
                theta = math.asin(tau / max_tau) * 180 / math.pi
                print('\ntheta: {}'.format(int(theta)))

                for i, v in enumerate(cc):
                    phat[i] = int(v * 512)

                if show:
                    show(phat)
                # print [l for l in level]
            except KeyboardInterrupt:
                break

        stream.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号