3 # Copyright 2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
24 Digital voice Tx and Rx using GSM 13kbit vocoder and GMSK.
26 Runs channel at 32kbit/sec. Currently uses fake channel coding,
27 but there's room for a rate 1/2 coder.
30 from gnuradio import gr, gru
31 from gnuradio.blksimpl.gmsk import gmsk_mod, gmsk_demod
33 from gnuradio.vocoder import gsm_full_rate
35 # Size of gsm full rate speech encoder output packet in bytes
39 # Size of packet in bytes that we send to GMSK modulator:
41 # Target: 256kS/sec air rate.
43 # 256kS 1 sym 1 bit 1 byte 0.020 sec 80 bytes
44 # ---- * ----- * ----- * ------ * --------- = --------
45 # sec 8 S 1 sym 8 bits frame frame
47 # gr_simple_framer add 10 bytes of overhead.
52 class digital_voice_tx(gr.hier_block):
54 Hierarchical block for digital voice tranmission.
56 The input is 8kS/sec floating point audio in the range [-1,+1]
57 The output is 256kS/sec GMSK modulated complex baseband signal in the range [-1,+1].
59 def __init__(self, fg):
60 samples_per_symbol = 8
62 bt = 0.3 # Gaussian filter bandwidth * symbol time
64 src_scale = gr.multiply_const_ff(32767)
65 f2s = gr.float_to_short()
66 voice_coder = gsm_full_rate.encode_sp()
68 channel_coder = gr.fake_channel_encoder_pp(GSM_FRAME_SIZE, AIR_FRAME_SIZE)
69 p2s = gr.parallel_to_serial(gr.sizeof_char, AIR_FRAME_SIZE)
71 mod = gmsk_mod(fg, sps=samples_per_symbol,
72 symbol_rate=symbol_rate, bt=bt,
73 p_size=AIR_FRAME_SIZE)
75 fg.connect(src_scale, f2s, voice_coder, channel_coder, p2s, mod)
76 gr.hier_block.__init__(self, fg, src_scale, mod)
79 class digital_voice_rx(gr.hier_block):
81 Hierarchical block for digital voice reception.
83 The input is 256kS/sec GMSK modulated complex baseband signal.
84 The output is 8kS/sec floating point audio in the range [-1,+1]
86 def __init__(self, fg):
87 samples_per_symbol = 8
90 demod = gmsk_demod(fg, sps=samples_per_symbol,
91 symbol_rate=symbol_rate,
92 p_size=AIR_FRAME_SIZE)
94 s2p = gr.serial_to_parallel(gr.sizeof_char, AIR_FRAME_SIZE)
95 channel_decoder = gr.fake_channel_decoder_pp(AIR_FRAME_SIZE, GSM_FRAME_SIZE)
97 voice_decoder = gsm_full_rate.decode_ps()
98 s2f = gr.short_to_float ()
99 sink_scale = gr.multiply_const_ff(1.0/32767.)
101 fg.connect(demod, s2p, channel_decoder, voice_decoder, s2f, sink_scale)
102 gr.hier_block.__init__(self, fg, demod, sink_scale)