8magsvn – Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 pavuk 1 #!/usr/bin/env python
2 #
3 # Copyright 2004,2005,2007 Free Software Foundation, Inc.
4 #
5 # This file is part of GNU Radio
6 #
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11 #
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
21 #
22  
23 from gnuradio import gr, gru, audio
24 from gnuradio import eng_notation
25 from gnuradio.eng_option import eng_option
26 from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider
27 from optparse import OptionParser
28 import wx
29 import sys
30 import time
3 kaklik 31 #import ephem
2 pavuk 32  
33 class app_top_block(stdgui2.std_top_block):
34 def __init__(self, frame, panel, vbox, argv):
35 stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
36  
37 self.frame = frame
38 self.panel = panel
39  
40 parser = OptionParser(option_class=eng_option)
41 parser.add_option("-O", "--audio-output", type="string", default="",
42 help="pcm output device name. E.g., hw:0,0 or /dev/dsp")
43 parser.add_option("-W", "--waterfall", action="store_true", default=False,
44 help="Enable waterfall display")
45 parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
46 help="Enable oscilloscope display")
47 parser.add_option("-I", "--audio-input", type="string", default="",
48 help="pcm input device name. E.g., hw:0,0 or /dev/dsp")
49 parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
50 help="set sample rate to RATE (48000)")
51 parser.add_option("-X", "--prefix", default="./")
52  
53 (options, args) = parser.parse_args()
54  
55 sample_rate = 48000 #int(options.sample_rate)
56  
57 # Set prefix for data files
58 self.prefix = options.prefix
59  
60 if len(args) != 0:
61 parser.print_help()
62 sys.exit(1)
63  
64 self.show_debug_info = True
65  
66 # build the graph
67 lo_freq1 = 16400
68 lo_freq2 = 18300
69 lo_freq3 = 19550
70 lo_freq4 = 20900
71 lo_freq5 = 22100
72 lo_freq6 = 23400
73  
74 self.audioin = audio.source (sample_rate, options.audio_input)
75  
76 lo_bw=150
77 bw_down=100
78 if_rate = 1000
79 if_decim = sample_rate/if_rate
80  
81 input_rate=if_rate
82 integ_rate=1
83 N = input_rate/integ_rate
84  
85 t = range(0,N-1)
86 tapsN = []
87 for i in t:
88 tapsN.append(1.0/N)
89  
90 conv=gr.complex_to_real()
91  
92 #RXBLOK ZACIATOK1
93 self.mygain1=gr.multiply_const_ff(3000)
94 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
95 channel_coeffs_bp1=gr.firdes.band_pass( 1, sample_rate, lo_freq1-lo_bw, lo_freq1+lo_bw, bw_down, gr.firdes.WIN_HANN, 6.76)
96 #audio_decimation, audio_coeffs
97 mybandpass1 = gr.fir_filter_fff (1, channel_coeffs_bp1)
98 channel_coeffs1 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
99 ddc1 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs1, lo_freq1-lo_bw-bw_down, sample_rate)
100  
101 self.detector1 = gr.complex_to_mag_squared()
102 self.integrator11 = gr.fir_filter_fff (N, tapsN)
103 self.integrator31 = gr.single_pole_iir_filter_ff(1)
104 self.probe1 = gr.probe_signal_f();
105  
106 self.connect(self.audioin, self.mygain1, mybandpass1, ddc1, self.detector1, self.integrator11, self.integrator31, self.probe1)
107 #RXBLOK KONIEC
108  
109 #RXBLOK ZACIATOK2
110 self.mygain2=gr.multiply_const_ff(3000)
111 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
112 channel_coeffs_bp2=gr.firdes.band_pass( 1, sample_rate, lo_freq2-lo_bw, lo_freq2+lo_bw, bw_down, gr.firdes.WIN_HANN, 6.76)
113 #audio_decimation, audio_coeffs
114 mybandpass2 = gr.fir_filter_fff (1, channel_coeffs_bp2)
115 channel_coeffs2 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
116 ddc2 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs2, lo_freq2-lo_bw-bw_down, sample_rate)
117  
118 self.detector2 = gr.complex_to_mag_squared()
119 self.integrator12 = gr.fir_filter_fff (N, tapsN)
120 self.integrator32 = gr.single_pole_iir_filter_ff(1)
121 self.probe2 = gr.probe_signal_f();
122  
123 self.connect(self.audioin, self.mygain2, mybandpass2, ddc2, self.detector2, self.integrator12, self.integrator32, self.probe2)
124 #RXBLOK KONIEC
125  
126 #RXBLOK ZACIATOK3
127 self.mygain3=gr.multiply_const_ff(3000)
128 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
129 channel_coeffs_bp3=gr.firdes.band_pass( 1, sample_rate, lo_freq3-lo_bw, lo_freq3+lo_bw, bw_down, gr.firdes.WIN_HANN, 6.76)
130 #audio_decimation, audio_coeffs
131 mybandpass3 = gr.fir_filter_fff (1, channel_coeffs_bp3)
132 channel_coeffs3 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
133 ddc3 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs3, lo_freq3-lo_bw-bw_down, sample_rate)
134  
135 self.detector3 = gr.complex_to_mag_squared()
136 self.integrator13 = gr.fir_filter_fff (N, tapsN)
137 self.integrator33 = gr.single_pole_iir_filter_ff(1)
138 self.probe3 = gr.probe_signal_f();
139  
140 self.connect(self.audioin, self.mygain3, mybandpass3, ddc3, self.detector3, self.integrator13, self.integrator33, self.probe3)
141 #RXBLOK KONIEC
142  
143 #RXBLOK ZACIATOK4
144 self.mygain4=gr.multiply_const_ff(3000)
145 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
146 channel_coeffs_bp4=gr.firdes.band_pass( 1, sample_rate, lo_freq4-lo_bw+50, lo_freq4+lo_bw-50, bw_down, gr.firdes.WIN_HANN, 6.76)
147 #audio_decimation, audio_coeffs
148 mybandpass4 = gr.fir_filter_fff (1, channel_coeffs_bp4)
149 channel_coeffs4 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
150 ddc4 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs4, lo_freq4-lo_bw-bw_down, sample_rate)
151  
152 self.detector4 = gr.complex_to_mag_squared()
153 self.integrator14 = gr.fir_filter_fff (N, tapsN)
154 self.integrator34 = gr.single_pole_iir_filter_ff(1)
155 self.probe4 = gr.probe_signal_f();
156  
157 self.connect(self.audioin, self.mygain4, mybandpass4, ddc4, self.detector4, self.integrator14, self.integrator34, self.probe4)
158 #RXBLOK KONIEC
159  
160 #RXBLOK ZACIATOK5
161 self.mygain5=gr.multiply_const_ff(3000)
162 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
163 channel_coeffs_bp5=gr.firdes.band_pass( 1, sample_rate, lo_freq5-lo_bw, lo_freq5+lo_bw, bw_down, gr.firdes.WIN_HANN, 6.76)
164 #audio_decimation, audio_coeffs
165 mybandpass5 = gr.fir_filter_fff (1, channel_coeffs_bp5)
166 channel_coeffs5 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
167 ddc5 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs5, lo_freq5-lo_bw-bw_down, sample_rate)
168  
169 self.detector5 = gr.complex_to_mag_squared()
170 self.integrator15 = gr.fir_filter_fff (N, tapsN)
171 self.integrator35 = gr.single_pole_iir_filter_ff(1)
172 self.probe5 = gr.probe_signal_f();
173  
174 self.connect(self.audioin, self.mygain5, mybandpass5, ddc5, self.detector5, self.integrator15, self.integrator35, self.probe5)
175 #RXBLOK KONIEC
176  
177 #RXBLOK ZACIATOK6
178 self.mygain6=gr.multiply_const_ff(3000)
179 #gain, sampling_freq, low_cutoff_freq, high_cutoff_freq,transition_width, window, beta
180 channel_coeffs_bp6=gr.firdes.band_pass( 1, sample_rate, lo_freq6-lo_bw, lo_freq6+lo_bw, bw_down, gr.firdes.WIN_HANN, 6.76)
181 #audio_decimation, audio_coeffs
182 mybandpass6 = gr.fir_filter_fff (1, channel_coeffs_bp6)
183 channel_coeffs6 = gr.firdes.low_pass (20.0, sample_rate, 400, 100, gr.firdes.WIN_HANN)
184 ddc6 = gr.freq_xlating_fir_filter_fcf (if_decim, channel_coeffs6, lo_freq6-lo_bw-bw_down, sample_rate)
185  
186 self.detector6 = gr.complex_to_mag_squared()
187 self.integrator16 = gr.fir_filter_fff (N, tapsN)
188 self.integrator36 = gr.single_pole_iir_filter_ff(1)
189 self.probe6 = gr.probe_signal_f();
190  
191 self.connect(self.audioin, self.mygain6, mybandpass6, ddc6, self.detector6, self.integrator16, self.integrator36, self.probe6)
192 #RXBLOK KONIEC
193  
194 #self.scopefft = fftsink2.fft_sink_f (panel, fft_size=512, sample_rate=1000, fft_rate=1)
195 #self.connect(ddc6, conv, self.scopefft)
196  
197 self._build_gui(vbox)
198  
199 # set initial values
200  
201 def _set_status_msg(self, msg):
202 self.frame.GetStatusBar().SetStatusText(msg, 0)
203  
204 def _build_gui(self, vbox):
205  
206 #vbox.Add(self.scopefft.win, 10, wx.EXPAND)
207 self.lmst_timer = wx.PyTimer(self.lmst_timeout)
208 self.lmst_timer.Start(1000)
209  
210 def lmst_timeout(self):
211  
212 self.write_continuum_data(self.probe1.level(),self.probe2.level(),self.probe3.level(),self.probe4.level(),self.probe5.level(),self.probe6.level())
213  
214 def write_continuum_data(self,data1,data2,data3,data4,data5,data6):
215  
216 # Create localtime structure for producing filename
217 foo = time.localtime()
218 pfx = self.prefix
219 filenamestr = "%s/%04d%02d%02d" % (pfx, foo.tm_year,
220 foo.tm_mon, foo.tm_mday)
221  
222 # Open the data file, appending
223 continuum_file = open (filenamestr+".tpdat","a")
224  
225 flt1 = "%8.4f" % data1
226 flt2 = "%8.4f" % data2
227 flt3 = "%8.4f" % data3
228 flt4 = "%8.4f" % data4
229 flt5 = "%8.4f" % data5
230 flt6 = "%8.4f" % data6
231 timestampstr = "%02d:%02d:%02d" % (foo.tm_hour, foo.tm_min, foo.tm_sec)
232 continuum_file.write(timestampstr+" "+flt1+" "+flt2+" "+flt3+" "+flt4+" "+flt5+" "+flt6+"\n")
233  
234 continuum_file.close()
235 return(data1)
236  
237 def main ():
238 app = stdgui2.stdapp(app_top_block, "Audio FFT", nstatus=1)
239 app.MainLoop()
240  
241 if __name__ == '__main__':
242 main ()