diff options
Diffstat (limited to 'gr-cvsd-vocoder/src/lib')
-rw-r--r-- | gr-cvsd-vocoder/src/lib/Makefile.am | 97 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/__init__.py | 20 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc | 196 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/cvsd_decode_bs.h | 97 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc | 194 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/cvsd_encode_sb.h | 96 | ||||
-rw-r--r-- | gr-cvsd-vocoder/src/lib/cvsd_vocoder.i | 85 |
7 files changed, 785 insertions, 0 deletions
diff --git a/gr-cvsd-vocoder/src/lib/Makefile.am b/gr-cvsd-vocoder/src/lib/Makefile.am new file mode 100644 index 0000000000..644966b852 --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/Makefile.am @@ -0,0 +1,97 @@ +# +# Copyright 2004,2005 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 2, 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. +# + +include $(top_srcdir)/Makefile.common + +# Install this stuff so that it ends up as the gnuradio.vocoder module +# This usually ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio/vocoder + +ourpythondir = $(grpythondir)/vocoder +ourlibdir = $(grpyexecdir)/vocoder + +INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) + +SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES) + + +ALL_IFILES = \ + $(LOCAL_IFILES) \ + $(NON_LOCAL_IFILES) + +NON_LOCAL_IFILES = \ + $(GNURADIO_I) + + +LOCAL_IFILES = \ + $(top_srcdir)/gr-cvsd-vocoder/src/lib/cvsd_vocoder.i + +# These files are built by SWIG. The first is the C++ glue. +# The second is the python wrapper that loads the _howto shared library +# and knows how to call our extensions. + +BUILT_SOURCES = \ + cvsd_vocoder.cc \ + cvsd_vocoder.py + +# This gets cvsd_vocoder.py installed in the right place +ourpython_PYTHON = \ + __init__.py \ + cvsd_vocoder.py + +ourlib_LTLIBRARIES = _cvsd_vocoder.la + +# These are the source files that go into the shared library +_cvsd_vocoder_la_SOURCES = \ + cvsd_decode_bs.cc \ + cvsd_encode_sb.cc \ + cvsd_vocoder.cc + + +# magic flags +_cvsd_vocoder_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version + +# link the library against the c++ standard library +_cvsd_vocoder_la_LIBADD = \ + $(PYTHON_LDFLAGS) \ + $(GNURADIO_CORE_LA) \ + -lstdc++ + +cvsd_vocoder.cc cvsd_vocoder.py: cvsd_vocoder.i $(ALL_IFILES) + $(SWIG) $(SWIGPYTHONARGS) -module cvsd_vocoder -o cvsd_vocoder.cc $(LOCAL_IFILES) + +# These headers get installed in ${prefix}/include/gnuradio +grinclude_HEADERS = \ + cvsd_decode_bs.h \ + cvsd_encode_sb.h + +# These swig headers get installed in ${prefix}/include/gnuradio/swig +swiginclude_HEADERS = \ + $(LOCAL_IFILES) + + +MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc + +# Don't distribute output of swig +dist-hook: + @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done + @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done + diff --git a/gr-cvsd-vocoder/src/lib/__init__.py b/gr-cvsd-vocoder/src/lib/__init__.py new file mode 100644 index 0000000000..4f066df09b --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/__init__.py @@ -0,0 +1,20 @@ +# +# Copyright 2005 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 2, 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. +# diff --git a/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc new file mode 100644 index 0000000000..def2d946e3 --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc @@ -0,0 +1,196 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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 2, 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. + */ + +/* + * config.h is generated by configure. It contains the results + * of probing for features, options etc. It should be the first + * file included in your .cc file. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cvsd_decode_bs.h> +#include <gr_io_signature.h> + +/* + * Create a new instance of cvsd_decode_bs and return + * a boost shared_ptr. This is effectively the public constructor. + */ +cvsd_decode_bs_sptr +cvsd_make_decode_bs (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max) +{ + return cvsd_decode_bs_sptr (new cvsd_decode_bs (min_step, max_step, + step_decay, accum_decay, K, J, + pos_accum_max, neg_accum_max)); +} + +cvsd_decode_bs::cvsd_decode_bs (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max) + : gr_sync_interpolator ("cvsd_decode_bs", + gr_make_io_signature (1, 1, sizeof (unsigned char)), + gr_make_io_signature (1, 1, sizeof (short)), + 8), + d_min_step (min_step), d_max_step(max_step), d_step_decay(step_decay), + d_accum_decay(accum_decay), d_K(K), d_J(J), + d_pos_accum_max(pos_accum_max), d_neg_accum_max(neg_accum_max), + d_accum(0), + d_loop_counter(1), + d_runner(0), + d_runner_mask(0), + d_stepsize(min_step) + +{ + assert(d_pos_accum_max <= SHRT_MAX); + assert(d_neg_accum_max >= -SHRT_MAX); + assert(d_K <= 32); + assert(d_J <= d_K); + + // nothing else required in this example +} + + +cvsd_decode_bs::~cvsd_decode_bs () +{ + // nothing else required in this example +} + +unsigned char cvsd_decode_bs::cvsd_bitwise_sum (unsigned int input) +{ + unsigned int temp=input; + unsigned char bits=0; + + while(temp) { + temp=temp&(temp-1); + bits++; + } + return bits; +} + +int cvsd_decode_bs::cvsd_round (double input) +{ + double temp; + temp=input+0.5; + temp=floor(temp); + + return (int)temp; +} + +unsigned int cvsd_decode_bs::cvsd_pow (short radix, short power) +{ + double d_radix = (double) radix; + int i_power = (int) power; + double output; + + output=pow(d_radix,i_power); + return ( (unsigned int) cvsd_round(output)); +} + + +int +cvsd_decode_bs::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + + + const unsigned char *in = (const unsigned char *) input_items[0]; + short *out = (short *) output_items[0]; + + int i=0; + short output_short=0; // 2 bytes 0 .. 65,535 + unsigned char bit_count=0; // 1 byte, 0 .. 255 + unsigned int mask=0; // 4 bytes, 0 .. 4,294,967,295 + unsigned char input_byte=0; // 1 bytes + unsigned char input_bit=0; // 1 byte, 0 .. 255 + + // Loop through each input data point + for(i = 0; i < noutput_items/8.0; i++) { + + input_byte = in[i]; + // Initiliaze bit counter + bit_count=0; + + while(bit_count<8) { + // Compute the Appropriate Mask + mask=cvsd_pow(2,7-bit_count); + + // Pull off the corresponding bit + input_bit = input_byte & mask; + + // Update the bit counter + bit_count++; + + // Update runner with the next input bit + // Runner is a shift-register; shift left, add on newest output bit + d_runner = (d_runner<<1) | ((unsigned int) input_bit); + + // Run this only if you have >= J bits in your shift register + if (d_loop_counter>=d_J) { + // Update Step Size + d_runner_mask=(cvsd_pow(2,d_J)-1); + if ((cvsd_bitwise_sum(d_runner & d_runner_mask)>=d_J)||(cvsd_bitwise_sum((~d_runner) & d_runner_mask)>=d_J)) { + // Runs of 1s and 0s + d_stepsize = std::min( (short) (d_stepsize + d_min_step), d_max_step); + } + else { + // No runs of 1s and 0s + d_stepsize = std::max( (short) cvsd_round(d_stepsize*d_step_decay), d_min_step); + } + } + + // Update Accum (i.e. the reference value) + if (input_bit) { + d_accum=d_accum+d_stepsize; + } + else { + d_accum=d_accum-d_stepsize; + } + + // Multiply by Accum_Decay + d_accum=(cvsd_round(d_accum*d_accum_decay)); + + // Check for overflow + if (d_accum >=((int) d_pos_accum_max)) { + d_accum=(int)d_pos_accum_max; + } + else if (d_accum <=((int) d_neg_accum_max)) { + d_accum=(int)d_neg_accum_max; + } + + // Find the output short to write to the file + output_short=((short) d_accum); + + if (d_loop_counter <= d_K) { + d_loop_counter++; + } + + *(out++) = output_short; + } // while () + + } // for() + + return noutput_items; +} diff --git a/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.h b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.h new file mode 100644 index 0000000000..d23c20e30a --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.h @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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 2, 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. + */ +#ifndef INCLUDED_CVSD_DECODE_BS_H +#define INCLUDED_CVSD_DECODE_BS_H + +#include <gr_sync_interpolator.h> + +class cvsd_decode_bs; + +typedef boost::shared_ptr<cvsd_decode_bs> cvsd_decode_bs_sptr; + +cvsd_decode_bs_sptr cvsd_make_decode_bs (short min_step=10, + short max_step=1280, + double step_decay=0.9990234375, + double accum_decay= 0.96875, + int K=32, + int J=4, + short pos_accum_max=32767, + short neg_accum_max=-32767); + +class cvsd_decode_bs : public gr_sync_interpolator +{ +private: + friend cvsd_decode_bs_sptr cvsd_make_decode_bs (short min_step, + short max_step, + double step_decay, + double accum_decay, + int K, + int J, + short pos_accum_max, + short neg_accum_max); + + cvsd_decode_bs (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max); + + int cvsd_round(double input); + unsigned int cvsd_pow (short radix, short power); + unsigned char cvsd_bitwise_sum (unsigned int input); + + short d_min_step; + short d_max_step; + double d_step_decay; + double d_accum_decay; + + //! \brief Size of shift register; the number of output bits remembered in shift register + int d_K; + + //! \brief Number of bits in the shift register that are equal; size of run of 1s, 0s + int d_J; + + short d_pos_accum_max; + short d_neg_accum_max; + + int d_accum; + int d_loop_counter; + unsigned int d_runner; + unsigned int d_runner_mask; // 4 bytes, 0 .. 4,294,967,295 + short d_stepsize; + + public: + ~cvsd_decode_bs (); // public destructor + + short min_step() { return d_min_step; } + short max_step() { return d_max_step; } + double step_decay() { return d_step_decay; } + double accum_decay() { return d_accum_decay; } + int K() { return d_K; } + int J() { return d_J; } + short pos_accum_max() { return d_pos_accum_max; } + short neg_accum_max() { return d_neg_accum_max; } + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_CVSD_DECODE_BS_H */ diff --git a/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc new file mode 100644 index 0000000000..37e2fb0b47 --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc @@ -0,0 +1,194 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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 2, 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. + */ + +/* + * config.h is generated by configure. It contains the results + * of probing for features, options etc. It should be the first + * file included in your .cc file. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cvsd_encode_sb.h> +#include <gr_io_signature.h> + +/* + * Create a new instance of cvsd_encode_sb and return + * a boost shared_ptr. This is effectively the public constructor. + */ +cvsd_encode_sb_sptr +cvsd_make_encode_sb (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max) +{ + return cvsd_encode_sb_sptr (new cvsd_encode_sb (min_step, max_step, + step_decay, accum_decay, K, J, + pos_accum_max, neg_accum_max)); +} + +cvsd_encode_sb::cvsd_encode_sb (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max) + : gr_sync_decimator ("cvsd_encode_sb", + gr_make_io_signature (1, 1, sizeof (short)), + gr_make_io_signature (1, 1, sizeof (unsigned char)), + 8), + d_min_step (min_step), d_max_step(max_step), d_step_decay(step_decay), + d_accum_decay(accum_decay), d_K(K), d_J(J), + d_pos_accum_max(pos_accum_max), d_neg_accum_max(neg_accum_max), + d_accum(0), + d_loop_counter(1), + d_runner(0), + d_stepsize(min_step) + +{ + assert(d_pos_accum_max <= SHRT_MAX); + assert(d_neg_accum_max >= -SHRT_MAX); + assert(d_K <= 32); + assert(d_J <= d_K); + + // nothing else required in this example +} + + +cvsd_encode_sb::~cvsd_encode_sb () +{ + // nothing else required in this example +} + +unsigned char cvsd_encode_sb::cvsd_bitwise_sum (unsigned int input) +{ + unsigned int temp=input; + unsigned char bits=0; + + while(temp) { + temp=temp&(temp-1); + bits++; + } + return bits; +} + +int cvsd_encode_sb::cvsd_round (double input) +{ + double temp; + temp=input+0.5; + temp=floor(temp); + + return (int)temp; +} + +unsigned int cvsd_encode_sb::cvsd_pow (short radix, short power) +{ + double d_radix = (double) radix; + int i_power = (int) power; + double output; + + output=pow(d_radix,i_power); + return ( (unsigned int) cvsd_round(output)); +} + + + +int +cvsd_encode_sb::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const short *in = (const short *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + unsigned short i=0; // 2 bytes, 0 .. 65,535 + unsigned char output_bit=0; // 1 byte, 0 .. 255 + unsigned char output_byte=0; // 1 bytes 0.255 + unsigned char bit_count=0; // 1 byte, 0 .. 255 + unsigned int mask=0; // 4 bytes, 0 .. 4,294,967,295 + + // Loop through each input data point + for(i = 0; i < noutput_items*8; i++) { + if((int)in[i] >= d_accum) { // Note: sign((data(n)-accum)) + output_bit=1; + } + else { + output_bit=0; + } + + // Update Accum (i.e. the reference value) + if (output_bit) { + d_accum=d_accum+d_stepsize; + //printf("Addding %d to the accum; the result is: %d.\n", d_stepsize, d_accum); + } + else { + d_accum=d_accum-d_stepsize; + //printf("Subtracting %d to the accum; the result is: %d.\n", d_stepsize, d_accum); + } + + // Multiply by Accum_Decay + d_accum=(cvsd_round(d_accum*d_accum_decay)); + + // Check for overflow + if (d_accum >= ((int)d_pos_accum_max)) { + d_accum = (int)d_pos_accum_max; + } + else if(d_accum <= ((int) d_neg_accum_max)) { + d_accum = (int) d_neg_accum_max; + } + + // Update runner with the last output bit + // Update Step Size + if (d_loop_counter >= d_J) { // Run this only if you have >= J bits in your shift register + mask=(cvsd_pow(2, d_J) - 1); + if ((cvsd_bitwise_sum(d_runner & mask) >= d_J) || (cvsd_bitwise_sum((~d_runner) & mask) >= d_J)) { + // Runs of 1s and 0s + d_stepsize = std::min( (short)(d_stepsize + d_min_step), d_max_step); + } + else { + // No runs of 1s and 0s + d_stepsize = std::max( (short)cvsd_round(d_stepsize*d_step_decay), d_min_step); + } + } + + // Runner is a shift-register; shift left, add on newest output bit + d_runner = (d_runner<<1) | ((unsigned int) output_bit); + + // Update the ouput type; shift left, add on newest output bit + // If you have put in 8 bits, output it as a byte + output_byte = (output_byte<<1) | output_bit; + bit_count++; + + if (d_loop_counter <= d_K) { + d_loop_counter++; + } + + // If you have put 8 bits, output and clear. + if (bit_count==8) { + // Read in short from the file + *(out++) = output_byte; + + // Reset the bit_count + bit_count=0; + output_byte=0; + } + } // While + + return noutput_items; +} diff --git a/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.h b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.h new file mode 100644 index 0000000000..57734ca15a --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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 2, 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. + */ +#ifndef INCLUDED_CVSD_ENCODER_SB_H +#define INCLUDED_CVSD_ENCODER_SB_H + +#include <gr_sync_decimator.h> + +class cvsd_encode_sb; + +typedef boost::shared_ptr<cvsd_encode_sb> cvsd_encode_sb_sptr; + +cvsd_encode_sb_sptr cvsd_make_encode_sb (short min_step=10, + short max_step=1280, + double step_decay=0.9990234375, + double accum_decay= 0.96875, + int K=32, + int J=4, + short pos_accum_max=32767, + short neg_accum_max=-32767); + +class cvsd_encode_sb : public gr_sync_decimator +{ +private: + friend cvsd_encode_sb_sptr cvsd_make_encode_sb (short min_step, + short max_step, + double step_decay, + double accum_decay, + int K, + int J, + short pos_accum_max, + short neg_accum_max); + + cvsd_encode_sb (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max); + + int cvsd_round(double input); + unsigned int cvsd_pow (short radix, short power); + unsigned char cvsd_bitwise_sum (unsigned int input); + + short d_min_step; + short d_max_step; + double d_step_decay; + double d_accum_decay; + + //! \brief Size of shift register; the number of output bits remembered in shift register + int d_K; + + //! \brief Number of bits in the shift register that are equal; size of run of 1s, 0s + int d_J; + + short d_pos_accum_max; + short d_neg_accum_max; + + int d_accum; + int d_loop_counter; + unsigned int d_runner; + short d_stepsize; + + public: + ~cvsd_encode_sb (); // public destructor + + short min_step() { return d_min_step; } + short max_step() { return d_max_step; } + double step_decay() { return d_step_decay; } + double accum_decay() { return d_accum_decay; } + int K() { return d_K; } + int J() { return d_J; } + short pos_accum_max() { return d_pos_accum_max; } + short neg_accum_max() { return d_neg_accum_max; } + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_CVSD_ENCODE_SB_H */ diff --git a/gr-cvsd-vocoder/src/lib/cvsd_vocoder.i b/gr-cvsd-vocoder/src/lib/cvsd_vocoder.i new file mode 100644 index 0000000000..5e618187fc --- /dev/null +++ b/gr-cvsd-vocoder/src/lib/cvsd_vocoder.i @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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 2, 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. + */ + +%feature("autodoc","1"); +%include "exception.i" +%import "gnuradio.i" + +%{ +#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix +#include "cvsd_encode_sb.h" +#include "cvsd_decode_bs.h" +#include <stdexcept> +%} + +GR_SWIG_BLOCK_MAGIC(cvsd,encode_sb); + +cvsd_encode_sb_sptr cvsd_make_encode_sb (short min_step=10, + short max_step=1280, + double step_decay=0.9990234375, + double accum_decay= 0.96875, + int K=32, + int J=4, + short pos_accum_max=32767, + short neg_accum_max=-32767); + +class cvsd_encode_sb : public gr_sync_decimator +{ +private: + cvsd_encode_sb (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max); + + + public: + short min_step() { return d_min_step; } + short max_step() { return d_max_step; } + double step_decay() { return d_step_decay; } + double accum_decay() { return d_accum_decay; } + int K() { return d_K; } + int J() { return d_J; } + short pos_accum_max() { return d_pos_accum_max; } + short neg_accum_max() { return d_neg_accum_max; } +}; + +// ---------------------------------------------------------------- + +GR_SWIG_BLOCK_MAGIC(cvsd,decode_bs); + +cvsd_decode_bs_sptr cvsd_make_decode_bs (short min_step=10, + short max_step=1280, + double step_decay=0.9990234375, + double accum_decay= 0.96875, + int K=32, + int J=4, + short pos_accum_max=32767, + short neg_accum_max=-32767); + +class cvsd_decode_bs : public gr_sync_interpolator +{ +private: + cvsd_decode_bs (short min_step, short max_step, double step_decay, + double accum_decay, int K, int J, + short pos_accum_max, short neg_accum_max); + + public: +}; |