[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 06/57: Bring codec2 up to the latest versio
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 06/57: Bring codec2 up to the latest version, and add support for all six bit rates. |
Date: |
Wed, 21 May 2014 03:10:24 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 2126bc4b7f94eff2b9c58e9cd3a34ed4f3798882
Author: Clayton Smith <address@hidden>
Date: Sun Apr 6 08:56:50 2014 -0400
Bring codec2 up to the latest version, and add support for all six bit
rates.
---
gr-vocoder/examples/codec2_audio_loopback.py | 5 ++-
gr-vocoder/grc/vocoder_codec2_decode_ps.xml | 35 ++++++++++++++++-
gr-vocoder/grc/vocoder_codec2_encode_sp.xml | 35 ++++++++++++++++-
gr-vocoder/include/gnuradio/vocoder/CMakeLists.txt | 1 +
.../gnuradio/vocoder/codec2.h} | 41 ++++++++++----------
.../include/gnuradio/vocoder/codec2_decode_ps.h | 2 +-
.../include/gnuradio/vocoder/codec2_encode_sp.h | 2 +-
gr-vocoder/lib/CMakeLists.txt | 1 +
.../lib/{codec2_encode_sp_impl.h => codec2.cc} | 28 +++-----------
gr-vocoder/lib/codec2_decode_ps_impl.cc | 44 ++++++++++++++--------
gr-vocoder/lib/codec2_decode_ps_impl.h | 5 ++-
gr-vocoder/lib/codec2_encode_sp_impl.cc | 35 +++++++++++------
gr-vocoder/lib/codec2_encode_sp_impl.h | 5 ++-
gr-vocoder/python/vocoder/qa_codec2_vocoder.py | 22 ++++-------
gr-vocoder/swig/vocoder_swig.i | 2 +
15 files changed, 166 insertions(+), 97 deletions(-)
diff --git a/gr-vocoder/examples/codec2_audio_loopback.py
b/gr-vocoder/examples/codec2_audio_loopback.py
index bf95f39..b63d508 100755
--- a/gr-vocoder/examples/codec2_audio_loopback.py
+++ b/gr-vocoder/examples/codec2_audio_loopback.py
@@ -24,14 +24,15 @@ from gnuradio import gr
from gnuradio import audio
from gnuradio import blocks
from gnuradio import vocoder
+from gnuradio.vocoder import codec2
def build_graph():
tb = gr.top_block()
src = audio.source(8000)
src_scale = blocks.multiply_const_ff(32767)
f2s = blocks.float_to_short()
- enc = vocoder.codec2_encode_sp()
- dec = vocoder.codec2_decode_ps()
+ enc = vocoder.codec2_encode_sp(codec2.MODE_2400)
+ dec = vocoder.codec2_decode_ps(codec2.MODE_2400)
s2f = blocks.short_to_float()
sink_scale = blocks.multiply_const_ff(1.0/32767.)
sink = audio.sink(8000)
diff --git a/gr-vocoder/grc/vocoder_codec2_decode_ps.xml
b/gr-vocoder/grc/vocoder_codec2_decode_ps.xml
index 8b5f348..b6e10ef 100644
--- a/gr-vocoder/grc/vocoder_codec2_decode_ps.xml
+++ b/gr-vocoder/grc/vocoder_codec2_decode_ps.xml
@@ -8,11 +8,42 @@
<name>CODEC2 Audio Decoder</name>
<key>vocoder_codec2_decode_ps</key>
<import>from gnuradio import vocoder</import>
- <make>vocoder.codec2_decode_ps()</make>
+ <import>from gnuradio.vocoder import codec2</import>
+ <make>vocoder.codec2_decode_ps($mode)</make>
+ <param>
+ <name>Bit rate</name>
+ <key>mode</key>
+ <value>codec2.MODE_2400</value>
+ <type>int</type>
+ <option>
+ <name>3200 bps</name>
+ <key>codec2.MODE_3200</key>
+ </option>
+ <option>
+ <name>2400 bps</name>
+ <key>codec2.MODE_2400</key>
+ </option>
+ <option>
+ <name>1600 bps</name>
+ <key>codec2.MODE_1600</key>
+ </option>
+ <option>
+ <name>1400 bps</name>
+ <key>codec2.MODE_1400</key>
+ </option>
+ <option>
+ <name>1300 bps</name>
+ <key>codec2.MODE_1300</key>
+ </option>
+ <option>
+ <name>1200 bps</name>
+ <key>codec2.MODE_1200</key>
+ </option>
+ </param>
<sink>
<name>in</name>
<type>byte</type>
- <vlen>50</vlen>
+ <vlen>{ 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48 }[$mode]</vlen>
</sink>
<source>
<name>out</name>
diff --git a/gr-vocoder/grc/vocoder_codec2_encode_sp.xml
b/gr-vocoder/grc/vocoder_codec2_encode_sp.xml
index 0fb0ecc..6af54fa 100644
--- a/gr-vocoder/grc/vocoder_codec2_encode_sp.xml
+++ b/gr-vocoder/grc/vocoder_codec2_encode_sp.xml
@@ -8,7 +8,38 @@
<name>CODEC2 Audio Encoder</name>
<key>vocoder_codec2_encode_sp</key>
<import>from gnuradio import vocoder</import>
- <make>vocoder.codec2_encode_sp()</make>
+ <import>from gnuradio.vocoder import codec2</import>
+ <make>vocoder.codec2_encode_sp($mode)</make>
+ <param>
+ <name>Bit rate</name>
+ <key>mode</key>
+ <value>codec2.MODE_2400</value>
+ <type>int</type>
+ <option>
+ <name>3200 bps</name>
+ <key>codec2.MODE_3200</key>
+ </option>
+ <option>
+ <name>2400 bps</name>
+ <key>codec2.MODE_2400</key>
+ </option>
+ <option>
+ <name>1600 bps</name>
+ <key>codec2.MODE_1600</key>
+ </option>
+ <option>
+ <name>1400 bps</name>
+ <key>codec2.MODE_1400</key>
+ </option>
+ <option>
+ <name>1300 bps</name>
+ <key>codec2.MODE_1300</key>
+ </option>
+ <option>
+ <name>1200 bps</name>
+ <key>codec2.MODE_1200</key>
+ </option>
+ </param>
<sink>
<name>in</name>
<type>short</type>
@@ -16,7 +47,7 @@
<source>
<name>out</name>
<type>byte</type>
- <vlen>50</vlen>
+ <vlen>{ 0: 64, 1: 48, 2: 64, 3: 56, 4: 52, 5: 48 }[$mode]</vlen>
</source>
</block>
diff --git a/gr-vocoder/include/gnuradio/vocoder/CMakeLists.txt
b/gr-vocoder/include/gnuradio/vocoder/CMakeLists.txt
index ea0562f..1ad2f71 100644
--- a/gr-vocoder/include/gnuradio/vocoder/CMakeLists.txt
+++ b/gr-vocoder/include/gnuradio/vocoder/CMakeLists.txt
@@ -24,6 +24,7 @@ install(FILES
api.h
alaw_decode_bs.h
alaw_encode_sb.h
+ codec2.h
codec2_decode_ps.h
codec2_encode_sp.h
cvsd_decode_bs.h
diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.h
b/gr-vocoder/include/gnuradio/vocoder/codec2.h
similarity index 55%
copy from gr-vocoder/lib/codec2_encode_sp_impl.h
copy to gr-vocoder/include/gnuradio/vocoder/codec2.h
index 7402d09..ca09e4d 100644
--- a/gr-vocoder/lib/codec2_encode_sp_impl.h
+++ b/gr-vocoder/include/gnuradio/vocoder/codec2.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013,2014 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,32 +20,35 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H
-#define INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H
+#ifndef _VOCODER_CODEC2_H_
+#define _VOCODER_CODEC2_H_
-#include <gnuradio/vocoder/codec2_encode_sp.h>
+#include <gnuradio/vocoder/api.h>
+
+extern "C" {
+#include "../lib/codec2/codec2.h"
+}
namespace gr {
namespace vocoder {
- class codec2_encode_sp_impl : public codec2_encode_sp
- {
- private:
- void *d_codec2;
- std::vector<unsigned char> d_frame_buf; //!< Save 1 CODEC2 frame
-
- void unpack_frame(const unsigned char *packed, unsigned char *out); //!<
Unpack the bytes from codec2 into unpacked bits
-
+ class VOCODER_API codec2 {
public:
- codec2_encode_sp_impl();
- ~codec2_encode_sp_impl();
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
+ enum bit_rate {
+ MODE_3200 = CODEC2_MODE_3200,
+ MODE_2400 = CODEC2_MODE_2400,
+ MODE_1600 = CODEC2_MODE_1600,
+ MODE_1400 = CODEC2_MODE_1400,
+ MODE_1300 = CODEC2_MODE_1300,
+ MODE_1200 = CODEC2_MODE_1200,
+ };
+
+ private:
+ };
+
} /* namespace vocoder */
} /* namespace gr */
-#endif /* INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H */
+#endif /* _VOCODER_CODEC2_H_ */
diff --git a/gr-vocoder/include/gnuradio/vocoder/codec2_decode_ps.h
b/gr-vocoder/include/gnuradio/vocoder/codec2_decode_ps.h
index 0418771..2b74c01 100644
--- a/gr-vocoder/include/gnuradio/vocoder/codec2_decode_ps.h
+++ b/gr-vocoder/include/gnuradio/vocoder/codec2_decode_ps.h
@@ -48,7 +48,7 @@ namespace gr {
/*!
* \brief Make Codec2 decoder block.
*/
- static sptr make();
+ static sptr make(int mode);
};
} /* namespace vocoder */
diff --git a/gr-vocoder/include/gnuradio/vocoder/codec2_encode_sp.h
b/gr-vocoder/include/gnuradio/vocoder/codec2_encode_sp.h
index 12b91b0..a6acc58 100644
--- a/gr-vocoder/include/gnuradio/vocoder/codec2_encode_sp.h
+++ b/gr-vocoder/include/gnuradio/vocoder/codec2_encode_sp.h
@@ -53,7 +53,7 @@ namespace gr {
/*!
* \brief Make Codec2 encoder block.
*/
- static sptr make();
+ static sptr make(int mode);
};
} /* namespace vocoder */
diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt
index 67271ee..e11b143 100644
--- a/gr-vocoder/lib/CMakeLists.txt
+++ b/gr-vocoder/lib/CMakeLists.txt
@@ -100,6 +100,7 @@ link_directories(${LOG4CPP_LIBRARY_DIRS})
list(APPEND gr_vocoder_sources
alaw_decode_bs_impl.cc
alaw_encode_sb_impl.cc
+ codec2.cc
codec2_decode_ps_impl.cc
codec2_encode_sp_impl.cc
cvsd_decode_bs_impl.cc
diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.h b/gr-vocoder/lib/codec2.cc
similarity index 52%
copy from gr-vocoder/lib/codec2_encode_sp_impl.h
copy to gr-vocoder/lib/codec2.cc
index 7402d09..6d0ef61 100644
--- a/gr-vocoder/lib/codec2_encode_sp_impl.h
+++ b/gr-vocoder/lib/codec2.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013,2014 Free Software Foundation, Inc.
+ * Copyright 2002,2007,2008,2012,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,32 +20,14 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H
-#define INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
-#include <gnuradio/vocoder/codec2_encode_sp.h>
+#include <gnuradio/vocoder/codec2.h>
namespace gr {
namespace vocoder {
- class codec2_encode_sp_impl : public codec2_encode_sp
- {
- private:
- void *d_codec2;
- std::vector<unsigned char> d_frame_buf; //!< Save 1 CODEC2 frame
-
- void unpack_frame(const unsigned char *packed, unsigned char *out); //!<
Unpack the bytes from codec2 into unpacked bits
-
- public:
- codec2_encode_sp_impl();
- ~codec2_encode_sp_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
} /* namespace vocoder */
} /* namespace gr */
-
-#endif /* INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H */
diff --git a/gr-vocoder/lib/codec2_decode_ps_impl.cc
b/gr-vocoder/lib/codec2_decode_ps_impl.cc
index a4f7ccc..fa4c183 100644
--- a/gr-vocoder/lib/codec2_decode_ps_impl.cc
+++ b/gr-vocoder/lib/codec2_decode_ps_impl.cc
@@ -24,12 +24,12 @@
#include "config.h"
#endif
-#include "codec2_decode_ps_impl.h"
-
extern "C" {
#include "codec2/codec2.h"
}
+#include "codec2_decode_ps_impl.h"
+
#include <gnuradio/io_signature.h>
#include <stdexcept>
#include <assert.h>
@@ -38,22 +38,34 @@ namespace gr {
namespace vocoder {
codec2_decode_ps::sptr
- codec2_decode_ps::make()
+ codec2_decode_ps::make(int mode)
{
+ CODEC2 *codec2;
+ int samples_per_frame, bits_per_frame;
+
+ // Check the number of input samples and output bits per frame.
+ codec2 = codec2_create(mode);
+ samples_per_frame = codec2_samples_per_frame(codec2);
+ bits_per_frame = codec2_bits_per_frame(codec2);
+ codec2_destroy(codec2);
+
return gnuradio::get_initial_sptr
- (new codec2_decode_ps_impl());
+ (new codec2_decode_ps_impl(mode, samples_per_frame, bits_per_frame));
}
- codec2_decode_ps_impl::codec2_decode_ps_impl ()
+ codec2_decode_ps_impl::codec2_decode_ps_impl (int mode, int
samples_per_frame, int bits_per_frame)
: sync_interpolator("vocoder_codec2_decode_ps",
- io_signature::make(1, 1, CODEC2_BITS_PER_FRAME *
sizeof(char)),
+ io_signature::make(1, 1, bits_per_frame *
sizeof(char)),
io_signature::make (1, 1, sizeof(short)),
- CODEC2_SAMPLES_PER_FRAME),
- d_frame_buf(CODEC2_BYTES_PER_FRAME, 0)
+ samples_per_frame),
+ d_frame_buf((bits_per_frame + 7) / 8, 0)
{
- if((d_codec2 = codec2_create()) == 0)
+ if((d_codec2 = codec2_create(mode)) == 0)
throw std::runtime_error("codec2_decode_ps_impl: codec2_create failed");
+ d_samples_per_frame = samples_per_frame;
+ d_bits_per_frame = bits_per_frame;
+ d_bytes_per_frame = (bits_per_frame + 7) / 8;
}
codec2_decode_ps_impl::~codec2_decode_ps_impl()
@@ -69,13 +81,13 @@ namespace gr {
const unsigned char *in = (const unsigned char*)input_items[0];
short *out = (short *) output_items[0];
- assert((noutput_items % CODEC2_SAMPLES_PER_FRAME) == 0);
+ assert((noutput_items % d_samples_per_frame) == 0);
- for(int i = 0; i < noutput_items; i += CODEC2_SAMPLES_PER_FRAME) {
+ for(int i = 0; i < noutput_items; i += d_samples_per_frame) {
pack_frame(in, &d_frame_buf[0]);
- codec2_decode (d_codec2, out, const_cast<unsigned
char*>(&d_frame_buf[0]));
- in += CODEC2_BITS_PER_FRAME * sizeof (char);
- out += CODEC2_SAMPLES_PER_FRAME;
+ codec2_decode (d_codec2, out, const_cast<unsigned
char*>(&d_frame_buf[0]), 0.0);
+ in += d_bits_per_frame * sizeof (char);
+ out += d_samples_per_frame;
}
return noutput_items;
@@ -84,10 +96,10 @@ namespace gr {
void
codec2_decode_ps_impl::pack_frame(const unsigned char *in_unpacked,
unsigned char *out_packed)
{
- memset((void *) &d_frame_buf[0], 0x00, CODEC2_BYTES_PER_FRAME);
+ memset((void *) &d_frame_buf[0], 0x00, d_bytes_per_frame);
int byte_idx = 0, bit_idx = 0;
- for(int k = 0; k < CODEC2_BITS_PER_FRAME; k++) {
+ for(int k = 0; k < d_bits_per_frame; k++) {
out_packed[byte_idx] |= ((in_unpacked[k] & 0x01) << (7-bit_idx));
bit_idx = (bit_idx + 1) % 8;
if (bit_idx == 0) {
diff --git a/gr-vocoder/lib/codec2_decode_ps_impl.h
b/gr-vocoder/lib/codec2_decode_ps_impl.h
index b9591dc..db5ba2e 100644
--- a/gr-vocoder/lib/codec2_decode_ps_impl.h
+++ b/gr-vocoder/lib/codec2_decode_ps_impl.h
@@ -31,13 +31,14 @@ namespace gr {
class codec2_decode_ps_impl : public codec2_decode_ps
{
private:
- void *d_codec2;
+ CODEC2 *d_codec2;
+ int d_samples_per_frame, d_bits_per_frame, d_bytes_per_frame;
std::vector<unsigned char> d_frame_buf; //!< Store 1 packed frame for
decoding
void pack_frame(const unsigned char *in_unpacked, unsigned char
*out_packed); //!< Pack the bytes from unpacked bits for codec2
public:
- codec2_decode_ps_impl();
+ codec2_decode_ps_impl(int mode, int samples_per_frame, int
bits_per_frame);
~codec2_decode_ps_impl();
int work(int noutput_items,
diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.cc
b/gr-vocoder/lib/codec2_encode_sp_impl.cc
index fc0b3ee..ae76b09 100644
--- a/gr-vocoder/lib/codec2_encode_sp_impl.cc
+++ b/gr-vocoder/lib/codec2_encode_sp_impl.cc
@@ -24,12 +24,12 @@
#include "config.h"
#endif
-#include "codec2_encode_sp_impl.h"
-
extern "C" {
#include "codec2/codec2.h"
}
+#include "codec2_encode_sp_impl.h"
+
#include <gnuradio/io_signature.h>
#include <stdexcept>
#include <iostream>
@@ -39,21 +39,32 @@ namespace gr {
namespace vocoder {
codec2_encode_sp::sptr
- codec2_encode_sp::make()
+ codec2_encode_sp::make(int mode)
{
+ CODEC2 *codec2;
+ int samples_per_frame, bits_per_frame;
+
+ // Check the number of input samples and output bits per frame.
+ codec2 = codec2_create(mode);
+ samples_per_frame = codec2_samples_per_frame(codec2);
+ bits_per_frame = codec2_bits_per_frame(codec2);
+ codec2_destroy(codec2);
+
return gnuradio::get_initial_sptr
- (new codec2_encode_sp_impl());
+ (new codec2_encode_sp_impl(mode, samples_per_frame, bits_per_frame));
}
- codec2_encode_sp_impl::codec2_encode_sp_impl()
+ codec2_encode_sp_impl::codec2_encode_sp_impl(int mode, int
samples_per_frame, int bits_per_frame)
: sync_decimator("vocoder_codec2_encode_sp",
io_signature::make(1, 1, sizeof(short)),
- io_signature::make(1, 1, CODEC2_BITS_PER_FRAME *
sizeof(char)),
- CODEC2_SAMPLES_PER_FRAME),
- d_frame_buf(CODEC2_BYTES_PER_FRAME, 0)
+ io_signature::make(1, 1, bits_per_frame *
sizeof(char)),
+ samples_per_frame),
+ d_frame_buf((bits_per_frame + 7) / 8, 0)
{
- if((d_codec2 = codec2_create()) == 0)
+ if((d_codec2 = codec2_create(mode)) == 0)
throw std::runtime_error("codec2_encode_sp_impl: codec2_create failed");
+ d_samples_per_frame = samples_per_frame;
+ d_bits_per_frame = bits_per_frame;
}
codec2_encode_sp_impl::~codec2_encode_sp_impl()
@@ -72,8 +83,8 @@ namespace gr {
for(int i = 0; i < noutput_items; i++) {
codec2_encode(d_codec2, &d_frame_buf[0], const_cast<short*>(in));
unpack_frame((const unsigned char *) &d_frame_buf[0], out);
- in += CODEC2_SAMPLES_PER_FRAME;
- out += CODEC2_BITS_PER_FRAME * sizeof(char);
+ in += d_samples_per_frame;
+ out += d_bits_per_frame * sizeof(char);
}
return noutput_items;
@@ -83,7 +94,7 @@ namespace gr {
codec2_encode_sp_impl::unpack_frame(const unsigned char *packed, unsigned
char *out)
{
int byte_idx = 0, bit_idx = 0;
- for(int k = 0; k < CODEC2_BITS_PER_FRAME; k++) {
+ for(int k = 0; k < d_bits_per_frame; k++) {
out[k] = (packed[byte_idx] >> (7-bit_idx)) & 0x01;
bit_idx = (bit_idx + 1) % 8;
if (bit_idx == 0) {
diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.h
b/gr-vocoder/lib/codec2_encode_sp_impl.h
index 7402d09..17d6f4e 100644
--- a/gr-vocoder/lib/codec2_encode_sp_impl.h
+++ b/gr-vocoder/lib/codec2_encode_sp_impl.h
@@ -31,13 +31,14 @@ namespace gr {
class codec2_encode_sp_impl : public codec2_encode_sp
{
private:
- void *d_codec2;
+ CODEC2 *d_codec2;
+ int d_samples_per_frame, d_bits_per_frame;
std::vector<unsigned char> d_frame_buf; //!< Save 1 CODEC2 frame
void unpack_frame(const unsigned char *packed, unsigned char *out); //!<
Unpack the bytes from codec2 into unpacked bits
public:
- codec2_encode_sp_impl();
+ codec2_encode_sp_impl(int mode, int samples_per_frame, int
bits_per_frame);
~codec2_encode_sp_impl();
int work(int noutput_items,
diff --git a/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
b/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
index 0e29401..8fe3ac5 100755
--- a/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
+++ b/gr-vocoder/python/vocoder/qa_codec2_vocoder.py
@@ -21,6 +21,7 @@
#
from gnuradio import gr, gr_unittest, vocoder, blocks
+from gnuradio.vocoder import codec2
class test_codec2_vocoder (gr_unittest.TestCase):
@@ -31,27 +32,18 @@ class test_codec2_vocoder (gr_unittest.TestCase):
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)
+ data = 40*(100,200,300,400,500,600,700,800)
+ expected_data = (0, 5, 10, 14, 15, 13, 14, 20, 40, 46, 39, 36, 35, 33,
22, 17, 31, 34, 29, 24, 24, 15, -3, -8, -7, 1, -4, -11, -14, -22, -39, -53,
-51, -52, -58, -58, -59, -58, -61, -74, -73, -79, -75, -61, -73, -76, -72, -75,
-62, -74, -75, -64, -64, -59, -61, -49, -68, -60, -23, -46, -48, -33, -48, 2,
20, -3, 2, -8, 9, 38, 9, 16, 23, 16, 44, 65, 37, 24, 25, 55, 61, 57, 52, 39,
47, 57, 66, 73, 50, 46, 47, 55, 55, 45, 73, 86, 63, 66, 60, 55, 60, 55, 71, 59,
46, 58, 46, 2, 38, 50, [...]
+
src = blocks.vector_source_s(data)
- enc = vocoder.codec2_encode_sp()
- dec = vocoder.codec2_decode_ps()
+ enc = vocoder.codec2_encode_sp(codec2.MODE_2400)
+ dec = vocoder.codec2_decode_ps(codec2.MODE_2400)
snk = blocks.vector_sink_s()
self.tb.connect(src, enc, dec, snk)
self.tb.run()
actual_result = snk.data()
self.assertEqual(expected_data, actual_result)
+ self.tb.disconnect(src, enc, dec, snk)
if __name__ == '__main__':
# Note: The Vocoder is stateful, which means this test will produce
failure when removing the xml option.
diff --git a/gr-vocoder/swig/vocoder_swig.i b/gr-vocoder/swig/vocoder_swig.i
index c404ea2..dac35c9 100644
--- a/gr-vocoder/swig/vocoder_swig.i
+++ b/gr-vocoder/swig/vocoder_swig.i
@@ -30,6 +30,7 @@
%{
#include "gnuradio/vocoder/alaw_decode_bs.h"
#include "gnuradio/vocoder/alaw_encode_sb.h"
+#include "gnuradio/vocoder/codec2.h"
#include "gnuradio/vocoder/codec2_decode_ps.h"
#include "gnuradio/vocoder/codec2_encode_sp.h"
#include "gnuradio/vocoder/cvsd_decode_bs.h"
@@ -48,6 +49,7 @@
%include "gnuradio/vocoder/alaw_decode_bs.h"
%include "gnuradio/vocoder/alaw_encode_sb.h"
+%include "gnuradio/vocoder/codec2.h"
%include "gnuradio/vocoder/codec2_decode_ps.h"
%include "gnuradio/vocoder/codec2_encode_sp.h"
%include "gnuradio/vocoder/cvsd_decode_bs.h"
- [Commit-gnuradio] [gnuradio] branch master updated (cb0bc7f -> 4750647), git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 01/57: cmake and build: fixes for cross-compiling to enable ControlPort with ICE., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 06/57: Bring codec2 up to the latest version, and add support for all six bit rates.,
git <=
- [Commit-gnuradio] [gnuradio] 12/57: qtgui: removing unused NumberDisplayPlot; the number sink doesn't have a canvas like the other plotters do and so doesn't require this., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 04/57: controlport: allows reset_perf_counters to be called over controlport; gr-perf-monitorx has button to call this., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 07/57: vocoder: add default mode parameter and updated documentation, git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 10/57: controlport: in gr-perf-monitorx, if all work times returned are 0, avoid a divide-by-zero fault., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 11/57: docs: doxygen mangles sections named with the same reference name. ControlPort and Vocoder both used 'using' - renamed for each., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 13/57: volk: adding a rate 1/2, K=7 convolutional decoder volk kernel., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 14/57: block interleave/deinterleave with statefull deinterleave, git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 03/57: controlport: adding a 'toggle' interface for ControlPort., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 20/57: digital: correlate_access_code_tag d_mask was set improperly when access code len = 64., git, 2014/05/20
- [Commit-gnuradio] [gnuradio] 09/57: documentation - fix example in case anyone gets confused, git, 2014/05/20