python - 在 GNURadio/GRC 中,如何顺序使用不同的音频源作为输入,而无需手动启动和停止?
问题描述
我的流程图中有 3-4 个不同的音频源。我想背靠背播放每个源(而不是相互重叠),而不必手动启动和停止每个源。本质上,就像一个计时器。例如,播放源 1 然后停止,等待 15 秒,播放源 2,等待 30 秒,依此类推......流程图中是否有可以执行此操作的块,或者是否有人有执行此操作的 python 块已经或类似的东西?
解决方案
以我自己的方式想出来......基本上我制作了自己的嵌入式python块,它将我想要的输入延迟了这么多秒。这是我想出的:
import time
import numpy as np
from gnuradio import gr
class blk(gr.sync_block):
"""Embedded Python Block that time delays the input file"""
# initializes the GRC Block input, output, block title, and parameters
def __init__(self, delay = 0):
gr.sync_block.__init__(
self,
name='Time Delayed Input',
in_sig=[np.float32],
out_sig=[np.float32]
)
# sets a callback for time delay in seconds specified in the GRC block
self.delay = time.sleep(delay)
def work(self, input_items, output_items):
# sets output equal to the input to just pass through the block
output_items[0][:] = input_items[0]
# calls a time delay in seconds
sleep.delay
# returns the input as the output after the specified delay
return len(output_items[0])
推荐阅读
- reactjs - 从与 ether.js 的反应中查询视图函数的最佳方法?
- javascript - 获取“TypeError:无法使用 Nextjs 读取未定义的属性“替换”
- sublimetext3 - Sublime Text:如何禁用或更新突出显示的粉红色线条的颜色?
- java - 接受 ArrayList 的方法删除单词并返回 Acronym
- mongodb - 使用 Mongo 4 在 Web2py SQLFORM 上 PyDAL 引发错误
- linux - dpkg/systemd 错误:cp: '/etc/resolv.conf' 和 '/run/systemd/resolve/stub-resolv.conf' 是同一个文件
- reactjs - React 不会在页面刷新或手动 URL 输入时呈现
- memory - 调试内核 ECC 清理。ARM v7 Cyclone V SOC
- javascript - 如何在浏览器窗口中访问自定义属性
- nginx - 使用 Nginx 和/或 Traefik 为 ML 模型提供服务