3
# Copyright 2004,2005,2007 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 3, 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.
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
31
class app_top_block(stdgui2.std_top_block):
32
def __init__(self, frame, panel, vbox, argv):
33
stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
38
parser = OptionParser(option_class=eng_option)
39
parser.add_option("-W", "--waterfall", action="store_true", default=False,
40
help="Enable waterfall display")
41
parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
42
help="Enable oscilloscope display")
43
parser.add_option("-I", "--audio-input", type="string", default="",
44
help="pcm input device name. E.g., hw:0,0 or /dev/dsp")
45
parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
46
help="set sample rate to RATE (48000)")
48
(options, args) = parser.parse_args()
49
sample_rate = int(options.sample_rate)
55
self.show_debug_info = True
60
waterfallsink2.waterfall_sink_f (panel, fft_size=1024, sample_rate=sample_rate)
61
elif options.oscilloscope:
62
self.scope = scopesink2.scope_sink_f(panel, sample_rate=sample_rate)
64
self.scope = fftsink2.fft_sink_f (panel, fft_size=1024, sample_rate=sample_rate, fft_rate=30,
65
ref_scale=1.0, ref_level=0, y_divs=12)
67
self.src = audio.source (sample_rate, options.audio_input)
69
self.connect(self.src, self.scope)
75
def _set_status_msg(self, msg):
76
self.frame.GetStatusBar().SetStatusText(msg, 0)
78
def _build_gui(self, vbox):
80
def _form_set_freq(kv):
81
return self.set_freq(kv['freq'])
83
vbox.Add(self.scope.win, 10, wx.EXPAND)
85
#self._build_subpanel(vbox)
87
def _build_subpanel(self, vbox_arg):
88
# build a secondary information panel (sometimes hidden)
90
# FIXME figure out how to have this be a subpanel that is always
91
# created, but has its visibility controlled by foo.Show(True/False)
93
def _form_set_decim(kv):
94
return self.set_decim(kv['decim'])
96
if not(self.show_debug_info):
103
#panel = wx.Panel(self.panel, -1)
104
#vbox = wx.BoxSizer(wx.VERTICAL)
106
hbox = wx.BoxSizer(wx.HORIZONTAL)
109
myform['decim'] = form.int_field(
110
parent=panel, sizer=hbox, label="Decim",
111
callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg))
114
myform['fs@usb'] = form.static_float_field(
115
parent=panel, sizer=hbox, label="Fs@USB")
118
myform['dbname'] = form.static_text_field(
119
parent=panel, sizer=hbox)
122
myform['baseband'] = form.static_float_field(
123
parent=panel, sizer=hbox, label="Analog BB")
126
myform['ddc'] = form.static_float_field(
127
parent=panel, sizer=hbox, label="DDC")
130
vbox.Add(hbox, 0, wx.EXPAND)
134
app = stdgui2.stdapp(app_top_block, "Audio FFT", nstatus=1)
137
if __name__ == '__main__':