diff options
Diffstat (limited to 'gnuradio-examples')
22 files changed, 136 insertions, 655 deletions
diff --git a/gnuradio-examples/.gitignore b/gnuradio-examples/.gitignore deleted file mode 100644 index 29ec71e01..000000000 --- a/gnuradio-examples/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/Makefile -/Makefile.in -/aclocal.m4 -/configure -/config.h.in -/stamp-h.in -/libtool -/config.log -/config.h -/config.cache -/config.status -/missing -/stamp-h -/stamp-h1 -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/autom4te.cache -/*.cache -/missing -/make.log -/gnuradio.pc diff --git a/gnuradio-examples/Makefile.am b/gnuradio-examples/Makefile.am deleted file mode 100644 index ded4e743d..000000000 --- a/gnuradio-examples/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright 2004,2007,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = - -if PYTHON -SUBDIRS += python grc -endif -if GUILE -SUBDIRS += waveforms -endif diff --git a/gnuradio-examples/grc/.gitignore b/gnuradio-examples/grc/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/grc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/grc/Makefile.am b/gnuradio-examples/grc/Makefile.am deleted file mode 100644 index f8906ea67..000000000 --- a/gnuradio-examples/grc/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -grc_examples_prefix = $(exampledir)/grc - -audiodatadir = $(grc_examples_prefix)/audio -dist_audiodata_DATA = \ - audio/dial_tone.grc \ - audio/cvsd_sweep.grc - -demoddatadir = $(grc_examples_prefix)/demod -dist_demoddata_DATA = \ - demod/mpsk_demod.grc \ - demod/pam_timing.grc \ - demod/pam_sync.grc \ - demod/digital_freq_lock.grc - -simpledatadir = $(grc_examples_prefix)/simple -dist_simpledata_DATA = \ - simple/ber_simulation.grc \ - simple/dpsk_loopback.grc \ - simple/variable_config.grc - -trellisdatadir = $(grc_examples_prefix)/trellis -dist_trellisdata_DATA = \ - trellis/readme.txt \ - trellis/interference_cancellation.grc \ - trellis/pccc.grc \ - trellis/pccc1.grc \ - trellis/sccc.grc \ - trellis/sccc1.grc - -uhddatadir = $(grc_examples_prefix)/uhd -dist_uhddata_DATA = \ - uhd/uhd_const_wave.grc \ - uhd/uhd_dpsk_mod.grc \ - uhd/uhd_rx_dpsk.grc \ - uhd/uhd_tx_dpsk.grc \ - uhd/uhd_fft.grc \ - uhd/uhd_two_tone_loopback.grc \ - uhd/uhd_wbfm_receive.grc - -xmlrpcdatadir = $(grc_examples_prefix)/xmlrpc -dist_xmlrpcdata_DATA = \ - xmlrpc/readme.txt \ - xmlrpc/xmlrpc_client.grc \ - xmlrpc/xmlrpc_client_script.py\ - xmlrpc/xmlrpc_server.grc diff --git a/gnuradio-examples/grc/uhd/.gitignore b/gnuradio-examples/grc/uhd/.gitignore deleted file mode 100644 index f6c10401f..000000000 --- a/gnuradio-examples/grc/uhd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.py -*.pyc diff --git a/gnuradio-examples/python/.gitignore b/gnuradio-examples/python/.gitignore deleted file mode 100644 index c400497f5..000000000 --- a/gnuradio-examples/python/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/*.pyo diff --git a/gnuradio-examples/python/Makefile.am b/gnuradio-examples/python/Makefile.am deleted file mode 100644 index 4327fd359..000000000 --- a/gnuradio-examples/python/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2004,2007,2009,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = \ - mp-sched \ - network \ - pfb \ - tags diff --git a/gnuradio-examples/python/mp-sched/.gitignore b/gnuradio-examples/python/mp-sched/.gitignore deleted file mode 100644 index c400497f5..000000000 --- a/gnuradio-examples/python/mp-sched/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/*.pyo diff --git a/gnuradio-examples/python/mp-sched/Makefile.am b/gnuradio-examples/python/mp-sched/Makefile.am deleted file mode 100644 index 98fa283ef..000000000 --- a/gnuradio-examples/python/mp-sched/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/mp-sched - -dist_ourdata_DATA = \ - README - -dist_ourdata_SCRIPTS = \ - plot_flops.py \ - run_synthetic.py \ - synthetic.py \ - wfm_rcv_pll_to_wav.py diff --git a/gnuradio-examples/python/network/.gitignore b/gnuradio-examples/python/network/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/python/network/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/python/network/Makefile.am b/gnuradio-examples/python/network/Makefile.am deleted file mode 100644 index 77cacbfd2..000000000 --- a/gnuradio-examples/python/network/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2007,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/network - -dist_ourdata_SCRIPTS = \ - audio_sink.py \ - audio_source.py \ - dial_tone_sink.py \ - dial_tone_source.py \ - vector_sink.py \ - vector_source.py diff --git a/gnuradio-examples/python/pfb/.gitignore b/gnuradio-examples/python/pfb/.gitignore deleted file mode 100644 index 282522db0..000000000 --- a/gnuradio-examples/python/pfb/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/gnuradio-examples/python/pfb/CMakeLists.txt b/gnuradio-examples/python/pfb/CMakeLists.txt index 55dbb16ac..88fdf2ead 100644 --- a/gnuradio-examples/python/pfb/CMakeLists.txt +++ b/gnuradio-examples/python/pfb/CMakeLists.txt @@ -29,6 +29,7 @@ GR_PYTHON_INSTALL(PROGRAMS resampler.py synth_filter.py synth_to_chan.py + reconstruction.py DESTINATION ${GR_PKG_DATA_DIR}/examples/pfb COMPONENT "gnuradio_examples" ) diff --git a/gnuradio-examples/python/pfb/Makefile.am b/gnuradio-examples/python/pfb/Makefile.am deleted file mode 100644 index 39c81bfc2..000000000 --- a/gnuradio-examples/python/pfb/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/pfb - -dist_ourdata_SCRIPTS = \ - channelize.py \ - chirp_channelize.py \ - decimate.py \ - interpolate.py \ - fmtest.py \ - resampler.py \ - synth_filter.py \ - synth_to_chan.py - -dist_ourdata_DATA = \ - resampler_demo.grc diff --git a/gnuradio-examples/python/pfb/channelize.py b/gnuradio-examples/python/pfb/channelize.py index 999e5d20e..2fcb14a36 100755 --- a/gnuradio-examples/python/pfb/channelize.py +++ b/gnuradio-examples/python/pfb/channelize.py @@ -68,7 +68,7 @@ class pfb_top_block(gr.top_block): self.head = gr.head(gr.sizeof_gr_complex, self._N) # Construct the channelizer filter - self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps) + self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps, 1) # Construct a vector sink for the input signal to the channelizer self.snk_i = gr.vector_sink_c() @@ -77,6 +77,9 @@ class pfb_top_block(gr.top_block): self.connect(self.add, self.head, self.pfb) self.connect(self.add, self.snk_i) + # Use this to play with the channel mapping + #self.pfb.set_channel_map([5,6,7,8,0,1,2,3,4]) + # Create a vector sink for each of M output channels of the filter and connect it self.snks = list() for i in xrange(self._M): diff --git a/gnuradio-examples/python/pfb/reconstruction.py b/gnuradio-examples/python/pfb/reconstruction.py new file mode 100755 index 000000000..2b6f9a831 --- /dev/null +++ b/gnuradio-examples/python/pfb/reconstruction.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +import scipy, math, pylab +from scipy import fftpack +from gnuradio import gr, digital, blks2 + +fftlen = 8192 + +def main(): + N = 10000 + fs = 2000.0 + Ts = 1.0/fs + t = scipy.arange(0, N*Ts, Ts) + + # When playing with the number of channels, be careful about the filter + # specs and the channel map of the synthesizer set below. + nchans = 10 + + # Build the filter(s) + bw = 1000 + tb = 400 + proto_taps = gr.firdes.low_pass_2(1, nchans*fs, bw, tb, 80, + gr.firdes.WIN_BLACKMAN_hARRIS) + print "Filter length: ", len(proto_taps) + + + # Create a modulated signal + npwr = 0.01 + data = scipy.random.randint(0, 256, N) + rrc_taps = gr.firdes.root_raised_cosine(1, 2, 1, 0.35, 41) + + src = gr.vector_source_b(data.astype(scipy.uint8).tolist(), False) + mod = digital.bpsk_mod(samples_per_symbol=2) + chan = gr.channel_model(npwr) + rrc = gr.fft_filter_ccc(1, rrc_taps) + + # Split it up into pieces + channelizer = blks2.pfb_channelizer_ccf(nchans, proto_taps, 2) + + # Put the pieces back together again + syn_taps = [nchans*t for t in proto_taps] + synthesizer = gr.pfb_synthesis_filterbank_ccf(nchans, syn_taps, True) + src_snk = gr.vector_sink_c() + snk = gr.vector_sink_c() + + # Remap the location of the channels + # Can be done in synth or channelizer (watch out for rotattions in + # the channelizer) + synthesizer.set_channel_map([ 0, 1, 2, 3, 4, + 15, 16, 17, 18, 19]) + + tb = gr.top_block() + tb.connect(src, mod, chan, rrc, channelizer) + tb.connect(rrc, src_snk) + + vsnk = [] + for i in xrange(nchans): + tb.connect((channelizer,i), (synthesizer, i)) + + vsnk.append(gr.vector_sink_c()) + tb.connect((channelizer,i), vsnk[i]) + + tb.connect(synthesizer, snk) + tb.run() + + sin = scipy.array(src_snk.data()[1000:]) + sout = scipy.array(snk.data()[1000:]) + + + # Plot original signal + fs_in = nchans*fs + f1 = pylab.figure(1, figsize=(16,12), facecolor='w') + s11 = f1.add_subplot(2,2,1) + s11.psd(sin, NFFT=fftlen, Fs=fs_in) + s11.set_title("PSD of Original Signal") + s11.set_ylim([-200, -20]) + + s12 = f1.add_subplot(2,2,2) + s12.plot(sin.real[1000:1500], "o-b") + s12.plot(sin.imag[1000:1500], "o-r") + s12.set_title("Original Signal in Time") + + start = 1 + skip = 4 + s13 = f1.add_subplot(2,2,3) + s13.plot(sin.real[start::skip], sin.imag[start::skip], "o") + s13.set_title("Constellation") + s13.set_xlim([-2, 2]) + s13.set_ylim([-2, 2]) + + # Plot channels + nrows = int(scipy.sqrt(nchans)) + ncols = int(scipy.ceil(float(nchans)/float(nrows))) + + f2 = pylab.figure(2, figsize=(16,12), facecolor='w') + for n in xrange(nchans): + s = f2.add_subplot(nrows, ncols, n+1) + s.psd(vsnk[n].data(), NFFT=fftlen, Fs=fs_in) + s.set_title("Channel {0}".format(n)) + s.set_ylim([-200, -20]) + + # Plot reconstructed signal + fs_out = 2*nchans*fs + f3 = pylab.figure(3, figsize=(16,12), facecolor='w') + s31 = f3.add_subplot(2,2,1) + s31.psd(sout, NFFT=fftlen, Fs=fs_out) + s31.set_title("PSD of Reconstructed Signal") + s31.set_ylim([-200, -20]) + + s32 = f3.add_subplot(2,2,2) + s32.plot(sout.real[1000:1500], "o-b") + s32.plot(sout.imag[1000:1500], "o-r") + s32.set_title("Reconstructed Signal in Time") + + start = 2 + skip = 4 + s33 = f3.add_subplot(2,2,3) + s33.plot(sout.real[start::skip], sout.imag[start::skip], "o") + s33.set_title("Constellation") + s33.set_xlim([-2, 2]) + s33.set_ylim([-2, 2]) + + pylab.show() + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass + diff --git a/gnuradio-examples/python/tags/.gitignore b/gnuradio-examples/python/tags/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/python/tags/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/python/tags/Makefile.am b/gnuradio-examples/python/tags/Makefile.am deleted file mode 100644 index 5d71bf9b0..000000000 --- a/gnuradio-examples/python/tags/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/tags - -dist_ourdata_SCRIPTS = \ - test_file_tags.py \ - uhd_burst_detector.py - diff --git a/gnuradio-examples/waveforms/.gitignore b/gnuradio-examples/waveforms/.gitignore deleted file mode 100644 index 16c984055..000000000 --- a/gnuradio-examples/waveforms/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/*.la -/*.lo diff --git a/gnuradio-examples/waveforms/Makefile.am b/gnuradio-examples/waveforms/Makefile.am deleted file mode 100644 index c07020a5c..000000000 --- a/gnuradio-examples/waveforms/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright 2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/waveforms - -dist_ourdata_DATA = \ - README \ - dial-tone.wfd diff --git a/gnuradio-examples/waveforms/README b/gnuradio-examples/waveforms/README deleted file mode 100644 index afaf1db73..000000000 --- a/gnuradio-examples/waveforms/README +++ /dev/null @@ -1,270 +0,0 @@ -# -# Copyright 2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -Introduction ------------- - -This directory contains example "Waveform Description Files" that are -designed to be loaded and run using the gr-run-waveform command. - -"Waveform Description Files" are written in an extended dialect of the -Scheme language. The dialect is "The Revised^5 Report on the -Algorithmic Language Scheme" (R5RS)[1] as implemented and extended by -Guile 1.8 [2], extended with the GNU Radio specific "define-waveform" -macro and "gr-run-waveform" command. - -For those of you who may be unfamiliar with the Scheme language, -it's a very simple high-level language defined by a brief 50 page -specification[1]. Those 50 pages define the language, standard -libraries and the formal semantics! - -For a quick tutorial introduction see the first 30 pages of "How to -Teach Yourself Scheme in Fixnum Days"[3] (This covers a different -Scheme dialect, but the first 30 pages or so are valid for Guile too.) - -Another text worth mentioning is "How To Design Programs"[4], a book -on the systematic design of computer programs which utilizes Scheme. - - -A Quick Walk-Through --------------------- - -We'll use dial-tone.wfd as our example. - -Assuming that you've already built and installed GNU Radio, you can -run dial-tone.wfd using: - - $ gr-run-waveform <prefix>/share/gnuradio/examples/waveforms/dial-tone.wfd - -where <prefix> is the location where GNU Radio is installed, typically /usr/local. - - -Here is dial-tone.wfd in its entirety: - -;; Start of dial-tone.wfd - -(use-modules (gnuradio audio_alsa)) - -(define-waveform (dial-tone cmd-line-args) - (vars - (sample-rate 48000) - (ampl 0.1)) - - (blocks - (src0 (gr:sig-source-f sample-rate gr:GR-SIN-WAVE 350 ampl)) - (src1 (gr:sig-source-f sample-rate gr:GR-SIN-WAVE 440 ampl)) - (sink (gr:audio-alsa-sink sample-rate "plughw:0,0"))) - - (connections - (src0 (list sink 0)) ; src0 to left input - (src1 (list sink 1)))) ; src1 to right input - -;; End of dial-tone.wfd - - -By default, waveforms have all of gnuradio-core available for their -use. This line: - - (use-modules (gnuradio audio_alsa)) - -imports the audio_alsa module, which we need for the audio sink. -Unlike python, there's no gr.<foo> notation. All names exported by -the (gnuradio audio_alsa) module are made available in the current -module. - - -"define-waveform" is where the real work gets done. -It has this general structure: - -(define-waveform (<waveform-name> cmd-line-args) - (vars - (<variable-name-1> <variable-value-1>) - ...) - - (blocks - (<block-variable-name-1> <block-value-1>) - ...) - - (connections - (<endpoint-1> ...) - ...)) - - -<waveform-name> is an identifier that names the waveform. - -Identifiers are similar to identifiers in other programming languages. -They are a sequence of letters, digits and "extended alphabetic -characters" that begins with a character that cannot begin a number. -"extended alphabetic characters" include: - - ! $ % & * + - . / : < = > ? @ ^ _ - - -By convention in Scheme and LISP, '-' is used in preference to '_' in identifiers. - -<variable-names> and <block-variable-names> name variables that store -associated values, which may be any Scheme value. (<block-variables> -should contain only instances of GNU Radio blocks.) - - -<variable-value-*> and <block-value-*> may be any valid Scheme expression. -E.g., constants, nested function calls, bindings using "let", or -lambda expressions. - - -The (connections ...) section contains 0 or more lists of endpoints, -specifying which endpoints are to be connected together. In the -general case, endpoints have both a block and a port number, though -the port number defaults to zero if not specified. - -To specify a port number, create a two element list of the block and -port number as illustrated above. - -Like the python implementation, more than a pair of endpoints can be -strung together. Assuming blk0, blk1 and blk2 are block variables, -this would connect blk0, output 0, to blk1, input 0; blk1, output 0 to -blk2, input 0: - - (connect - (blk0 blk1 blk2)) - -It could also be written like this: - - (connect - (blk0 blk1) - (blk1 blk2)) - -Or even more verbosely as: - - (connect - ((list blk0 0) (list blk1 0)) - ((list blk1 0) (list blk2 0))) - -And finally, using Scheme's quasiquote mechanism, this works too: - - (connect - (`(,blk0 0) (,blk1 0)) - (`(,blk1 0) (,blk2 0))) - - -When gr-run-waveform loads the waveform file, it expands the -define-waveform section into code that creates a GNU Radio top block, -creates and initializes all variables and blocks specified in the -respective sections and connects them together according the -connections specifications. Finally it runs the resulting GNU Radio -flowgraph. - - -Naming conventions (or what's my block called???!!!) ----------------------------------------------------- - -All GNU Radio block constructors as well as everything else wrapped -for export by SWIG starts with a "gr:" prefix. This is to avoid -collisions with any built in Scheme procedures. - -All blocks contained in gnuradio-core are named like this: - - C++ name Python name Guile name - -------- ----------- ---------- - gr_head gr.head gr:head - gr_add_const_ff gr.add_const_ff gr:add-const-ff - - -GNU Radio blocks in any other component besides gnuradio-core use a -slightly different convention. They also start with gr: but in -addition include the component name after the gr:. This is because -Scheme implements its namespace differently than Python does. -Thus: - - C++ name Python name Guile name - -------- ----------- ---------- - audio_alsa_sink audio_alsa.sink gr:audio-alsa-sink - audio_jack_sink audio_jack.sink gr:audio-jack-sink - usrp2_sink_32fc usrp2.sink_32fc gr:usrp2-sink-32fc - - -Now, because we're working in Scheme and not C++ or Python, the -calling of class methods (member functions) is different too. SWIG -converts C++ member functions into what are called "generic functions" -using GOOPS[5], Guile's object oriented extension. (For those familar -with Common Lisp, GOOPS is very close in spirit to CLOS, the Common -Lisp Object System, but adapted for the Scheme language.) - -Assuming "u2" is a variable holding an instance of a usrp2 sink, -these all retrieve the current interpolation value: - - C++ Python Guile - -------- ----------- ---------- - u2->interp() u2.interp() (gr:interp u2) - - -Mapping of Guile types to/from C++ ----------------------------------- - -The mapping is similar in flavor to the Python <-> C++ mapping - - C++ Python Guile - -------- ----------- ---------- - true True #t - false False #f - "a string" "a string" "a string" - 3.14159 3.14159 3.14159 - gr_complex(1,-1) 1-1j 1-1i - vector<int> (1, 2, 3) #(1 2 3) - vector<float> (1.0, 2.0, 3.0) #(1.0 2.0 3.0) - - -You can find examples of each block constructor being called by -looking in the guile QA code contained in gnuradio-core/src/guile/tests/*.test -The types and values passed are syntactically correct, but don't -necessarily doing anything meaningful. - - -gr-run-waveform vs gr-run-waveform-script vs gr-run-waveform-binary -------------------------------------------------------------------- - -There are two implementations of gr-run-waveform: -gr-run-waveform-script and gr-run-waveform-binary. gr-run-waveform is -symlinked to one of them, with preference to gr-run-waveform-binary if -the gr-run-waveform component was built and installed. - -gr-run-waveform-script is contained in gnuradio-core and uses the -system's Guile interpreter and assocated files to implement this -functionality. - -gr-run-waveform-binary is built by the optional standalone component -gr-run-waveform. gr-run-waveform-binary is a C binary that requires -only handful of shared libraries and a single data file. To function -it requires the main program: gr-run-waveform-binary; the GNU Radio -C++ libraries: libgnuradio-*.so; the SWIG generated wrapper libraries: -libguile-gnuradio-*.so; and one additional file: -<prefix>/share/gnuradio/gr-run-waveform/filesystem.dat. - -The two programs run waveform files identically. They differ only in -the details of how they are implemented. - - -References ----------- - -[1] http://www.schemers.org/Documents/Standards/R5RS/r5rs.pdf -[2] http://www.gnu.org/software/guile/guile.html -[3] html: http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html - pdf: http://download.plt-scheme.org/doc/205/pdf/t-y-scheme.pdf -[4] http://www.htdp.org/2003-09-26 -[5] http://www.gnu.org/software/guile/docs/goops/index.html diff --git a/gnuradio-examples/waveforms/dial-tone.wfd b/gnuradio-examples/waveforms/dial-tone.wfd deleted file mode 100644 index 5ab60075a..000000000 --- a/gnuradio-examples/waveforms/dial-tone.wfd +++ /dev/null @@ -1,40 +0,0 @@ -;;; Emacs, format this using -*-scheme-*- mode. -;;; -;;; Copyright 2010 Free Software Foundation, Inc. -;;; -;;; This file is part of GNU Radio -;;; -;;; GNU Radio is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 3, or (at your option) -;;; any later version. -;;; -;;; GNU Radio is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; This example waveform outputs a signal to an audio_alsa_sink -;;; that sounds like North American dial tone. - -(use-modules (gnuradio audio_alsa)) - - -(define-waveform (dial-tone cmd-line-args) - (vars - (sample-rate 48000) - (ampl 0.1)) - - (blocks - (src0 (gr:sig-source-f sample-rate gr:GR-SIN-WAVE 350 ampl)) - (src1 (gr:sig-source-f sample-rate gr:GR-SIN-WAVE 440 ampl)) - (sink (gr:audio-alsa-sink sample-rate "plughw:0,0")) - ) - - (connections - (src0 (list sink 0)) ; src0 to left input - (src1 (list sink 1)))) ; src1 to right input |