diff options
author | Tom Rondeau | 2010-11-16 07:56:14 -0800 |
---|---|---|
committer | Tom Rondeau | 2010-11-16 07:56:14 -0800 |
commit | 559d397de9ba937f470d27a7ad8b8d15f8f2f90f (patch) | |
tree | 221f32c0c10e55f9072fb22623e01fcd1dd63353 /gnuradio-examples | |
parent | a6b5781e36ff75adb1e4d39d755d4ab8f5efd9dd (diff) | |
parent | 53eee1c624794056fcba50a5eb50b864cbf159dd (diff) | |
download | gnuradio-559d397de9ba937f470d27a7ad8b8d15f8f2f90f.tar.gz gnuradio-559d397de9ba937f470d27a7ad8b8d15f8f2f90f.tar.bz2 gnuradio-559d397de9ba937f470d27a7ad8b8d15f8f2f90f.zip |
Merge branch 'next' into tagging
Diffstat (limited to 'gnuradio-examples')
-rw-r--r-- | gnuradio-examples/c++/dial_tone/Makefile.am | 9 | ||||
-rwxr-xr-x | gnuradio-examples/python/pfb/synth_filter.py | 71 | ||||
-rwxr-xr-x | gnuradio-examples/python/pfb/synth_to_chan.py | 105 |
3 files changed, 181 insertions, 4 deletions
diff --git a/gnuradio-examples/c++/dial_tone/Makefile.am b/gnuradio-examples/c++/dial_tone/Makefile.am index ea34beee8..188275fca 100644 --- a/gnuradio-examples/c++/dial_tone/Makefile.am +++ b/gnuradio-examples/c++/dial_tone/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,9 +22,10 @@ include $(top_srcdir)/Makefile.common # For compiling within the GNU Radio build tree -AM_CPPFLAGS=$(STD_DEFINES_AND_INCLUDES) \ - -I$(top_srcdir)/gr-audio-alsa/src \ - $(WITH_INCLUDES) +AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-audio-alsa/src \ + $(STD_DEFINES_AND_INCLUDES) \ + $(WITH_INCLUDES) GR_AUDIO_ALSA_LA=$(top_builddir)/gr-audio-alsa/src/libgnuradio-audio-alsa.la diff --git a/gnuradio-examples/python/pfb/synth_filter.py b/gnuradio-examples/python/pfb/synth_filter.py new file mode 100755 index 000000000..a1562f9ea --- /dev/null +++ b/gnuradio-examples/python/pfb/synth_filter.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, blks2 +import scipy, pylab + +def main(): + N = 1000000 + fs = 8000 + + freqs = [100, 200, 300, 400, 500] + nchans = 7 + + sigs = list() + for fi in freqs: + s = gr.sig_source_c(fs, gr.GR_SIN_WAVE, fi, 1) + sigs.append(s) + + taps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Num. Taps = %d (taps per filter = %d)" % (len(taps), + len(taps)/nchans) + filtbank = gr.pfb_synthesis_filterbank_ccf(nchans, taps) + + head = gr.head(gr.sizeof_gr_complex, N) + snk = gr.vector_sink_c() + + tb = gr.top_block() + tb.connect(filtbank, head, snk) + + for i,si in enumerate(sigs): + tb.connect(si, (filtbank, i)) + + tb.run() + + if 1: + f1 = pylab.figure(1) + s1 = f1.add_subplot(1,1,1) + s1.plot(snk.data()[1000:]) + + fftlen = 2048 + f2 = pylab.figure(2) + s2 = f2.add_subplot(1,1,1) + winfunc = scipy.blackman + s2.psd(snk.data()[10000:], NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + + pylab.show() + +if __name__ == "__main__": + main() diff --git a/gnuradio-examples/python/pfb/synth_to_chan.py b/gnuradio-examples/python/pfb/synth_to_chan.py new file mode 100755 index 000000000..1beda1a54 --- /dev/null +++ b/gnuradio-examples/python/pfb/synth_to_chan.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# +# 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, blks2 +import scipy, pylab + +def main(): + N = 1000000 + fs = 8000 + + freqs = [100, 200, 300, 400, 500] + nchans = 7 + + sigs = list() + fmtx = list() + for fi in freqs: + s = gr.sig_source_f(fs, gr.GR_SIN_WAVE, fi, 1) + fm = blks2.nbfm_tx (fs, 4*fs, max_dev=10000, tau=75e-6) + sigs.append(s) + fmtx.append(fm) + + syntaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps), + len(syntaps)/nchans) + chtaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps), + len(chtaps)/nchans) + filtbank = gr.pfb_synthesis_filterbank_ccf(nchans, syntaps) + channelizer = blks2.pfb_channelizer_ccf(nchans, chtaps) + + noise_level = 0.01 + head = gr.head(gr.sizeof_gr_complex, N) + noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level) + addnoise = gr.add_cc() + snk_synth = gr.vector_sink_c() + + tb = gr.top_block() + + tb.connect(noise, (addnoise,0)) + tb.connect(filtbank, head, (addnoise, 1)) + tb.connect(addnoise, channelizer) + tb.connect(addnoise, snk_synth) + + snk = list() + for i,si in enumerate(sigs): + tb.connect(si, fmtx[i], (filtbank, i)) + + for i in xrange(nchans): + snk.append(gr.vector_sink_c()) + tb.connect((channelizer, i), snk[i]) + + tb.run() + + if 1: + channel = 1 + data = snk[channel].data()[1000:] + + f1 = pylab.figure(1) + s1 = f1.add_subplot(1,1,1) + s1.plot(data[10000:10200] ) + s1.set_title(("Output Signal from Channel %d" % channel)) + + fftlen = 2048 + winfunc = scipy.blackman + #winfunc = scipy.hamming + + f2 = pylab.figure(2) + s2 = f2.add_subplot(1,1,1) + s2.psd(data, NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + s2.set_title(("Output PSD from Channel %d" % channel)) + + f3 = pylab.figure(3) + s3 = f3.add_subplot(1,1,1) + s3.psd(snk_synth.data()[1000:], NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + s3.set_title("Output of Synthesis Filter") + + pylab.show() + +if __name__ == "__main__": + main() |