summaryrefslogtreecommitdiff
path: root/gr-audio/examples/python
diff options
context:
space:
mode:
Diffstat (limited to 'gr-audio/examples/python')
-rwxr-xr-xgr-audio/examples/python/dial_tone.py21
-rwxr-xr-xgr-audio/examples/python/dial_tone_daemon.py21
-rwxr-xr-xgr-audio/examples/python/dial_tone_wav.py12
-rwxr-xr-xgr-audio/examples/python/mono_tone.py16
-rwxr-xr-xgr-audio/examples/python/multi_tone.py24
-rwxr-xr-xgr-audio/examples/python/test_resampler.py16
6 files changed, 71 insertions, 39 deletions
diff --git a/gr-audio/examples/python/dial_tone.py b/gr-audio/examples/python/dial_tone.py
index 5661d13d48..c55d0d38dd 100755
--- a/gr-audio/examples/python/dial_tone.py
+++ b/gr-audio/examples/python/dial_tone.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,12 @@ from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
+
class my_top_block(gr.top_block):
def __init__(self):
@@ -35,7 +41,7 @@ class my_top_block(gr.top_block):
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 ()
+ (options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
raise SystemExit, 1
@@ -43,12 +49,11 @@ class my_top_block(gr.top_block):
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))
-
+ src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
+ src1 = analog.sig_source_f(sample_rate, analog.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:
diff --git a/gr-audio/examples/python/dial_tone_daemon.py b/gr-audio/examples/python/dial_tone_daemon.py
index b25baebee2..e4dbd95321 100755
--- a/gr-audio/examples/python/dial_tone_daemon.py
+++ b/gr-audio/examples/python/dial_tone_daemon.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007,2008 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007,2008,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -26,6 +26,12 @@ from gnuradio.eng_option import eng_option
from optparse import OptionParser
import os
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
+
class my_top_block(gr.top_block):
def __init__(self):
@@ -36,7 +42,7 @@ class my_top_block(gr.top_block):
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 ()
+ (options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
raise SystemExit, 1
@@ -44,12 +50,11 @@ class my_top_block(gr.top_block):
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))
-
+ src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
+ src1 = analog.sig_source_f(sample_rate, analog.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__':
pid = gru.daemonize()
diff --git a/gr-audio/examples/python/dial_tone_wav.py b/gr-audio/examples/python/dial_tone_wav.py
index c06af55b70..4d8d6b4019 100755
--- a/gr-audio/examples/python/dial_tone_wav.py
+++ b/gr-audio/examples/python/dial_tone_wav.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007,2008 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007,2008,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -26,6 +26,12 @@ from gnuradio import gr
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
+
class my_top_block(gr.top_block):
def __init__(self):
@@ -45,8 +51,8 @@ class my_top_block(gr.top_block):
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)
+ src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
+ src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl)
head0 = gr.head(gr.sizeof_float, int(options.samples))
head1 = gr.head(gr.sizeof_float, int(options.samples))
dst = gr.wavfile_sink(args[0], 2, int(options.sample_rate), 16)
diff --git a/gr-audio/examples/python/mono_tone.py b/gr-audio/examples/python/mono_tone.py
index bce486e4ab..ad73d62327 100755
--- a/gr-audio/examples/python/mono_tone.py
+++ b/gr-audio/examples/python/mono_tone.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,12 @@ from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
+
#import os
#print os.getpid()
#raw_input('Attach gdb and press Enter: ')
@@ -50,11 +56,11 @@ class my_top_block(gr.top_block):
sample_rate = int(options.sample_rate)
ampl = 0.1
- src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 650, ampl)
+ src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 650, ampl)
- dst = audio.sink (sample_rate,
- options.audio_output,
- options.ok_to_block)
+ dst = audio.sink(sample_rate,
+ options.audio_output,
+ options.ok_to_block)
self.connect (src0, (dst, 0))
diff --git a/gr-audio/examples/python/multi_tone.py b/gr-audio/examples/python/multi_tone.py
index 00c213b634..6232cbef52 100755
--- a/gr-audio/examples/python/multi_tone.py
+++ b/gr-audio/examples/python/multi_tone.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2006,2007 Free Software Foundation, Inc.
+# Copyright 2004,2006,2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,12 @@ from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
+
#import os
#print os.getpid()
#raw_input('Attach gdb and press Enter: ')
@@ -43,7 +49,7 @@ class my_top_block(gr.top_block):
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 ()
+ (options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
raise SystemExit, 1
@@ -69,19 +75,19 @@ class my_top_block(gr.top_block):
# progression = (7, 11, 1, 5)
progression = (7, 11, 1, 5, 9)
- dst = audio.sink (sample_rate,
- options.audio_output,
- options.ok_to_block)
+ 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))
+ 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))
+ src = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, freq, ampl)
+ self.connect(src, (dst, i))
if __name__ == '__main__':
try:
diff --git a/gr-audio/examples/python/test_resampler.py b/gr-audio/examples/python/test_resampler.py
index db7f79fba0..93be86086b 100755
--- a/gr-audio/examples/python/test_resampler.py
+++ b/gr-audio/examples/python/test_resampler.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2005,2007 Free Software Foundation, Inc.
+# Copyright 2004,2005,2007,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -25,6 +25,11 @@ from gnuradio import audio
from gnuradio.eng_option import eng_option
from optparse import OptionParser
+try:
+ from gnuradio import analog
+except ImportError:
+ sys.stderr.write("Error: Program requires gr-analog.\n")
+ sys.exit(1)
class my_top_block(gr.top_block):
@@ -38,7 +43,7 @@ class my_top_block(gr.top_block):
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 ()
+ (options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
raise SystemExit, 1
@@ -53,11 +58,10 @@ class my_top_block(gr.top_block):
print "decim =", decim
ampl = 0.1
- src0 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 650, ampl)
+ src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl)
rr = blks2.rational_resampler_fff(interp, decim)
- dst = audio.sink (output_rate, options.audio_output)
- self.connect (src0, rr, (dst, 0))
-
+ dst = audio.sink(output_rate, options.audio_output)
+ self.connect(src0, rr, (dst, 0))
if __name__ == '__main__':
try: