software codec option, fix gruel incl

git-svn-id: http://op25.osmocom.org/svn/trunk@321 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
max 2013-09-11 01:47:15 +00:00
parent fbffa862a8
commit 3293212043
5 changed files with 35 additions and 8 deletions

View File

@ -27,7 +27,7 @@ grincludedir = $(includedir)/gnuradio
swigincludedir = $(grincludedir)/swig
# gruel includes
gruelincludedir = $(includedir)/gruel
gruelincludedir = $(GRUEL_INCLUDEDIR)/gruel
# Install this stuff in the appropriate subdirectory
# This usually ends up at:

View File

@ -87,6 +87,8 @@ GR_REQUIRE_BOOST_INCLUDES
STD_DEFINES_AND_INCLUDES="$GNURADIO_CORE_CFLAGS $BOOST_CFLAGS"
AC_SUBST(STD_DEFINES_AND_INCLUDES)
PKG_CHECK_MODULES(GRUEL, gruel)
AC_CONFIG_FILES([\
Makefile \

View File

@ -85,7 +85,9 @@ _repeater_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version -L../../../imbe_vo
# c++ standard library
_repeater_la_LIBADD = \
$(PYTHON_LDFLAGS) \
-lstdc++
-lstdc++ \
../../../blocks/src/lib/software_imbe_decoder.lo \
../../../blocks/src/lib/imbe_decoder.lo
repeater.cc repeater.py: repeater.i $(ALL_IFILES)
$(SWIG) $(SWIGPYTHONARGS) -module repeater -o repeater.cc $<

View File

@ -225,6 +225,12 @@ repeater_vocoder::repeater_vocoder (bool encode_flag, bool verbose_flag, int str
init_sock(udp_host, opt_udp_port);
clear_bits(f_body);
const char *p = getenv("IMBE");
if (p && strcasecmp(p, "soft") == 0)
d_software_imbe_decoder = true;
else
d_software_imbe_decoder = false;
}
/*
@ -313,14 +319,26 @@ void repeater_vocoder::rxchar(char c)
rxbuf[rxbufp] = 0;
sscanf(rxbuf, "%x %x %x %x %x %x %x %x", &u[0], &u[1], &u[2], &u[3], &u[4], &u[5], &u[6], &u[7]);
rxbufp = 0;
for (int i=0; i < 8; i++) {
frame_vector[i] = u[i];
}
/* TEST*/ frame_vector[7] >>= 1;
// decode 88 bits, outputs 160 sound samples (8000 rate)
vocoder.imbe_decode(frame_vector, snd);
if (d_software_imbe_decoder) {
voice_codeword cw;
imbe_header_encode(cw, u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]);
software_decoder.decode(cw);
audio_samples *samples = software_decoder.audio();
assert (samples->size() == FRAME);
for (int i=0; i < FRAME; i++) {
snd[i] = (int16_t)(samples->front() * 32768.0);
samples->pop_front();
}
} else {
for (int i=0; i < 8; i++) {
frame_vector[i] = u[i];
}
/* TEST*/ frame_vector[7] >>= 1;
vocoder.imbe_decode(frame_vector, snd);
}
if (opt_udp_port > 0) {
sendto(write_sock, snd, FRAME * sizeof(uint16_t), 0, (struct sockaddr*)&write_sock_addr, sizeof(write_sock_addr));
sendto(write_sock, snd, FRAME * sizeof(int16_t), 0, (struct sockaddr*)&write_sock_addr, sizeof(write_sock_addr));
} else {
// add generated samples to output queue
for (int i = 0; i < FRAME; i++) {

View File

@ -32,6 +32,9 @@ typedef std::vector<bool> bit_vector;
#include <imbe_vocoder.h>
#include <imbe_decoder.h>
#include <software_imbe_decoder.h>
class repeater_vocoder;
/*
@ -115,6 +118,8 @@ private:
uint8_t save_l;
bit_vector f_body;
imbe_vocoder vocoder;
software_imbe_decoder software_decoder;
bool d_software_imbe_decoder;
std::deque<uint8_t> output_queue;
std::deque<uint16_t> output_queue_decode;