From 5d69a524f81f234b3fbc41d49ba18d6f6886baba Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Thu, 3 Aug 2006 04:51:51 +0000
Subject: Houston, we have a trunk.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3122 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gnuradio-examples/python/audio/Makefile.am         | 32 ++++++++
 gnuradio-examples/python/audio/audio_copy.py       | 64 +++++++++++++++
 gnuradio-examples/python/audio/audio_play.py       | 57 ++++++++++++++
 gnuradio-examples/python/audio/audio_to_file.py    | 63 +++++++++++++++
 gnuradio-examples/python/audio/dial_squelch.py     | 89 +++++++++++++++++++++
 gnuradio-examples/python/audio/dial_tone.py        | 57 ++++++++++++++
 gnuradio-examples/python/audio/dialtone_v.py       | 71 +++++++++++++++++
 gnuradio-examples/python/audio/mono_tone.py        | 66 ++++++++++++++++
 gnuradio-examples/python/audio/multi_tone.py       | 90 ++++++++++++++++++++++
 .../python/audio/spectrum_inversion.py             | 48 ++++++++++++
 gnuradio-examples/python/audio/test_resampler.py   | 66 ++++++++++++++++
 11 files changed, 703 insertions(+)
 create mode 100644 gnuradio-examples/python/audio/Makefile.am
 create mode 100755 gnuradio-examples/python/audio/audio_copy.py
 create mode 100755 gnuradio-examples/python/audio/audio_play.py
 create mode 100755 gnuradio-examples/python/audio/audio_to_file.py
 create mode 100755 gnuradio-examples/python/audio/dial_squelch.py
 create mode 100755 gnuradio-examples/python/audio/dial_tone.py
 create mode 100755 gnuradio-examples/python/audio/dialtone_v.py
 create mode 100755 gnuradio-examples/python/audio/mono_tone.py
 create mode 100755 gnuradio-examples/python/audio/multi_tone.py
 create mode 100755 gnuradio-examples/python/audio/spectrum_inversion.py
 create mode 100755 gnuradio-examples/python/audio/test_resampler.py

(limited to 'gnuradio-examples/python/audio')

