#!/usr/bin/env python################################################### Gnuradio Python Flow Graph# Title: Records Player# Author: Jakub Kakona# Generated: Fri May 30 01:39:46 2014##################################################from gnuradio import blocksfrom gnuradio import eng_notationfrom gnuradio import filterfrom gnuradio import grfrom gnuradio import wxguifrom gnuradio.eng_option import eng_optionfrom gnuradio.fft import windowfrom gnuradio.filter import firdesfrom gnuradio.wxgui import scopesink2from gnuradio.wxgui import waterfallsink2from grc_gnuradio import wxgui as grc_wxguifrom optparse import OptionParserimport wxclass Records_player(grc_wxgui.top_block_gui):def __init__(self):grc_wxgui.top_block_gui.__init__(self, title="Records Player")_icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))################################################### Variables##################################################self.prefix = prefix = "/media/kaklik/Radio_zaloha/2014-05-02/"self.out_dir = out_dir = "/home/kaklik/git/pysdr/"self.filename = filename = "2014.05.02.14.58.50.dat"self.srcfile = srcfile = prefix+filenameself.samp_rate = samp_rate = 5e6self.outfile_ADC2 = outfile_ADC2 = out_dir+filename+"ADC2.wav"self.outfile_ADC1 = outfile_ADC1 = out_dir+filename+"ADC1.wav"self.out_sample_rate = out_sample_rate = int(2e3)self.normalize = normalize = 1/200.0self.cutoff = cutoff = 1000self.LO = LO = 286078822.488################################################### Blocks##################################################self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF signal")self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Scope")self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod")self.Add(self.notebook_0)self.wxgui_waterfallsink2_1_0 = waterfallsink2.waterfall_sink_c(self.notebook_0.GetPage(2).GetWin(),baseband_freq=0,dynamic_range=100,ref_level=0,ref_scale=2.0,sample_rate=out_sample_rate,fft_size=512,fft_rate=15,average=False,avg_alpha=None,title="IF Plot",win=window.blackmanharris,size=(1200, 400),)self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_1_0.win)self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(self.notebook_0.GetPage(2).GetWin(),baseband_freq=0,dynamic_range=100,ref_level=0,ref_scale=2.0,sample_rate=out_sample_rate,fft_size=512,fft_rate=15,average=False,avg_alpha=None,title="IF Plot",win=window.blackmanharris,size=(1200,400),)self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_1.win)self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(self.notebook_0.GetPage(0).GetWin(),baseband_freq=0,dynamic_range=100,ref_level=0,ref_scale=2.0,sample_rate=samp_rate,fft_size=1024,fft_rate=15,average=False,avg_alpha=None,title="ADC1 Waterfall Plot",)self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(self.notebook_0.GetPage(0).GetWin(),baseband_freq=0,dynamic_range=100,ref_level=0,ref_scale=2.0,sample_rate=samp_rate,fft_size=512,fft_rate=15,average=False,avg_alpha=None,title="ADC2 Waterfall Plot",win=window.hanning,)self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(self.GetWin(),title="Scope Plot",sample_rate=out_sample_rate,v_scale=0,v_offset=0,t_scale=0,ac_couple=False,xy_mode=True,num_inputs=1,trig_mode=wxgui.TRIG_MODE_AUTO,y_axis_label="Counts",)self.Add(self.wxgui_scopesink2_2.win)self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(self.notebook_0.GetPage(1).GetWin(),title="Scope Plot",sample_rate=samp_rate/2,v_scale=0,v_offset=0,t_scale=1e-2,ac_couple=False,xy_mode=False,num_inputs=2,trig_mode=wxgui.TRIG_MODE_AUTO,y_axis_label="Counts",)self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_1.win)self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(self.notebook_0.GetPage(1).GetWin(),title="Scope Plot",sample_rate=samp_rate,v_scale=0,v_offset=0,t_scale=0,ac_couple=False,xy_mode=False,num_inputs=4,trig_mode=wxgui.TRIG_MODE_AUTO,y_axis_label="Counts",)self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)self.low_pass_filter_0_0 = filter.fir_filter_ccf(int(samp_rate/out_sample_rate), firdes.low_pass(normalize, samp_rate, cutoff, 1e3, firdes.WIN_HAMMING, 6.76))self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/out_sample_rate), firdes.low_pass(normalize, samp_rate, cutoff, 1e3, firdes.WIN_HAMMING, 6.76))self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, ([1]), 143050000-LO/2, samp_rate)self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, ([1]), 143050000-LO/2, samp_rate)self.blocks_wavfile_sink_1_0 = blocks.wavfile_sink(outfile_ADC2, 2, out_sample_rate, 16)self.blocks_wavfile_sink_1 = blocks.wavfile_sink(outfile_ADC1, 2, out_sample_rate, 16)self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_short*1, 10)self.blocks_short_to_float_2_0 = blocks.short_to_float(1, 1)self.blocks_short_to_float_2 = blocks.short_to_float(1, 1)self.blocks_short_to_float_1_0 = blocks.short_to_float(1, 1)self.blocks_short_to_float_1 = blocks.short_to_float(1, 1)self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1)self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)self.blocks_interleave_0_2 = blocks.interleave(gr.sizeof_short*1)self.blocks_interleave_0_1 = blocks.interleave(gr.sizeof_short*1)self.blocks_interleave_0_0 = blocks.interleave(gr.sizeof_short*1)self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short*1)self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)self.blocks_float_to_complex_0 = blocks.float_to_complex(1)self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*10, srcfile, False)self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)self.blocks_complex_to_float_0 = blocks.complex_to_float(1)################################################### Connections##################################################self.connect((self.blocks_vector_to_streams_0, 2), (self.blocks_interleave_0_2, 0))self.connect((self.blocks_vector_to_streams_0, 3), (self.blocks_interleave_0_2, 1))self.connect((self.blocks_vector_to_streams_0, 4), (self.blocks_interleave_0_1, 0))self.connect((self.blocks_vector_to_streams_0, 5), (self.blocks_interleave_0_1, 1))self.connect((self.blocks_vector_to_streams_0, 6), (self.blocks_interleave_0_0, 0))self.connect((self.blocks_vector_to_streams_0, 7), (self.blocks_interleave_0_0, 1))self.connect((self.blocks_vector_to_streams_0, 8), (self.blocks_interleave_0, 0))self.connect((self.blocks_vector_to_streams_0, 9), (self.blocks_interleave_0, 1))self.connect((self.blocks_file_source_0, 0), (self.blocks_vector_to_streams_0, 0))self.connect((self.blocks_interleave_0, 0), (self.blocks_short_to_float_1, 0))self.connect((self.blocks_interleave_0_0, 0), (self.blocks_short_to_float_0, 0))self.connect((self.blocks_short_to_float_1, 0), (self.wxgui_scopesink2_0, 3))self.connect((self.blocks_short_to_float_0, 0), (self.wxgui_scopesink2_0, 2))self.connect((self.blocks_interleave_0_1, 0), (self.blocks_short_to_float_1_0, 0))self.connect((self.blocks_interleave_0_2, 0), (self.blocks_short_to_float_0_0, 0))self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0))self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0))self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_float_0_0, 0))self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.low_pass_filter_0_0, 0))self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_waterfallsink2_1_0, 0))self.connect((self.blocks_short_to_float_2_0, 0), (self.wxgui_scopesink2_1, 1))self.connect((self.blocks_short_to_float_2, 0), (self.wxgui_scopesink2_1, 0))self.connect((self.blocks_vector_to_streams_0, 1), (self.blocks_short_to_float_2_0, 0))self.connect((self.blocks_vector_to_streams_0, 0), (self.blocks_short_to_float_2, 0))self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))self.connect((self.blocks_float_to_complex_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_float_to_complex_0_0, 0))self.connect((self.blocks_short_to_float_1_0, 0), (self.blocks_float_to_complex_0_0, 1))self.connect((self.blocks_short_to_float_1, 0), (self.blocks_float_to_complex_0, 1))self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))self.connect((self.blocks_short_to_float_0_0, 0), (self.wxgui_scopesink2_0, 0))self.connect((self.blocks_short_to_float_1_0, 0), (self.wxgui_scopesink2_0, 1))self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))self.connect((self.blocks_float_to_complex_0_0, 0), (self.wxgui_waterfallsink2_0_0, 0))self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_wavfile_sink_1_0, 0))self.connect((self.blocks_complex_to_float_0_0, 1), (self.blocks_wavfile_sink_1_0, 1))self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_1, 0))self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_1, 1))self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.wxgui_scopesink2_2, 0))# QT sink close method reimplementationdef get_prefix(self):return self.prefixdef set_prefix(self, prefix):self.prefix = prefixself.set_srcfile(self.prefix+self.filename)def get_out_dir(self):return self.out_dirdef set_out_dir(self, out_dir):self.out_dir = out_dirself.set_outfile_ADC2(self.out_dir+self.filename+"ADC2.wav")self.set_outfile_ADC1(self.out_dir+self.filename+"ADC1.wav")def get_filename(self):return self.filenamedef set_filename(self, filename):self.filename = filenameself.set_outfile_ADC2(self.out_dir+self.filename+"ADC2.wav")self.set_outfile_ADC1(self.out_dir+self.filename+"ADC1.wav")self.set_srcfile(self.prefix+self.filename)def get_srcfile(self):return self.srcfiledef set_srcfile(self, srcfile):self.srcfile = srcfileself.blocks_file_source_0.open(self.srcfile, False)def get_samp_rate(self):return self.samp_ratedef set_samp_rate(self, samp_rate):self.samp_rate = samp_rateself.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/2)self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate)self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)self.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))def get_outfile_ADC2(self):return self.outfile_ADC2def set_outfile_ADC2(self, outfile_ADC2):self.outfile_ADC2 = outfile_ADC2self.blocks_wavfile_sink_1_0.open(self.outfile_ADC2)def get_outfile_ADC1(self):return self.outfile_ADC1def set_outfile_ADC1(self, outfile_ADC1):self.outfile_ADC1 = outfile_ADC1self.blocks_wavfile_sink_1.open(self.outfile_ADC1)def get_out_sample_rate(self):return self.out_sample_ratedef set_out_sample_rate(self, out_sample_rate):self.out_sample_rate = out_sample_rateself.wxgui_waterfallsink2_1_0.set_sample_rate(self.out_sample_rate)self.wxgui_waterfallsink2_1.set_sample_rate(self.out_sample_rate)self.wxgui_scopesink2_2.set_sample_rate(self.out_sample_rate)def get_normalize(self):return self.normalizedef set_normalize(self, normalize):self.normalize = normalizeself.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))def get_cutoff(self):return self.cutoffdef set_cutoff(self, cutoff):self.cutoff = cutoffself.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))def get_LO(self):return self.LOdef set_LO(self, LO):self.LO = LOself.freq_xlating_fir_filter_xxx_0.set_center_freq(143050000-self.LO/2)self.freq_xlating_fir_filter_xxx_0_0.set_center_freq(143050000-self.LO/2)if __name__ == '__main__':import ctypesimport osif os.name == 'posix':try:x11 = ctypes.cdll.LoadLibrary('libX11.so')x11.XInitThreads()except:print "Warning: failed to XInitThreads()"parser = OptionParser(option_class=eng_option, usage="%prog: [options]")(options, args) = parser.parse_args()tb = Records_player()tb.Start(True)tb.Wait()