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

2024-06-16 12:54:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我的流程图中有3-4个不同的音频源。我想背对背播放每个源(而不是重叠播放),而不必手动启动和停止每个源。本质上,就像计时器一样。例如,播放源1,然后停止,等待15秒,播放源2,等待30秒,依此类推。。。。流程图中是否有可以这样做的块,或者是否有人已经有了可以这样做的python块或类似的东西


Tags: 手动音频计时器流程图本质背对背
1条回答
网友
1楼 · 发布于 2024-06-16 12:54:59

基本上我自己制作了一个嵌入式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])

相关问题 更多 >