diff --git a/gnuradio-examples/python/audio/Makefile.am b/gnuradio-examples/python/audio/Makefile.am
new file mode 100644
index 0000000000..27cea62a31
--- /dev/null
+++ b/gnuradio-examples/python/audio/Makefile.am
@@ -0,0 +1,32 @@
+#
+# Copyright 2004 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+EXTRA_DIST = 			\
+	audio_copy.py		\
+	audio_play.py		\
+	audio_to_file.py	\
+	dial_tone.py		\
+	mono_tone.py		\
+	multi_tone.py		\
+	spectrum_inversion.py	\
+	test_resampler.py	
+
+
diff --git a/gnuradio-examples/python/audio/audio_copy.py b/gnuradio-examples/python/audio/audio_copy.py
new file mode 100755
index 0000000000..56fa836d29
--- /dev/null
+++ b/gnuradio-examples/python/audio/audio_copy.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-I", "--audio-input", type="string", default="",
+                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        src = audio.source (sample_rate, options.audio_input)
+        dst = audio.sink (sample_rate, options.audio_output)
+
+        # Determine the maximum number of outputs on the source and
+        # maximum number of inputs on the sink, then connect together
+        # the most channels we can without overlap
+        nchan = min (src.output_signature().max_streams(),
+                     dst.input_signature().max_streams())
+
+        for i in range (nchan):
+            self.connect ((src, i), (dst, i))
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
+    
diff --git a/gnuradio-examples/python/audio/audio_play.py b/gnuradio-examples/python/audio/audio_play.py
new file mode 100755
index 0000000000..e70b0f942d
--- /dev/null
+++ b/gnuradio-examples/python/audio/audio_play.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-F", "--filename", type="string", default="audio.dat",
+                          help="read input from FILE")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        parser.add_option("-R", "--repeat", action="store_true", default=False)
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        (options, args) = parser.parse_args()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        src = gr.file_source (gr.sizeof_float, options.filename, options.repeat)
+        dst = audio.sink (sample_rate, options.audio_output)
+        self.connect(src, dst)
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/audio_to_file.py b/gnuradio-examples/python/audio/audio_to_file.py
new file mode 100755
index 0000000000..74e1ea7ac3
--- /dev/null
+++ b/gnuradio-examples/python/audio/audio_to_file.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# Copyright 2004 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        usage="%prog: [options] output_filename"
+        parser = OptionParser(option_class=eng_option, usage=usage)
+        parser.add_option("-I", "--audio-input", type="string", default="",
+                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        parser.add_option("-N", "--nsamples", type="eng_float", default=None,
+                          help="number of samples to collect [default=+inf]")
+     
+        (options, args) = parser.parse_args ()
+        if len(args) != 1:
+            parser.print_help()
+            raise SystemExit, 1
+        filename = args[0]
+
+        sample_rate = int(options.sample_rate)
+        src = audio.source (sample_rate, options.audio_input)
+        dst = gr.file_sink (gr.sizeof_float, filename)
+
+        if options.nsamples is None:
+            self.connect((src, 0), dst)
+        else:
+            head = gr.head(gr.sizeof_float, int(options.nsamples))
+            self.connect((src, 0), head, dst)
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/dial_squelch.py b/gnuradio-examples/python/audio/dial_squelch.py
new file mode 100755
index 0000000000..d947e58604
--- /dev/null
+++ b/gnuradio-examples/python/audio/dial_squelch.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# Copyright 2006 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr, audio, eng_option
+from gnuradio.eng_option import eng_option
+from math import pi, cos
+from optparse import OptionParser
+
+"""
+This script generates a standard dial tone and then applies a sinusoidal
+envelope to vary it's loudness.  The audio is then passed through the
+power squelch block before it gets sent to the sound card. By varying
+the command line parameters, one can see the effect of differing
+amounts of power averaging, threshold, and attack/decay ramping.
+"""
+
+class app_flow_graph(gr.flow_graph):
+    def __init__(self, options, args):
+        gr.flow_graph.__init__(self)
+	
+	# Create dial tone by adding two sine waves
+	SRC1 = gr.sig_source_f(options.rate, gr.GR_SIN_WAVE, 350, 0.5, 0.0)
+	SRC2 = gr.sig_source_f(options.rate, gr.GR_SIN_WAVE, 440, 0.5, 0.0)
+	ADD = gr.add_ff()
+
+	# Convert to vector stream (and back) to apply raised cosine envelope
+	# You could also do this with a vector_source_f block that repeats.
+	S2V = gr.stream_to_vector(gr.sizeof_float, options.rate)
+	ENV = [0.5-cos(2*pi*x/options.rate)/2 for x in range(options.rate)]
+	MLT = gr.multiply_const_vff(ENV)
+	V2S = gr.vector_to_stream(gr.sizeof_float, options.rate)
+
+	# Run through power squelch with user supplied or default options
+	# Zero output when squelch is invoked
+	SQL = gr.pwr_squelch_ff(options.threshold, options.alpha, options.ramp, False)
+	DST = audio.sink(options.rate)
+
+	# Solder it all together
+	self.connect(SRC1, (ADD, 0))
+	self.connect(SRC2, (ADD, 1))
+	self.connect(ADD, S2V, MLT, V2S, SQL, DST)
+	
+def main():
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("-r", "--rate", type="int", default=8000, help="set audio output sample rate to RATE", metavar="RATE")
+    parser.add_option("-t", "--threshold", type="eng_float", default=-10.0, help="set power squelch to DB", metavar="DB")
+    parser.add_option("-a", "--alpha", type="eng_float", default=None, help="set alpha to ALPHA", metavar="ALPHA")
+    parser.add_option("-m", "--ramp", type="int", default=None, help="set attack/decay ramp to SAMPLES", metavar="SAMPLES")
+    (options, args) = parser.parse_args()
+
+    if options.alpha == None:
+	options.alpha = 50.0/options.rate
+	
+    if options.ramp == None:
+	options.ramp = options.rate/50	# ~ 20 ms
+
+    print "Using audio rate of", options.rate
+    print "Using threshold of", options.threshold, "db"
+    print "Using alpha of", options.alpha
+    print "Using ramp of", options.ramp, "samples"
+
+    fg = app_flow_graph(options, args)
+
+    try:
+      fg.run()
+    except KeyboardInterrupt:
+      pass
+
+if __name__ == "__main__":
+    main()
diff --git a/gnuradio-examples/python/audio/dial_tone.py b/gnuradio-examples/python/audio/dial_tone.py
new file mode 100755
index 0000000000..3ce84eb596
--- /dev/null
+++ b/gnuradio-examples/python/audio/dial_tone.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        ampl = 0.1
+
+        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)
+        dst = audio.sink (sample_rate, options.audio_output)
+        self.connect (src0, (dst, 0))
+        self.connect (src1, (dst, 1))
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/dialtone_v.py b/gnuradio-examples/python/audio/dialtone_v.py
new file mode 100755
index 0000000000..e704414a9e
--- /dev/null
+++ b/gnuradio-examples/python/audio/dialtone_v.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+# Copyright 2006 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr, audio
+from math import pi, sin
+
+"""
+This test script demonstrates the use of element-wise vector processing
+vs. stream processing.  The example is artificial in that the stream
+version in dial_tone.py is the normal way to do it; in addition, the
+envelope processing here is just for demo purposes and isn't needed.
+"""
+
+# For testing different buffer sizes
+rate = 48000
+
+fg = gr.flow_graph()
+
+# Two streams of floats
+a = gr.sig_source_f(rate, gr.GR_SIN_WAVE, 350, 0.5, 0.0);
+b = gr.sig_source_f(rate, gr.GR_SIN_WAVE, 440, 0.5, 0.0);
+
+# Turn them into vectors of length 'size'
+av = gr.stream_to_vector(gr.sizeof_float, rate)
+bv = gr.stream_to_vector(gr.sizeof_float, rate)
+
+# Make a vector adder for float vectors
+adder = gr.add_vff(rate)
+
+# Make a 1 Hz sine envelope
+envelope = [sin(2*pi*x/rate)*0.5 for x in range(rate)]
+multiplier = gr.multiply_const_vff(envelope)
+
+# Make an offset adder
+offset = gr.add_const_vff((0.5,)*rate)
+
+# Turn the vector back into a stream of floats
+result = gr.vector_to_stream(gr.sizeof_float, rate)
+
+# Play it
+sink = audio.sink(rate)
+
+fg.connect(a, av)
+fg.connect(b, bv)
+fg.connect(av, (adder, 0))
+fg.connect(bv, (adder, 1))
+fg.connect(adder, multiplier, offset, result, sink)
+
+try:
+    fg.run()
+except KeyboardInterrupt:
+    pass
diff --git a/gnuradio-examples/python/audio/mono_tone.py b/gnuradio-examples/python/audio/mono_tone.py
new file mode 100755
index 0000000000..84c3b542ee
--- /dev/null
+++ b/gnuradio-examples/python/audio/mono_tone.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+#import os
+#print os.getpid()
+#raw_input('Attach gdb and press Enter: ')
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        parser.add_option("-D", "--dont-block", action="store_false", default=True,
+                          dest="ok_to_block")
+
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        ampl = 0.1
+
+        src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 650, ampl)
+
+        dst = audio.sink (sample_rate,
+                          options.audio_output,
+                          options.ok_to_block)
+            
+        self.connect (src0, (dst, 0))
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/multi_tone.py b/gnuradio-examples/python/audio/multi_tone.py
new file mode 100755
index 0000000000..c6f83050e2
--- /dev/null
+++ b/gnuradio-examples/python/audio/multi_tone.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+#import os
+#print os.getpid()
+#raw_input('Attach gdb and press Enter: ')
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
+                          help="set sample rate to RATE (48000)")
+        parser.add_option ("-m", "--max-channels", type="int", default="16",
+                           help="set maximum channels to use")
+        parser.add_option("-D", "--dont-block", action="store_false", default=True,
+                          dest="ok_to_block")
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        limit_channels = options.max_channels
+
+        ampl = 0.1
+
+        # With a tip of the hat to Harry Partch, may he R.I.P.
+        # See "Genesis of a Music".  He was into some very wild tunings...
+        base = 392
+        ratios = { 1 : 1.0,
+                   3 : 3.0/2,
+                   5 : 5.0/4,
+                   7 : 7.0/4,
+                   9 : 9.0/8,
+                   11 : 11.0/8 }
+
+        # progression = (1, 5, 3, 7)
+        # progression = (1, 9, 3, 7)
+        # progression = (3, 7, 9, 11)
+        # progression = (7, 11, 1, 5)
+        progression = (7, 11, 1, 5, 9)
+
+        dst = audio.sink (sample_rate,
+                          options.audio_output,
+                          options.ok_to_block)
+    
+        max_chan = dst.input_signature().max_streams()
+        if (max_chan == -1) or (max_chan > limit_channels):
+            max_chan = limit_channels
+
+        for i in range (max_chan):
+            quo, rem = divmod (i, len (progression))
+            freq = base * ratios[progression[rem]] * (quo + 1)
+            src = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, freq, ampl)
+            self.connect (src, (dst, i))
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/spectrum_inversion.py b/gnuradio-examples/python/audio/spectrum_inversion.py
new file mode 100755
index 0000000000..9bb87aa4b1
--- /dev/null
+++ b/gnuradio-examples/python/audio/spectrum_inversion.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# Gang - Here's a simple script that demonstrates spectrum inversion
+# using the multiply by [1,-1] method (mixing with Nyquist frequency).
+# Requires nothing but a sound card, and sounds just like listening
+# to a SSB signal on the wrong sideband.
+#
+
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-I", "--audio-input", type="string", default="",
+                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", default=8000,
+                          help="set sample rate to RATE (8000)")
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        sample_rate = int(options.sample_rate)
+        src = audio.source (sample_rate, options.audio_input)
+        dst = audio.sink (sample_rate, options.audio_output)
+
+	vec1 = [1, -1]
+	vsource = gr.vector_source_f(vec1, True)
+	multiply = gr.multiply_ff()
+
+	self.connect(src, (multiply, 0))
+	self.connect(vsource, (multiply, 1))
+	self.connect(multiply, dst)
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
diff --git a/gnuradio-examples/python/audio/test_resampler.py b/gnuradio-examples/python/audio/test_resampler.py
new file mode 100755
index 0000000000..6c9e5a7608
--- /dev/null
+++ b/gnuradio-examples/python/audio/test_resampler.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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 2, 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., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 
+
+from gnuradio import gr, gru, blks
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+
+class my_graph(gr.flow_graph):
+
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-O", "--audio-output", type="string", default="",
+                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
+        parser.add_option("-i", "--input-rate", type="eng_float", default=8000,
+                          help="set input sample rate to RATE (%default)")
+        parser.add_option("-o", "--output-rate", type="eng_float", default=48000,
+                          help="set output sample rate to RATE (%default)")
+        (options, args) = parser.parse_args ()
+        if len(args) != 0:
+            parser.print_help()
+            raise SystemExit, 1
+
+        input_rate = int(options.input_rate)
+        output_rate = int(options.output_rate)
+
+        interp = gru.lcm(input_rate, output_rate) / input_rate
+        decim = gru.lcm(input_rate, output_rate) / output_rate
+
+        print "interp =", interp
+        print "decim  =", decim
+
+        ampl = 0.1
+        src0 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 650, ampl)
+        rr = blks.rational_resampler_fff(self, interp, decim)
+        dst = audio.sink (output_rate, options.audio_output)
+        self.connect (src0, rr, (dst, 0))
+
+
+if __name__ == '__main__':
+    try:
+        my_graph().run()
+    except KeyboardInterrupt:
+        pass
-- 
cgit v1.2.3