def xInit(self, signals, noises, sinks): # ------------------------------------------------------------------------ self.sources = {} self.mutes = {} self.amps = {} #sources for signal in signals: self.sources[signal] = gr.sig_source_f( self.samprate, gr.GR_SIN_WAVE, 440, 0.25, 0) self.mutes[signal] = gr.mute_ff(True) self.amps[signal] = gr.multiply_const_ff(0.25) for noise in noises: self.sources[noise] = analog.noise_source_f( analog.GR_LAPLACIAN, 1, 0) self.mutes[noise] = gr.mute_ff(True) self.amps[noise] = gr.multiply_const_ff(0.25) #mixer if len(self.sources) > 1: self.adder = self.add = gr.add_vff(1) else: self.adder = gr.multiply_const_vff((1, )) self.level = gr.multiply_const_ff(1) #sinks self.sinks = sinks self.audiomute = gr.mute_ff(True) self.audio = audio.sink(self.samprate, "", True) self.udp = gr.null_sink(gr.sizeof_float) self.rawfile = gr.null_sink(gr.sizeof_float) self.wavefile = gr.null_sink(gr.sizeof_float)
def __init__(self, controller, muted=True): # ------------------------------------------------------------------------ super(AudioSourceAdapter, self).__init__() self.controller = controller self.samprate = controller.samprate self.source = audio.source(self.samprate, "", True) self.mute = gr.mute_ff(muted)
def __init__(self, controller, filename="", muted=True): # ------------------------------------------------------------------------ super(FileSourceAdapter, self).__init__() self.controller = controller self.samprate = controller.samprate if filename: self.source = gr.file_source(gr.sizeof_float, filename, True) else: self.source = gr.null_source(gr.sizeof_float) self.mute = gr.mute_ff(muted)
def __init__(self, controller, ac_couple_key, sample_rate_key): gr.hier_block2.__init__( self, "ac_couple", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float), ) #blocks lpf = gr.single_pole_iir_filter_ff(0.0) sub = gr.sub_ff() mute = gr.mute_ff() #connect self.connect(self, sub, self) self.connect(self, lpf, mute, (sub, 1)) #subscribe controller.subscribe(ac_couple_key, lambda x: mute.set_mute(not x)) controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(0.05)) #initialize controller[ac_couple_key] = controller[ac_couple_key] controller[sample_rate_key] = controller[sample_rate_key]
def __init__(self, controller, ac_couple_key, ac_couple, sample_rate_key): gr.hier_block2.__init__( self, "ac_couple", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float), ) #blocks lpf = gr.single_pole_iir_filter_ff(0.0) sub = gr.sub_ff() mute = gr.mute_ff() #connect self.connect(self, sub, self) self.connect(self, lpf, mute, (sub, 1)) #subscribe controller.subscribe(ac_couple_key, lambda x: mute.set_mute(not x)) controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(2.0/x)) #initialize controller[ac_couple_key] = ac_couple controller[sample_rate_key] = controller[sample_rate_key]
def __init__(self, controller, address="", muted=True): # ------------------------------------------------------------------------ super(UdpSourceAdapter, self).__init__() self.controller = controller self.source = self.xUdpSource(address) or self.xNullSource() self.mute = gr.mute_ff(muted)