首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在GNURadio/GRC中,如何顺序地使用不同的音频源作为输入,而不必手动启动和停止?

在GNURadio/GRC中,如何顺序地使用不同的音频源作为输入,而不必手动启动和停止?
EN

Stack Overflow用户
提问于 2020-12-02 15:20:47
回答 1查看 137关注 0票数 1

我的流程图中有3-4个不同的音频源。我想要播放每个源背对背(而不是覆盖在对方之上),而不必手动启动和停止每个源。本质上表现得像个计时器。例如,播放源1然后停止,等待15秒,播放源2,等待30秒,等等……流程图中是否有可以这样做的块,或者是否有人已经有这样做的python块,或者类似的东西?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-07 19:19:23

在我自己的同类of...basically上,我制作了自己的嵌入式python块,它将我想要的输入延迟很多秒。以下是我想出的:

代码语言:javascript
复制
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])
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65110965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档