def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=5, taps=None, fractional_bw=None, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) # self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/rubus/workdir/data/train01/iq.raw', False) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, inputfilename, False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) # self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/rubus/workdir/data/train01/iq.raw.filtered', False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, outputfilename, False) self.blocks_file_sink_0.set_unbuffered(True) self.band_reject_filter_1 = filter.fir_filter_ccf( 1, firdes.band_reject(1, samp_rate * 2 / 5, 1.16e6, 1.2e6, 10e3, firdes.WIN_HAMMING, 6.76)) self.band_reject_filter_0 = filter.fir_filter_ccf( 1, firdes.band_reject(1, samp_rate * 2 / 5, 340e3, 410e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 5e6, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.band_reject_filter_0, 0), (self.band_reject_filter_1, 0)) self.connect((self.band_reject_filter_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.band_reject_filter_0, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.blocks_throttle_0.set_sample_rate(self.samp_rate) self.band_reject_filter_1.set_taps( firdes.band_reject(1, self.samp_rate * 2 / 5, 1.16e6, 1.2e6, 10e3, firdes.WIN_HAMMING, 6.76)) self.band_reject_filter_0.set_taps( firdes.band_reject(1, self.samp_rate * 2 / 5, 340e3, 410e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
def update_filter(self): self.band_reject_filter_0 = filter.fir_filter_fff( 1, firdes.band_reject(1, self.samp_rate, self.low_cutoff, self.high_cutoff, self.transition_width, firdes.WIN_HAMMING, 6.76)) def setup_blocks(self): self.connect((self.band_reject_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.band_reject_filter_0, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_freq_sink_x_1.set_frequency_range(0, self.samp_rate) self.band_reject_filter_0.set_taps( firdes.band_reject(1, self.samp_rate, self.variable_qtgui_range_3, self.variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0.set_taps( firdes.band_pass(self.variable_qtgui_range_2, self.samp_rate, self.variable_qtgui_range_0, self.variable_qtgui_range_1, 10, firdes.WIN_HAMMING, 6.76))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.band_reject_filter_0.set_taps( firdes.band_reject(1, self.samp_rate, 1000, 1050, 10, firdes.WIN_HAMMING, 6.76))
def update_filter(self): self.band_reject_filter_0 = filter.fir_filter_fff(1, firdes.band_reject(1, self.samp_rate, self.low_cutoff, self.high_cutoff, self.transition_width, firdes.WIN_HAMMING, 6.76)) def setup_blocks(self): self.connect((self.band_reject_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.band_reject_filter_0, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.band_reject_filter_0.set_taps(firdes.band_reject(1, self.samp_rate, 1000, 1050, 10, firdes.WIN_HAMMING, 6.76))
def __init__(self): gr.top_block.__init__(self, "Audio Filter") Qt.QWidget.__init__(self) self.setWindowTitle("Audio Filter") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "Audio_Filter") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.variable_qtgui_range_4 = variable_qtgui_range_4 = 3000 self.variable_qtgui_range_3 = variable_qtgui_range_3 = 3000 self.variable_qtgui_range_2 = variable_qtgui_range_2 = 1 self.variable_qtgui_range_1 = variable_qtgui_range_1 = 2700 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 200 self.step = step = 10 self.samp_rate = samp_rate = 6000 ################################################## # Blocks ################################################## self._variable_qtgui_range_4_range = Range(0, 3000, step, 3000, 200) self._variable_qtgui_range_4_win = RangeWidget( self._variable_qtgui_range_4_range, self.set_variable_qtgui_range_4, 'HIGH BLOCK', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_4_win) self._variable_qtgui_range_3_range = Range(0, 3000, step, 3000, 200) self._variable_qtgui_range_3_win = RangeWidget( self._variable_qtgui_range_3_range, self.set_variable_qtgui_range_3, 'LOW BLOCK', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_3_win) self._variable_qtgui_range_2_range = Range(0, 10, 0.1, 1, 200) self._variable_qtgui_range_2_win = RangeWidget( self._variable_qtgui_range_2_range, self.set_variable_qtgui_range_2, 'VOLUME', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_2_win) self._variable_qtgui_range_1_range = Range(0, 3000, step, 2700, 200) self._variable_qtgui_range_1_win = RangeWidget( self._variable_qtgui_range_1_range, self.set_variable_qtgui_range_1, 'Low PASS', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_1_win) self._variable_qtgui_range_0_range = Range(0, 3000, step, 200, 200) self._variable_qtgui_range_0_win = RangeWidget( self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'High PASS', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_0_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Output", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Input', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.band_reject_filter_0 = filter.fir_filter_fff( 1, firdes.band_reject(1, samp_rate, variable_qtgui_range_3, variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(variable_qtgui_range_2, samp_rate, variable_qtgui_range_0, variable_qtgui_range_1, 10, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(samp_rate, '', True) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.band_reject_filter_0, 0)) self.connect((self.band_reject_filter_0, 0), (self.audio_sink_0, 0)) self.connect((self.band_reject_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.band_pass_filter_0, 0))
def set_variable_qtgui_range_3(self, variable_qtgui_range_3): self.variable_qtgui_range_3 = variable_qtgui_range_3 self.band_reject_filter_0.set_taps( firdes.band_reject(1, self.samp_rate, self.variable_qtgui_range_3, self.variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76))
def __init__(self): gr.top_block.__init__(self, "Audio Filter") Qt.QWidget.__init__(self) self.setWindowTitle("Audio Filter") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "Audio_Filter") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.variable_qtgui_range_4 = variable_qtgui_range_4 = 3000 self.variable_qtgui_range_3 = variable_qtgui_range_3 = 3000 self.variable_qtgui_range_2 = variable_qtgui_range_2 = 1 self.variable_qtgui_range_1 = variable_qtgui_range_1 = 2700 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 200 self.step = step = 10 self.samp_rate = samp_rate = 6000 ################################################## # Blocks ################################################## self._variable_qtgui_range_4_range = Range(0, 3000, step, 3000, 200) self._variable_qtgui_range_4_win = RangeWidget(self._variable_qtgui_range_4_range, self.set_variable_qtgui_range_4, 'HIGH BLOCK', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_4_win) self._variable_qtgui_range_3_range = Range(0, 3000, step, 3000, 200) self._variable_qtgui_range_3_win = RangeWidget(self._variable_qtgui_range_3_range, self.set_variable_qtgui_range_3, 'LOW BLOCK', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_3_win) self._variable_qtgui_range_2_range = Range(0, 10, 0.1, 1, 200) self._variable_qtgui_range_2_win = RangeWidget(self._variable_qtgui_range_2_range, self.set_variable_qtgui_range_2, 'VOLUME', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_2_win) self._variable_qtgui_range_1_range = Range(0, 3000, step, 2700, 200) self._variable_qtgui_range_1_win = RangeWidget(self._variable_qtgui_range_1_range, self.set_variable_qtgui_range_1, 'Low PASS', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_1_win) self._variable_qtgui_range_0_range = Range(0, 3000, step, 200, 200) self._variable_qtgui_range_0_win = RangeWidget(self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'High PASS', "counter_slider", float) self.top_layout.addWidget(self._variable_qtgui_range_0_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Output", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Input', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.band_reject_filter_0 = filter.fir_filter_fff(1, firdes.band_reject( 1, samp_rate, variable_qtgui_range_3, variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( variable_qtgui_range_2, samp_rate, variable_qtgui_range_0, variable_qtgui_range_1, 10, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(samp_rate, '', True) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.band_reject_filter_0, 0)) self.connect((self.band_reject_filter_0, 0), (self.audio_sink_0, 0)) self.connect((self.band_reject_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.band_pass_filter_0, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) self.qtgui_freq_sink_x_1.set_frequency_range(0, self.samp_rate) self.band_reject_filter_0.set_taps(firdes.band_reject(1, self.samp_rate, self.variable_qtgui_range_3, self.variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0.set_taps(firdes.band_pass(self.variable_qtgui_range_2, self.samp_rate, self.variable_qtgui_range_0, self.variable_qtgui_range_1, 10, firdes.WIN_HAMMING, 6.76))
def set_variable_qtgui_range_3(self, variable_qtgui_range_3): self.variable_qtgui_range_3 = variable_qtgui_range_3 self.band_reject_filter_0.set_taps(firdes.band_reject(1, self.samp_rate, self.variable_qtgui_range_3, self.variable_qtgui_range_4, 10, firdes.WIN_HAMMING, 6.76))