From 0e2859ee71060e316a33f72ff7f2f6f1b2317ca5 Mon Sep 17 00:00:00 2001
From: Ben Reynwar <ben@reynwar.net>
Date: Fri, 8 Mar 2013 20:57:28 -0700
Subject: vocoder: Enabling uninstalled python imports.

---
 gr-vocoder/python/vocoder/CMakeLists.txt        |  56 +++++++++++
 gr-vocoder/python/vocoder/__init__.py           |  35 +++++++
 gr-vocoder/python/vocoder/cvsd.py               |  96 ++++++++++++++++++
 gr-vocoder/python/vocoder/qa_alaw_vocoder.py    |  48 +++++++++
 gr-vocoder/python/vocoder/qa_codec2_vocoder.py  |  58 +++++++++++
 gr-vocoder/python/vocoder/qa_cvsd_vocoder.py    | 127 ++++++++++++++++++++++++
 gr-vocoder/python/vocoder/qa_g721_vocoder.py    |  47 +++++++++
 gr-vocoder/python/vocoder/qa_g723_24_vocoder.py |  46 +++++++++
 gr-vocoder/python/vocoder/qa_g723_40_vocoder.py |  46 +++++++++
 gr-vocoder/python/vocoder/qa_gsm_full_rate.py   |  60 +++++++++++
 gr-vocoder/python/vocoder/qa_ulaw_vocoder.py    |  47 +++++++++
 11 files changed, 666 insertions(+)
 create mode 100644 gr-vocoder/python/vocoder/CMakeLists.txt
 create mode 100644 gr-vocoder/python/vocoder/__init__.py
 create mode 100644 gr-vocoder/python/vocoder/cvsd.py
 create mode 100755 gr-vocoder/python/vocoder/qa_alaw_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_codec2_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_cvsd_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_g721_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_g723_24_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_g723_40_vocoder.py
 create mode 100755 gr-vocoder/python/vocoder/qa_gsm_full_rate.py
 create mode 100755 gr-vocoder/python/vocoder/qa_ulaw_vocoder.py

(limited to 'gr-vocoder/python/vocoder')

