Rev Author Line No. Line
4918 kaklik 1 #!/usr/bin/env python
2 ##################################################
3 # Gnuradio Python Flow Graph
4 # Title: Records Player
5 # Author: Jakub Kakona
6 # Generated: Fri May 30 01:39:46 2014
7 ##################################################
8  
9 from gnuradio import blocks
10 from gnuradio import eng_notation
11 from gnuradio import filter
12 from gnuradio import gr
13 from gnuradio import wxgui
14 from gnuradio.eng_option import eng_option
15 from gnuradio.fft import window
16 from gnuradio.filter import firdes
17 from gnuradio.wxgui import scopesink2
18 from gnuradio.wxgui import waterfallsink2
19 from grc_gnuradio import wxgui as grc_wxgui
20 from optparse import OptionParser
21 import wx
22  
23 class Records_player(grc_wxgui.top_block_gui):
24  
25 def __init__(self):
26 grc_wxgui.top_block_gui.__init__(self, title="Records Player")
27 _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
28 self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
29  
30 ##################################################
31 # Variables
32 ##################################################
33 self.prefix = prefix = "/media/kaklik/Radio_zaloha/2014-05-02/"
34 self.out_dir = out_dir = "/home/kaklik/git/pysdr/"
35 self.filename = filename = "2014.05.02.14.58.50.dat"
36 self.srcfile = srcfile = prefix+filename
37 self.samp_rate = samp_rate = 5e6
38 self.outfile_ADC2 = outfile_ADC2 = out_dir+filename+"ADC2.wav"
39 self.outfile_ADC1 = outfile_ADC1 = out_dir+filename+"ADC1.wav"
40 self.out_sample_rate = out_sample_rate = int(2e3)
41 self.normalize = normalize = 1/200.0
42 self.cutoff = cutoff = 1000
43 self.LO = LO = 286078822.488
44  
45 ##################################################
46 # Blocks
47 ##################################################
48 self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
49 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF signal")
50 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Scope")
51 self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod")
52 self.Add(self.notebook_0)
53 self.wxgui_waterfallsink2_1_0 = waterfallsink2.waterfall_sink_c(
54 self.notebook_0.GetPage(2).GetWin(),
55 baseband_freq=0,
56 dynamic_range=100,
57 ref_level=0,
58 ref_scale=2.0,
59 sample_rate=out_sample_rate,
60 fft_size=512,
61 fft_rate=15,
62 average=False,
63 avg_alpha=None,
64 title="IF Plot",
65 win=window.blackmanharris,
66 size=(1200, 400),
67 )
68 self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_1_0.win)
69 self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
70 self.notebook_0.GetPage(2).GetWin(),
71 baseband_freq=0,
72 dynamic_range=100,
73 ref_level=0,
74 ref_scale=2.0,
75 sample_rate=out_sample_rate,
76 fft_size=512,
77 fft_rate=15,
78 average=False,
79 avg_alpha=None,
80 title="IF Plot",
81 win=window.blackmanharris,
82 size=(1200,400),
83 )
84 self.notebook_0.GetPage(2).Add(self.wxgui_waterfallsink2_1.win)
85 self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
86 self.notebook_0.GetPage(0).GetWin(),
87 baseband_freq=0,
88 dynamic_range=100,
89 ref_level=0,
90 ref_scale=2.0,
91 sample_rate=samp_rate,
92 fft_size=1024,
93 fft_rate=15,
94 average=False,
95 avg_alpha=None,
96 title="ADC1 Waterfall Plot",
97 )
98 self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
99 self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
100 self.notebook_0.GetPage(0).GetWin(),
101 baseband_freq=0,
102 dynamic_range=100,
103 ref_level=0,
104 ref_scale=2.0,
105 sample_rate=samp_rate,
106 fft_size=512,
107 fft_rate=15,
108 average=False,
109 avg_alpha=None,
110 title="ADC2 Waterfall Plot",
111 win=window.hanning,
112 )
113 self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
114 self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
115 self.GetWin(),
116 title="Scope Plot",
117 sample_rate=out_sample_rate,
118 v_scale=0,
119 v_offset=0,
120 t_scale=0,
121 ac_couple=False,
122 xy_mode=True,
123 num_inputs=1,
124 trig_mode=wxgui.TRIG_MODE_AUTO,
125 y_axis_label="Counts",
126 )
127 self.Add(self.wxgui_scopesink2_2.win)
128 self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
129 self.notebook_0.GetPage(1).GetWin(),
130 title="Scope Plot",
131 sample_rate=samp_rate/2,
132 v_scale=0,
133 v_offset=0,
134 t_scale=1e-2,
135 ac_couple=False,
136 xy_mode=False,
137 num_inputs=2,
138 trig_mode=wxgui.TRIG_MODE_AUTO,
139 y_axis_label="Counts",
140 )
141 self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_1.win)
142 self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
143 self.notebook_0.GetPage(1).GetWin(),
144 title="Scope Plot",
145 sample_rate=samp_rate,
146 v_scale=0,
147 v_offset=0,
148 t_scale=0,
149 ac_couple=False,
150 xy_mode=False,
151 num_inputs=4,
152 trig_mode=wxgui.TRIG_MODE_AUTO,
153 y_axis_label="Counts",
154 )
155 self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win)
156 self.low_pass_filter_0_0 = filter.fir_filter_ccf(int(samp_rate/out_sample_rate), firdes.low_pass(
157 normalize, samp_rate, cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
158 self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/out_sample_rate), firdes.low_pass(
159 normalize, samp_rate, cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
160 self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, ([1]), 143050000-LO/2, samp_rate)
161 self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, ([1]), 143050000-LO/2, samp_rate)
162 self.blocks_wavfile_sink_1_0 = blocks.wavfile_sink(outfile_ADC2, 2, out_sample_rate, 16)
163 self.blocks_wavfile_sink_1 = blocks.wavfile_sink(outfile_ADC1, 2, out_sample_rate, 16)
164 self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_short*1, 10)
165 self.blocks_short_to_float_2_0 = blocks.short_to_float(1, 1)
166 self.blocks_short_to_float_2 = blocks.short_to_float(1, 1)
167 self.blocks_short_to_float_1_0 = blocks.short_to_float(1, 1)
168 self.blocks_short_to_float_1 = blocks.short_to_float(1, 1)
169 self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1)
170 self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
171 self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
172 self.blocks_interleave_0_2 = blocks.interleave(gr.sizeof_short*1)
173 self.blocks_interleave_0_1 = blocks.interleave(gr.sizeof_short*1)
174 self.blocks_interleave_0_0 = blocks.interleave(gr.sizeof_short*1)
175 self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short*1)
176 self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
177 self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
178 self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*10, srcfile, False)
179 self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
180 self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
181  
182 ##################################################
183 # Connections
184 ##################################################
185 self.connect((self.blocks_vector_to_streams_0, 2), (self.blocks_interleave_0_2, 0))
186 self.connect((self.blocks_vector_to_streams_0, 3), (self.blocks_interleave_0_2, 1))
187 self.connect((self.blocks_vector_to_streams_0, 4), (self.blocks_interleave_0_1, 0))
188 self.connect((self.blocks_vector_to_streams_0, 5), (self.blocks_interleave_0_1, 1))
189 self.connect((self.blocks_vector_to_streams_0, 6), (self.blocks_interleave_0_0, 0))
190 self.connect((self.blocks_vector_to_streams_0, 7), (self.blocks_interleave_0_0, 1))
191 self.connect((self.blocks_vector_to_streams_0, 8), (self.blocks_interleave_0, 0))
192 self.connect((self.blocks_vector_to_streams_0, 9), (self.blocks_interleave_0, 1))
193 self.connect((self.blocks_file_source_0, 0), (self.blocks_vector_to_streams_0, 0))
194 self.connect((self.blocks_interleave_0, 0), (self.blocks_short_to_float_1, 0))
195 self.connect((self.blocks_interleave_0_0, 0), (self.blocks_short_to_float_0, 0))
196 self.connect((self.blocks_short_to_float_1, 0), (self.wxgui_scopesink2_0, 3))
197 self.connect((self.blocks_short_to_float_0, 0), (self.wxgui_scopesink2_0, 2))
198 self.connect((self.blocks_interleave_0_1, 0), (self.blocks_short_to_float_1_0, 0))
199 self.connect((self.blocks_interleave_0_2, 0), (self.blocks_short_to_float_0_0, 0))
200 self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))
201 self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0))
202 self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0))
203 self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_float_0_0, 0))
204 self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.low_pass_filter_0_0, 0))
205 self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_waterfallsink2_1_0, 0))
206 self.connect((self.blocks_short_to_float_2_0, 0), (self.wxgui_scopesink2_1, 1))
207 self.connect((self.blocks_short_to_float_2, 0), (self.wxgui_scopesink2_1, 0))
208 self.connect((self.blocks_vector_to_streams_0, 1), (self.blocks_short_to_float_2_0, 0))
209 self.connect((self.blocks_vector_to_streams_0, 0), (self.blocks_short_to_float_2, 0))
210 self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
211 self.connect((self.blocks_float_to_complex_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
212 self.connect((self.blocks_short_to_float_0_0, 0), (self.blocks_float_to_complex_0_0, 0))
213 self.connect((self.blocks_short_to_float_1_0, 0), (self.blocks_float_to_complex_0_0, 1))
214 self.connect((self.blocks_short_to_float_1, 0), (self.blocks_float_to_complex_0, 1))
215 self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
216 self.connect((self.blocks_short_to_float_0_0, 0), (self.wxgui_scopesink2_0, 0))
217 self.connect((self.blocks_short_to_float_1_0, 0), (self.wxgui_scopesink2_0, 1))
218 self.connect((self.blocks_float_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))
219 self.connect((self.blocks_float_to_complex_0_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
220 self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_wavfile_sink_1_0, 0))
221 self.connect((self.blocks_complex_to_float_0_0, 1), (self.blocks_wavfile_sink_1_0, 1))
222 self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_1, 0))
223 self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_1, 1))
224 self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
225 self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
226 self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.wxgui_scopesink2_2, 0))
227  
228  
229 # QT sink close method reimplementation
230  
231 def get_prefix(self):
232 return self.prefix
233  
234 def set_prefix(self, prefix):
235 self.prefix = prefix
236 self.set_srcfile(self.prefix+self.filename)
237  
238 def get_out_dir(self):
239 return self.out_dir
240  
241 def set_out_dir(self, out_dir):
242 self.out_dir = out_dir
243 self.set_outfile_ADC2(self.out_dir+self.filename+"ADC2.wav")
244 self.set_outfile_ADC1(self.out_dir+self.filename+"ADC1.wav")
245  
246 def get_filename(self):
247 return self.filename
248  
249 def set_filename(self, filename):
250 self.filename = filename
251 self.set_outfile_ADC2(self.out_dir+self.filename+"ADC2.wav")
252 self.set_outfile_ADC1(self.out_dir+self.filename+"ADC1.wav")
253 self.set_srcfile(self.prefix+self.filename)
254  
255 def get_srcfile(self):
256 return self.srcfile
257  
258 def set_srcfile(self, srcfile):
259 self.srcfile = srcfile
260 self.blocks_file_source_0.open(self.srcfile, False)
261  
262 def get_samp_rate(self):
263 return self.samp_rate
264  
265 def set_samp_rate(self, samp_rate):
266 self.samp_rate = samp_rate
267 self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
268 self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate/2)
269 self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate)
270 self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate)
271 self.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
272 self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
273  
274 def get_outfile_ADC2(self):
275 return self.outfile_ADC2
276  
277 def set_outfile_ADC2(self, outfile_ADC2):
278 self.outfile_ADC2 = outfile_ADC2
279 self.blocks_wavfile_sink_1_0.open(self.outfile_ADC2)
280  
281 def get_outfile_ADC1(self):
282 return self.outfile_ADC1
283  
284 def set_outfile_ADC1(self, outfile_ADC1):
285 self.outfile_ADC1 = outfile_ADC1
286 self.blocks_wavfile_sink_1.open(self.outfile_ADC1)
287  
288 def get_out_sample_rate(self):
289 return self.out_sample_rate
290  
291 def set_out_sample_rate(self, out_sample_rate):
292 self.out_sample_rate = out_sample_rate
293 self.wxgui_waterfallsink2_1_0.set_sample_rate(self.out_sample_rate)
294 self.wxgui_waterfallsink2_1.set_sample_rate(self.out_sample_rate)
295 self.wxgui_scopesink2_2.set_sample_rate(self.out_sample_rate)
296  
297 def get_normalize(self):
298 return self.normalize
299  
300 def set_normalize(self, normalize):
301 self.normalize = normalize
302 self.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
303 self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
304  
305 def get_cutoff(self):
306 return self.cutoff
307  
308 def set_cutoff(self, cutoff):
309 self.cutoff = cutoff
310 self.low_pass_filter_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
311 self.low_pass_filter_0_0.set_taps(firdes.low_pass(self.normalize, self.samp_rate, self.cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
312  
313 def get_LO(self):
314 return self.LO
315  
316 def set_LO(self, LO):
317 self.LO = LO
318 self.freq_xlating_fir_filter_xxx_0.set_center_freq(143050000-self.LO/2)
319 self.freq_xlating_fir_filter_xxx_0_0.set_center_freq(143050000-self.LO/2)
320  
321 if __name__ == '__main__':
322 import ctypes
323 import os
324 if os.name == 'posix':
325 try:
326 x11 = ctypes.cdll.LoadLibrary('libX11.so')
327 x11.XInitThreads()
328 except:
329 print "Warning: failed to XInitThreads()"
330 parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
331 (options, args) = parser.parse_args()
332 tb = Records_player()
333 tb.Start(True)
334 tb.Wait()
335