diff options
author | jcorgan | 2007-04-28 02:20:28 +0000 |
---|---|---|
committer | jcorgan | 2007-04-28 02:20:28 +0000 |
commit | b26ea69676c09f5366a9e2f33b11ae5a7521ffe5 (patch) | |
tree | 0641c1c25d6e827f70941e07f4611d0a2b6b83cd /gnuradio-examples/python/hier/audio/dial_tone2.py | |
parent | 00696b9f754338de9362932c1ecfb1e144a38786 (diff) | |
download | gnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.tar.gz gnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.tar.bz2 gnuradio-b26ea69676c09f5366a9e2f33b11ae5a7521ffe5.zip |
Merged -r 5137:5174 from developer branch jcorgan/hb. Trunk passes distcheck. Converts gr.hier_block2 API to not use 'define_component' methodology anymore.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5177 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples/python/hier/audio/dial_tone2.py')
-rwxr-xr-x | gnuradio-examples/python/hier/audio/dial_tone2.py | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/gnuradio-examples/python/hier/audio/dial_tone2.py b/gnuradio-examples/python/hier/audio/dial_tone2.py index cbb187a36..3511fdba7 100755 --- a/gnuradio-examples/python/hier/audio/dial_tone2.py +++ b/gnuradio-examples/python/hier/audio/dial_tone2.py @@ -27,32 +27,20 @@ from optparse import OptionParser # Top-level block creating a dial tone # Derives from new class gr.hier_block2 -class dial_tone(gr.hier_block2): +class dial_tone(gr.top_block): def __init__(self, sample_rate, # Audio output sample rate (int) audio_output, # Audio output device amplitude): # Output volume (0.0-1.0) - # Call hierarchical block constructor - # Top-level blocks have no inputs or outputs - gr.hier_block2.__init__(self, - "dial_tone", # Block type - gr.io_signature(0,0,0), # Input signature - gr.io_signature(0,0,0)) # Output signature + gr.top_block.__init__(self, "dial_tone") - # Hierarchical blocks have a set of 'components' (which may - # be themselves hierarchical blocks), mapped to names. - # 'define_component' takes a string and either a hierarchical - # block or an instance of a 'leaf node' (gr_block) block + src0 = gr.sig_source_f(sample_rate, gr.GR_SIN_WAVE, 350, amplitude) + src1 = gr.sig_source_f(sample_rate, gr.GR_SIN_WAVE, 440, amplitude) + dst = audio.sink(sample_rate, audio_output) - # Give names to two sine wave sources and an audio sink - self.define_component("src0", gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, amplitude)) - self.define_component("src1", gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, amplitude)) - self.define_component("dst", audio.sink(sample_rate, audio_output)) - - # Wire up outputs to inputs. (TODO: convenience functions) - self.connect("src0", 0, "dst", 0) - self.connect("src1", 0, "dst", 1) + self.connect(src0, (dst, 0)) + self.connect(src1, (dst, 1)) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) @@ -68,13 +56,13 @@ if __name__ == '__main__': raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = dial_tone(int(options.sample_rate), - options.audio_output, - options.amplitude) + top = dial_tone(int(options.sample_rate), + options.audio_output, + options.amplitude) # Create an instance of a runtime, passing it the top block # to process - runtime = gr.runtime(top_block) + runtime = gr.runtime(top) try: # Run forever |