diff options
author | Tom Rondeau | 2011-10-07 10:39:43 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-07 10:39:43 -0400 |
commit | fcc3780747a4ab650a676b6908d602db7a9f9cb0 (patch) | |
tree | 19d8fee5ef266bc96424159fd976a46c1e5b6c75 /gr-digital/examples | |
parent | e1180546037845728fa0aed892ab751f6924f361 (diff) | |
download | gnuradio-fcc3780747a4ab650a676b6908d602db7a9f9cb0.tar.gz gnuradio-fcc3780747a4ab650a676b6908d602db7a9f9cb0.tar.bz2 gnuradio-fcc3780747a4ab650a676b6908d602db7a9f9cb0.zip |
digital: updated rx and tx voice examples to work over the air with UHD.
Diffstat (limited to 'gr-digital/examples')
-rwxr-xr-x | gr-digital/examples/rx_voice.py | 31 | ||||
-rwxr-xr-x | gr-digital/examples/tx_voice.py | 33 | ||||
-rw-r--r-- | gr-digital/examples/uhd_interface.py | 3 |
3 files changed, 48 insertions, 19 deletions
diff --git a/gr-digital/examples/rx_voice.py b/gr-digital/examples/rx_voice.py index d29d64ed6..72227eeaf 100755 --- a/gr-digital/examples/rx_voice.py +++ b/gr-digital/examples/rx_voice.py @@ -20,17 +20,13 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr -from gnuradio import uhd -from gnuradio import audio +from gnuradio import gr, blks2, audio, uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser -from gnuradio.vocoder import gsm_full_rate - -# From gr-digital from gnuradio import digital +from gnuradio import vocoder import random import struct @@ -38,6 +34,7 @@ import sys # from current dir from receive_path import receive_path +from uhd_interface import uhd_receiver #import os #print os.getpid() @@ -50,9 +47,9 @@ class audio_tx(gr.hier_block2): gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature - sample_rate = 8000 + self.sample_rate = sample_rate = 8000 self.packet_src = gr.message_source(33) - voice_decoder = gsm_full_rate.decode_ps() + voice_decoder = vocoder.gsm_fr_decode_ps() s2f = gr.short_to_float () sink_scale = gr.multiply_const_ff(1.0/32767.) audio_sink = audio.sink(sample_rate, audio_output_dev) @@ -68,10 +65,25 @@ class my_top_block(gr.top_block): self.rxpath = receive_path(demod_class, rx_callback, options) self.audio_tx = audio_tx(options.audio_output) - if(options.from_file is not None): + if(options.rx_freq is not None): + self.source = uhd_receiver(options.address, options.bitrate, + options.samples_per_symbol, + options.rx_freq, options.rx_gain, + options.antenna, options.verbose) + options.samples_per_symbol = self.source._sps + + audio_rate = self.audio_tx.sample_rate + usrp_rate = self.source.get_sample_rate() + rrate = usrp_rate / audio_rate + self.resampler = blks2.pfb_arb_resampler_ccf(rrate) + + self.connect(self.source, self.resampler, self.rxpath) + + elif(options.from_file is not None): self.thr = gr.throttle(gr.sizeof_gr_complex, options.bitrate) self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file) self.connect(self.source, self.thr, self.rxpath) + else: self.thr = gr.throttle(gr.sizeof_gr_complex, 1e6) self.source = gr.null_source(gr.sizeof_gr_complex) @@ -117,6 +129,7 @@ def main(): parser.add_option("","--from-file", default=None, help="input file of samples to demod") receive_path.add_options(parser, expert_grp) + uhd_receiver.add_options(parser) for mod in demods.values(): mod.add_options(expert_grp) diff --git a/gr-digital/examples/tx_voice.py b/gr-digital/examples/tx_voice.py index f4f2c3a86..eabb5e3c3 100755 --- a/gr-digital/examples/tx_voice.py +++ b/gr-digital/examples/tx_voice.py @@ -20,17 +20,13 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr -from gnuradio import uhd -from gnuradio import audio +from gnuradio import gr, blks2, audio, uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser -from gnuradio.vocoder import gsm_full_rate - -# From gr-digital from gnuradio import digital +from gnuradio import vocoder import random import time @@ -39,6 +35,7 @@ import sys # from current dir from transmit_path import transmit_path +from uhd_interface import uhd_transmitter #import os #print os.getpid() @@ -50,11 +47,11 @@ class audio_rx(gr.hier_block2): gr.hier_block2.__init__(self, "audio_rx", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature - sample_rate = 8000 + self.sample_rate = sample_rate = 8000 src = audio.source(sample_rate, audio_input_dev) src_scale = gr.multiply_const_ff(32767) f2s = gr.float_to_short() - voice_coder = gsm_full_rate.encode_sp() + voice_coder = vocoder.gsm_fr_encode_sp() self.packets_from_encoder = gr.msg_queue() packet_sink = gr.message_sink(33, self.packets_from_encoder, False) self.connect(src, src_scale, f2s, voice_coder, packet_sink) @@ -70,13 +67,27 @@ class my_top_block(gr.top_block): self.txpath = transmit_path(modulator_class, options) self.audio_rx = audio_rx(options.audio_input) - if(options.to_file is not None): + if(options.tx_freq is not None): + self.sink = uhd_transmitter(options.address, options.bitrate, + options.samples_per_symbol, + options.tx_freq, options.tx_gain, + options.antenna, options.verbose) + options.samples_per_symbol = self.sink._sps + audio_rate = self.audio_rx.sample_rate + usrp_rate = self.sink.get_sample_rate() + rrate = usrp_rate / audio_rate + + elif(options.to_file is not None): self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) + rrate = 1 else: self.sink = gr.null_sink(gr.sizeof_gr_complex) + rrate = 1 + self.resampler = blks2.pfb_arb_resampler_ccf(rrate) + self.connect(self.audio_rx) - self.connect(self.txpath, self.sink) + self.connect(self.txpath, self.resampler, self.sink) # ///////////////////////////////////////////////////////////////////////////// @@ -106,7 +117,9 @@ def main(): help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("","--to-file", default=None, help="Output file for modulated samples") + transmit_path.add_options(parser, expert_grp) + uhd_transmitter.add_options(parser) for mod in mods.values(): mod.add_options(expert_grp) diff --git a/gr-digital/examples/uhd_interface.py b/gr-digital/examples/uhd_interface.py index a01648715..8420f3eec 100644 --- a/gr-digital/examples/uhd_interface.py +++ b/gr-digital/examples/uhd_interface.py @@ -90,6 +90,9 @@ class uhd_interface: return (actual_samp_rate, actual_sps) + def get_sample_rate(self): + return self.u.get_samp_rate() + def set_gain(self, gain=None): if gain is None: # if no gain was specified, use the mid-point in dB |