3 # Copyright 2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
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 2, or (at your option)
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.
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.
24 # All Your Frequencies are Belong to Us!
26 # Transmit NBFM message on 25 channels simultaneously!
29 from gnuradio import gr, gru, eng_notation
30 from gnuradio import usrp
31 from gnuradio import audio
32 from gnuradio import blks
33 from gnuradio import optfir
34 from gnuradio.eng_option import eng_option
35 from optparse import OptionParser
40 from gnuradio.wxgui import stdgui, fftsink
44 def make_random_complex_tuple(L):
47 result.append(complex(random.gauss(0, 1),random.gauss(0, 1)))
52 src = gr.vector_source_c(make_random_complex_tuple(32*1024), True)
56 def plot_taps(taps, sample_rate=2):
57 return gru.gnuplot_freqz (gru.freqz (taps, 1), sample_rate)
60 class ayfabtu_graph (stdgui.gui_flow_graph):
61 def __init__(self, frame, panel, vbox, argv):
62 stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
64 parser = OptionParser (option_class=eng_option)
65 parser.add_option ("-c", "--duc-freq", type="eng_float", default=29.325e6,
66 help="set Tx ddc frequency to FREQ", metavar="FREQ")
67 (options, args) = parser.parse_args ()
74 self.usrp_interp = 256
75 self.usrp_rate = self.dac_rate / self.usrp_interp # 500 kS/s
76 self.audio_rate = 32000 # 32 kS/s
78 self.audio_src = gr.file_source(gr.sizeof_float, "ayfabtu.dat", True)
80 ahp_taps = gr.firdes.high_pass(1, # gain
85 self.audio_hp = gr.fir_filter_fff(1, ahp_taps)
87 self.audio_gain = gr.multiply_const_ff(AUDIO_GAIN)
89 null_src = gr.null_source(gr.sizeof_gr_complex)
90 #noise_src = gr.noise_source_c(gr.GR_UNIFORM, 1, 0)
91 noise_src = random_noise_c()
94 artaps = optfir.low_pass(1, # gain
99 50, # stopband atten in dB
102 artaps = gr.firdes.low_pass(1, # gain
107 print "len(artaps) =", len(artaps)
108 self.audio_resampler = blks.rational_resampler_fff(self, 15, 32, artaps)
110 self.fm_mod = blks.nbfm_tx(self, 15000, 15000, max_dev=4.5e3)
113 fbtaps = gr.firdes.low_pass(1, # gain
118 print "len(fbtabs) =", len(fbtaps)
119 #self.plot = plot_taps(fbtaps, 25*15e3)
120 self.filter_bank = blks.synthesis_filterbank(self, nchan, fbtaps)
122 self.if_gain = gr.multiply_const_cc(IF_GAIN)
125 ifrtaps = optfir.low_pass(1,
130 50, # stopband atten in dB
133 ifrtaps = gr.firdes.low_pass(1,
140 print "len(ifrtaps) =", len(ifrtaps)
141 self.if_resampler = blks.rational_resampler_ccf(self, 4, 3, ifrtaps)
144 self.u = usrp.sink_c(0, 256)
145 self.u.set_tx_freq(0, options.duc_freq)
146 self.u.set_pga(0, self.u.pga_max())
148 # wire it all together
150 self.connect(self.audio_src, self.audio_hp, self.audio_gain,
151 self.audio_resampler, self.fm_mod)
153 null_sink = gr.null_sink(gr.sizeof_gr_complex)
155 for i in range(nchan):
157 self.connect(self.fm_mod, (self.filter_bank, i))
159 self.connect(null_src, (self.filter_bank, i))
161 self.connect(self.filter_bank, self.if_gain, self.if_resampler, self.u)
165 app = stdgui.stdapp (ayfabtu_graph, "All Your Frequency Are Belong to Us")
168 if __name__ == '__main__':