diff options
Diffstat (limited to 'gr-audio/examples/python')
-rwxr-xr-x | gr-audio/examples/python/dial_tone.py | 16 | ||||
-rwxr-xr-x | gr-audio/examples/python/dial_tone_daemon.py | 16 | ||||
-rwxr-xr-x | gr-audio/examples/python/dial_tone_wav.py | 7 | ||||
-rwxr-xr-x | gr-audio/examples/python/mono_tone.py | 11 | ||||
-rwxr-xr-x | gr-audio/examples/python/multi_tone.py | 18 | ||||
-rwxr-xr-x | gr-audio/examples/python/test_resampler.py | 12 |
6 files changed, 41 insertions, 39 deletions
diff --git a/gr-audio/examples/python/dial_tone.py b/gr-audio/examples/python/dial_tone.py index 5661d13d48..9c8e8d460d 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 # @@ -22,6 +22,7 @@ from gnuradio import gr from gnuradio import audio +from gnuradio import analog from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -35,7 +36,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 +44,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..2d40ac9714 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 # @@ -22,6 +22,7 @@ from gnuradio import gr, gru from gnuradio import audio +from gnuradio import analog from gnuradio.eng_option import eng_option from optparse import OptionParser import os @@ -36,7 +37,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 +45,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..e044a83f14 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 # @@ -23,6 +23,7 @@ # GNU Radio example program to record a dial tone to a WAV file from gnuradio import gr +from gnuradio import analog from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -45,8 +46,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..376ed4fee6 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 # @@ -21,6 +21,7 @@ # from gnuradio import gr +from gnuradio import analog from gnuradio import audio from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -50,11 +51,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..d311247520 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 # @@ -43,7 +43,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 +69,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..9775754e39 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 # @@ -22,6 +22,7 @@ from gnuradio import gr, gru, blks2 from gnuradio import audio +from gnuradio import analog from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -38,7 +39,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 +54,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: |