diff --git a/gr-vocoder/python/vocoder/CMakeLists.txt b/gr-vocoder/python/vocoder/CMakeLists.txt
new file mode 100644
index 000000000..9fdc62528
--- /dev/null
+++ b/gr-vocoder/python/vocoder/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+# Setup python install
+########################################################################
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+    FILES
+    __init__.py
+    cvsd.py
+    DESTINATION ${GR_PYTHON_DIR}/gnuradio/vocoder
+    COMPONENT "vocoder_python"
+)
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+
+list(APPEND GR_TEST_PYTHON_DIRS
+    ${CMAKE_BINARY_DIR}/gr-blocks/python
+    ${CMAKE_BINARY_DIR}/gr-blocks/swig
+    ${CMAKE_BINARY_DIR}/gr-filter/python
+    ${CMAKE_BINARY_DIR}/gr-filter/swig
+    ${CMAKE_BINARY_DIR}/gr-analog/python
+    ${CMAKE_BINARY_DIR}/gr-analog/swig
+    ${CMAKE_BINARY_DIR}/gr-vocoder/python
+    ${CMAKE_BINARY_DIR}/gr-vocoder/swig
+)
+list(APPEND GR_TEST_TARGET_DEPS gnuradio-vocoder)
+
+include(GrTest)
+file(GLOB py_qa_test_files "qa_*.py")
+foreach(py_qa_test_file ${py_qa_test_files})
+    get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+    GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-vocoder/python/vocoder/__init__.py b/gr-vocoder/python/vocoder/__init__.py
new file mode 100644
index 000000000..7b1b82f84
--- /dev/null
+++ b/gr-vocoder/python/vocoder/__init__.py
@@ -0,0 +1,35 @@
+#
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+'''
+This is the gr-vocoder package. This package includes the various
+vocoder blocks in GNU Radio.
+'''
+import os
+
+try:
+    from vocoder_swig import *
+except ImportError:
+    dirname, filename = os.path.split(os.path.abspath(__file__))
+    __path__.append(os.path.join(dirname, "..", "..", "swig"))
+    from vocoder_swig import *
+
+from cvsd import *
diff --git a/gr-vocoder/python/vocoder/cvsd.py b/gr-vocoder/python/vocoder/cvsd.py
new file mode 100644
index 000000000..1c58c3307
--- /dev/null
+++ b/gr-vocoder/python/vocoder/cvsd.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr
+import vocoder_swig
+
+try:
+    from gnuradio import filter
+except ImportError:
+    import filter_swig as filter
+
+try:
+    from gnuradio import blocks
+except ImportError:
+    import blocks_swig as blocks
+
+class cvsd_encode_fb(gr.hier_block2):
+    '''
+    This is a wrapper for the CVSD encoder that performs interpolation and filtering
+    necessary to work with the vocoding. It converts an incoming float (+-1) to a short, scales
+    it (to 32000; slightly below the maximum value), interpolates it, and then vocodes it.
+
+    The incoming sampling rate can be anything, though, of course, the higher the sampling rate and the
+    higher the interpolation rate are, the better the sound quality.
+    '''
+
+    def __init__(self, resample=8, bw=0.5):
+        '''
+        When using the CVSD vocoder, appropriate sampling rates are from 8k to 64k with resampling rates
+        from 1 to 8. A rate of 8k with a resampling rate of 8 provides a good quality signal.
+        '''
+
+	gr.hier_block2.__init__(self, "cvsd_encode",
+				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
+				gr.io_signature(1, 1, gr.sizeof_char))  # Output signature
+
+        scale_factor = 32000.0
+        self.interp = resample
+
+        src_scale = blocks.multiply_const_ff(scale_factor)
+        taps = filter.firdes.low_pass(self.interp, self.interp, bw, 2*bw)
+        interp = filter.interp_fir_filter_fff(self.interp, taps)
+        f2s = blocks.float_to_short()
+        enc = vocoder_swig.cvsd_encode_sb()
+
+        self.connect(self, src_scale, interp, f2s, enc, self)
+
+
+class cvsd_decode_bf(gr.hier_block2):
+    '''
+    This is a wrapper for the CVSD decoder that performs decimation and filtering
+    necessary to work with the vocoding. It converts an incoming CVSD-encoded short to a float, decodes it
+    to a float, decimates it, and scales it (by 32000; slightly below the maximum value to avoid clipping).
+
+    The sampling rate can be anything, though, of course, the higher the sampling rate and the
+    higher the interpolation rate are, the better the sound quality.
+    '''
+
+    def __init__(self, resample=8, bw=0.5):
+        '''
+        When using the CVSD vocoder, appropriate sampling rates are from 8k to 64k with resampling rates
+        from 1 to 8. A rate of 8k with a resampling rate of 8 provides a good quality signal.
+        '''
+	gr.hier_block2.__init__(self, "cvsd_decode",
+				gr.io_signature(1, 1, gr.sizeof_char),  # Input signature
+				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature
+
+        scale_factor = 32000.0
+        self.decim = resample
+
+        dec = vocoder_swig.cvsd_decode_bs()
+        s2f = blocks.short_to_float()
+        taps = filter.firdes.low_pass(1, 1, bw, 2*bw)
+        decim = filter.fir_filter_fff(self.decim, taps)
+        sink_scale = blocks.multiply_const_ff(1.0/scale_factor)
+
+        self.connect(self, dec, s2f, decim, sink_scale, self)
diff --git a/gr-vocoder/python/vocoder/qa_alaw_vocoder.py b/gr-vocoder/python/vocoder/qa_alaw_vocoder.py
new file mode 100755
index 000000000..a8d65409e
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_alaw_vocoder.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_alaw_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = (8,24,40,56,72,88,104,120,136,152,168,184,
+                200,216,232,248,264,280,296,312,328,344)
+        src = gr.vector_source_s(data)
+        enc = alaw_encode_sb()
+        dec = alaw_decode_bs()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(data, actual_result)
+        
+
+if __name__ == '__main__':
+    gr_unittest.run(test_alaw_vocoder, "test_alaw_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_codec2_vocoder.py b/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
new file mode 100755
index 000000000..7f3890445
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_codec2_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = 20*(100,200,300,400,500,600,700,800)
+        expected_data = (0,0,0,3,2,0,1,5,6,7,1,-1,0,-5,-11,-10,-20,-22,
+                         -20,-20,-27,-26,-36,-48,-59,-24,5,-7,-12,-27,-22,
+                         -22,-16,13,20,39,23,25,8,-6,15,44,97,135,145,125,
+                         94,102,126,129,165,192,180,132,99,79,73,83,72,47,
+                         40,0,-32,-46,-67,-99,-123,-114,-87,-108,-131,-152,
+                         -181,-245,-348,-294,-101,-71,-85,-26,99,123,15,2,77,
+                         13,-117,-145,-105,-39,-50,-89,-59,-77,-134,-95,-51,
+                         -22,17,-19,-59,-74,-103,-78,4,77,113,60,18,13,-67,
+                         -49,24,88,179,190,89,18,-90,-102,-50,-5,123,135,57,
+                         31,-82,-98,-51,6,93,104,44,-5,-84,-107,-44,45,102,104,
+                         15,-47,-107,-126,-87,-11,89,93,13,-95,-136,-187,-70,
+                         -167,216,-70,-103,175,-284,-486)
+        src = gr.vector_source_s(data)
+        enc = codec2_encode_sp()
+        dec = codec2_decode_ps()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(expected_data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_codec2_vocoder, "test_codec2_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_cvsd_vocoder.py b/gr-vocoder/python/vocoder/qa_cvsd_vocoder.py
new file mode 100755
index 000000000..42cb7f19b
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_cvsd_vocoder.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+#
+# Copyright 2007,2010,2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+from cvsd import *
+import blocks_swig as blocks
+import filter_swig as filter
+
+class test_cvsd_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        raw_enc = cvsd_encode_sb()
+        raw_dec = cvsd_decode_bs()
+        hb_enc = cvsd_encode_fb()
+        hb_dec = cvsd_decode_bf()
+
+
+    """ Disable for now
+    def test01(self):
+        sample_rate = 8000
+        scale_factor = 32000
+
+        expected_data = (6.9670547250243192e-21, -2.4088578356895596e-05,
+                         -5.1261918997624889e-05, 7.2410854045301676e-05,
+                         8.444241393590346e-05, -1.2537107068055775e-05,
+                         0.00024186755763366818, -0.00060463894624263048,
+                         0.00064864184241741896, 0.010409165173768997,
+                         0.0087582804262638092, 0.017965050414204597,
+                         0.010722399689257145, 0.006602009292691946,
+                         0.02213001623749733, 0.0079685859382152557,
+                         0.033707316964864731, 0.027021972462534904,
+                         0.0086071854457259178, 0.0081678871065378189,
+                         0.039343506097793579, 0.030671956017613411,
+                         0.029626710340380669, 0.020126519724726677,
+                         0.023636780679225922, 0.0064640454947948456,
+                         -0.0038861562497913837, 0.0021134600974619389,
+                         -0.0088051930069923401, -0.00023228264763019979,
+                         -0.033737499266862869, -0.033141419291496277,
+                         -0.037145044654607773, -0.0080892946571111679,
+                         -0.077117636799812317, -0.078382067382335663,
+                         -0.055503919720649719, -0.019355267286300659,
+                         -0.022441385313868523, -0.073706060647964478,
+                         -0.054677654057741165, -0.047119375318288803,
+                         -0.044418536126613617, -0.036084383726119995,
+                         -0.0206278245896101, -0.031200021505355835,
+                         -0.0004070434661116451, 0.0006594572332687676,
+                         -0.016584658995270729, 0.07387717068195343,
+                         -0.0063191778026521206, 0.051200628280639648,
+                         -0.029480356723070145, 0.05176771804690361,
+                         0.038578659296035767, 0.026550088077783585,
+                         0.067103870213031769, 0.001888439292088151,
+                         0.28141644597053528, 0.49543789029121399,
+                         0.6626054048538208, 0.79180729389190674,
+                         0.89210402965545654, 0.96999943256378174,
+                         1.0261462926864624, 1.0267977714538574,
+                         1.0251555442810059, 1.0265737771987915,
+                         1.0278496742248535, 1.0208886861801147,
+                         1.0325057506561279, 0.91415292024612427,
+                         0.83941859006881714, 0.67373806238174438,
+                         0.51683622598648071, 0.38949671387672424,
+                         0.16016888618469238, 0.049505095928907394,
+                         -0.16699212789535522, -0.26886492967605591,
+                         -0.49256673455238342, -0.59178370237350464,
+                         -0.73317724466323853, -0.78922677040100098,
+                         -0.88782668113708496, -0.96708977222442627,
+                         -0.96490746736526489, -0.94962418079376221,
+                         -0.94716215133666992, -0.93755108118057251,
+                         -0.84852480888366699, -0.80485564470291138,
+                         -0.69762390851974487, -0.58398681879043579,
+                         -0.45891636610031128, -0.29681697487831116,
+                         -0.16035343706607819, 0.014823081903159618,
+                         0.16282452642917633, 0.33802291750907898)
+
+        # WARNING: not importing analog in this QA code.
+        # If we enable this, we can probably just create a sin with numpy.
+        src = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 200, 1, 0)
+        head = gr.head(gr.sizeof_float, 100)
+        src_scale = blocks.multiply_const_ff(scale_factor)
+
+        interp = filter.rational_resampler_fff(8, 1)
+        f2s = blocks.float_to_short()
+
+        enc = cvsd_vocoder.encode_sb()
+        dec = cvsd_vocoder.decode_bs()
+
+        s2f = blocks.short_to_float()
+        decim = filter.rational_resampler_fff(1, 8)
+
+        sink_scale = blocks.multiply_const_ff(1.0/scale_factor)
+        sink = gr.vector_sink_f()
+
+        self.tb.connect(src, src_scale, interp, f2s, enc)
+        self.tb.connect(enc, dec, s2f, decim, sink_scale, head, sink)
+        self.tb.run()
+	print sink.data()
+
+        self.assertFloatTuplesAlmostEqual (expected_data, sink.data(), 5)
+    """
+
+if __name__ == '__main__':
+    gr_unittest.run(test_cvsd_vocoder, "test_cvsd_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_g721_vocoder.py b/gr-vocoder/python/vocoder/qa_g721_vocoder.py
new file mode 100755
index 000000000..e6ac04e15
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_g721_vocoder.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_g721_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = (8,24,36,52,56,64,76,88,104,124,132,148,172,
+                196,220,244,280,320,372,416,468,524,580,648)
+        src = gr.vector_source_s(data)
+        enc = g721_encode_sb()
+        dec = g721_decode_bs()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_g721_vocoder, "test_g721_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_g723_24_vocoder.py b/gr-vocoder/python/vocoder/qa_g723_24_vocoder.py
new file mode 100755
index 000000000..eda9ed86b
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_g723_24_vocoder.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_g723_24_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = (0,16,36,40,68,104,148,220,320,512)
+        src = gr.vector_source_s(data)
+        enc = g723_24_encode_sb()
+        dec = g723_24_decode_bs()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_g723_24_vocoder, "test_g723_24_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_g723_40_vocoder.py b/gr-vocoder/python/vocoder/qa_g723_40_vocoder.py
new file mode 100755
index 000000000..db6b7538f
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_g723_40_vocoder.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_g723_40_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = (0,8,36,72,100,152,228,316,404,528)
+        src = gr.vector_source_s(data)
+        enc = g723_40_encode_sb()
+        dec = g723_40_decode_bs()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_g723_40_vocoder, "test_g723_40_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_gsm_full_rate.py b/gr-vocoder/python/vocoder/qa_gsm_full_rate.py
new file mode 100755
index 000000000..4a7692ecd
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_gsm_full_rate.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2007,2010,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+import vocoder_swig
+
+class test_gsm_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block ()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = 20*(100,200,300,400,500,600,700,800)
+        expected_data = (0,0,360,304,256,720,600,504,200,144,128,464,
+                         376,384,680,576,440,264,176,176,640,520,480,
+                         464,384,288,432,296,328,760,624,504,176,96,96,
+                         416,312,360,808,672,216,104,136,504,376,448,
+                         720,608,296,304,176,336,576,456,560,512,320,
+                         216,344,264,456,672,576,488,192,80,152,424,
+                         368,552,688,560,280,200,104,256,520,464,608,
+                         488,184,104,16,472,456,360,696,568,208,136,88,
+                         376,480,456,616,472,232,224,264,320,512,624,
+                         632,520,176,80,192,304,400,592,664,552,248,152,
+                         144,336,440,520,616,664,304,176,80,536,448,376,
+                         680,600,240,168,112,408,488,472,608,480,240,232,
+                         208,288,480,600,616,520,176,88,184,296,392,584,
+                         656,552,248,160,144,336,432,512,608,664)
+        src = gr.vector_source_s(data)
+        enc = vocoder_swig.gsm_fr_encode_sp()
+        dec = vocoder_swig.gsm_fr_decode_ps()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(expected_data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_gsm_vocoder, "test_gsm_vocoder.xml")
diff --git a/gr-vocoder/python/vocoder/qa_ulaw_vocoder.py b/gr-vocoder/python/vocoder/qa_ulaw_vocoder.py
new file mode 100755
index 000000000..a87aae762
--- /dev/null
+++ b/gr-vocoder/python/vocoder/qa_ulaw_vocoder.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#
+# Copyright 2011,2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+from vocoder_swig import *
+
+class test_ulaw_vocoder (gr_unittest.TestCase):
+
+    def setUp (self):
+        self.tb = gr.top_block()
+
+    def tearDown (self):
+        self.tb = None
+
+    def test001_module_load (self):
+        data = (8,24,40,56,72,88,104,120,132,148,164,180,
+                196,212,228,244,260,276,292,308,324,340)
+        src = gr.vector_source_s(data)
+        enc = ulaw_encode_sb()
+        dec = ulaw_decode_bs()
+        snk = gr.vector_sink_s()
+        self.tb.connect(src, enc, dec, snk)
+        self.tb.run()
+        actual_result = snk.data()
+        self.assertEqual(data, actual_result)
+
+if __name__ == '__main__':
+    gr_unittest.run(test_ulaw_vocoder, "test_ulaw_vocoder.xml")
-- 
cgit v1.2.3