diff options
Diffstat (limited to 'gr-vocoder/lib')
49 files changed, 2290 insertions, 1429 deletions
diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt index 43a4156d06..7949e227b7 100644 --- a/gr-vocoder/lib/CMakeLists.txt +++ b/gr-vocoder/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,26 +29,30 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +if(ENABLE_GR_CTRLPORT) + ADD_DEFINITIONS(-DGR_CTRLPORT) +endif(ENABLE_GR_CTRLPORT) + ######################################################################## # Setup library ######################################################################## list(APPEND gr_vocoder_sources - vocoder_alaw_decode_bs.cc - vocoder_alaw_encode_sb.cc - vocoder_codec2_decode_ps.cc - vocoder_codec2_encode_sp.cc - vocoder_cvsd_decode_bs.cc - vocoder_cvsd_encode_sb.cc - vocoder_g721_decode_bs.cc - vocoder_g721_encode_sb.cc - vocoder_g723_24_decode_bs.cc - vocoder_g723_24_encode_sb.cc - vocoder_g723_40_decode_bs.cc - vocoder_g723_40_encode_sb.cc - vocoder_gsm_fr_decode_ps.cc - vocoder_gsm_fr_encode_sp.cc - vocoder_ulaw_decode_bs.cc - vocoder_ulaw_encode_sb.cc + alaw_decode_bs_impl.cc + alaw_encode_sb_impl.cc + codec2_decode_ps_impl.cc + codec2_encode_sp_impl.cc + cvsd_decode_bs_impl.cc + cvsd_encode_sb_impl.cc + g721_decode_bs_impl.cc + g721_encode_sb_impl.cc + g723_24_decode_bs_impl.cc + g723_24_encode_sb_impl.cc + g723_40_decode_bs_impl.cc + g723_40_encode_sb_impl.cc + gsm_fr_decode_ps_impl.cc + gsm_fr_encode_sp_impl.cc + ulaw_decode_bs_impl.cc + ulaw_encode_sb_impl.cc ) ######################################################################## diff --git a/gr-vocoder/lib/alaw_decode_bs_impl.cc b/gr-vocoder/lib/alaw_decode_bs_impl.cc new file mode 100644 index 0000000000..abea694da9 --- /dev/null +++ b/gr-vocoder/lib/alaw_decode_bs_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "alaw_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + +extern "C" { +#include "g7xx/g72x.h" +} + + alaw_decode_bs::sptr + alaw_decode_bs::make() + { + return gnuradio::get_initial_sptr + (new alaw_decode_bs_impl()); + } + + alaw_decode_bs_impl::alaw_decode_bs_impl() + : gr_sync_block("vocoder_alaw_decode_bs", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(short))) + { + } + + alaw_decode_bs_impl::~alaw_decode_bs_impl() + { + } + + int + alaw_decode_bs_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = alaw2linear(in[i]); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/alaw_decode_bs_impl.h b/gr-vocoder/lib/alaw_decode_bs_impl.h new file mode 100644 index 0000000000..06b23f3cfa --- /dev/null +++ b/gr-vocoder/lib/alaw_decode_bs_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_ALAW_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_ALAW_DECODE_BS_IMPL_H + +#include <vocoder/alaw_decode_bs.h> + +namespace gr { + namespace vocoder { + + class alaw_decode_bs_impl : public alaw_decode_bs + { + public: + alaw_decode_bs_impl(); + ~alaw_decode_bs_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_ALAW_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/alaw_encode_sb_impl.cc b/gr-vocoder/lib/alaw_encode_sb_impl.cc new file mode 100644 index 0000000000..4b316f2e14 --- /dev/null +++ b/gr-vocoder/lib/alaw_encode_sb_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "alaw_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + +extern "C" { +#include "g7xx/g72x.h" +} + + alaw_encode_sb::sptr + alaw_encode_sb::make() + { + return gnuradio::get_initial_sptr + (new alaw_encode_sb_impl()); + } + + alaw_encode_sb_impl::alaw_encode_sb_impl() + : gr_sync_block("avocoder_law_encode_sb", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + } + + alaw_encode_sb_impl::~alaw_encode_sb_impl() + { + } + + int + alaw_encode_sb_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = linear2alaw(in[i]); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/alaw_encode_sb_impl.h b/gr-vocoder/lib/alaw_encode_sb_impl.h new file mode 100644 index 0000000000..72112e35a9 --- /dev/null +++ b/gr-vocoder/lib/alaw_encode_sb_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_ALAW_ENCODER_SB_IMPL_H +#define INCLUDED_VOCODER_ALAW_ENCODER_SB_IMPL_H + +#include <vocoder/alaw_encode_sb.h> + +namespace gr { + namespace vocoder { + + class alaw_encode_sb_impl : public alaw_encode_sb + { + public: + alaw_encode_sb_impl(); + ~alaw_encode_sb_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_ALAW_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/codec2_decode_ps_impl.cc b/gr-vocoder/lib/codec2_decode_ps_impl.cc new file mode 100644 index 0000000000..cd47c9e702 --- /dev/null +++ b/gr-vocoder/lib/codec2_decode_ps_impl.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "codec2_decode_ps_impl.h" + +extern "C" { +#include "codec2/codec2.h" +} + +#include <gr_io_signature.h> +#include <stdexcept> +#include <assert.h> + +namespace gr { + namespace vocoder { + + codec2_decode_ps::sptr + codec2_decode_ps::make() + { + return gnuradio::get_initial_sptr + (new codec2_decode_ps_impl()); + } + + + codec2_decode_ps_impl::codec2_decode_ps_impl () + : gr_sync_interpolator("vocoder_codec2_decode_ps", + gr_make_io_signature(1, 1, CODEC2_BITS_PER_FRAME * sizeof(char)), + gr_make_io_signature (1, 1, sizeof(short)), + CODEC2_SAMPLES_PER_FRAME) + { + if((d_codec2 = codec2_create()) == 0) + throw std::runtime_error("codec2_decode_ps_impl: codec2_create failed"); + } + + codec2_decode_ps_impl::~codec2_decode_ps_impl() + { + codec2_destroy(d_codec2); + } + + int + codec2_decode_ps_impl::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]; + + assert((noutput_items % CODEC2_SAMPLES_PER_FRAME) == 0); + + for(int i = 0; i < noutput_items; i += CODEC2_SAMPLES_PER_FRAME) { + codec2_decode (d_codec2, out, const_cast<unsigned char*>(in)); + in += CODEC2_BITS_PER_FRAME * sizeof (char); + out += CODEC2_SAMPLES_PER_FRAME; + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/codec2_decode_ps_impl.h b/gr-vocoder/lib/codec2_decode_ps_impl.h new file mode 100644 index 0000000000..26e39da1de --- /dev/null +++ b/gr-vocoder/lib/codec2_decode_ps_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_CODEC2_DECODE_PS_IMPL_H +#define INCLUDED_VOCODER_CODEC2_DECODE_PS_IMPL_H + +#include <vocoder/codec2_decode_ps.h> + +namespace gr { + namespace vocoder { + + class codec2_decode_ps_impl : public codec2_decode_ps + { + private: + void *d_codec2; + + public: + codec2_decode_ps_impl(); + ~codec2_decode_ps_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_DECODE_PS_IMPL_H */ diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.cc b/gr-vocoder/lib/codec2_encode_sp_impl.cc new file mode 100644 index 0000000000..0217fbd424 --- /dev/null +++ b/gr-vocoder/lib/codec2_encode_sp_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "codec2_encode_sp_impl.h" + +extern "C" { +#include "codec2/codec2.h" +} + +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace vocoder { + + codec2_encode_sp::sptr + codec2_encode_sp::make() + { + return gnuradio::get_initial_sptr + (new codec2_encode_sp_impl()); + } + + codec2_encode_sp_impl::codec2_encode_sp_impl() + : gr_sync_decimator("vocoder_codec2_encode_sp", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, CODEC2_BITS_PER_FRAME * sizeof(char)), + CODEC2_SAMPLES_PER_FRAME) + { + if((d_codec2 = codec2_create()) == 0) + throw std::runtime_error("codec2_encode_sp_impl: codec2_create failed"); + } + + codec2_encode_sp_impl::~codec2_encode_sp_impl() + { + codec2_destroy(d_codec2); + } + + int + codec2_encode_sp_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + codec2_encode(d_codec2, out, const_cast<short*>(in)); + in += CODEC2_SAMPLES_PER_FRAME; + out += CODEC2_BITS_PER_FRAME * sizeof(char); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/codec2_encode_sp_impl.h b/gr-vocoder/lib/codec2_encode_sp_impl.h new file mode 100644 index 0000000000..1a5c34c9d8 --- /dev/null +++ b/gr-vocoder/lib/codec2_encode_sp_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H +#define INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H + +#include <vocoder/codec2_encode_sp.h> + +namespace gr { + namespace vocoder { + + class codec2_encode_sp_impl : public codec2_encode_sp + { + private: + void *d_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); + }; + + } /* namespace vocoder */ +} /* namespace gr */ + +#endif /* INCLUDED_VOCODER_CODEC2_ENCODE_SP_IMPL_H */ diff --git a/gr-vocoder/lib/cvsd_decode_bs_impl.cc b/gr-vocoder/lib/cvsd_decode_bs_impl.cc new file mode 100644 index 0000000000..e7f284adda --- /dev/null +++ b/gr-vocoder/lib/cvsd_decode_bs_impl.cc @@ -0,0 +1,192 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "cvsd_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + cvsd_decode_bs::sptr + cvsd_decode_bs::make(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 gnuradio::get_initial_sptr + (new cvsd_decode_bs_impl(min_step, max_step, + step_decay, accum_decay, K, J, + pos_accum_max, neg_accum_max)); + } + + cvsd_decode_bs_impl::cvsd_decode_bs_impl(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("vocoder_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) + { + if(d_K > 32) + throw std::runtime_error("cvsd_decode_bs_impl: K must be <= 32\n"); + + if(d_J > d_K) + throw std::runtime_error("cvsd_decode_bs_impl: J must be <= K\n"); + } + + cvsd_decode_bs_impl::~cvsd_decode_bs_impl() + { + // nothing else required in this example + } + + unsigned char + cvsd_decode_bs_impl::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_impl::cvsd_round(double input) + { + double temp; + temp=input+0.5; + temp=floor(temp); + + return (int)temp; + } + + unsigned int + cvsd_decode_bs_impl::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_impl::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; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/cvsd_decode_bs_impl.h b/gr-vocoder/lib/cvsd_decode_bs_impl.h new file mode 100644 index 0000000000..007c00c2bd --- /dev/null +++ b/gr-vocoder/lib/cvsd_decode_bs_impl.h @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +#ifndef INCLUDED_VOCODER_CVSD_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_CVSD_DECODE_BS_IMPL_H + +#include <vocoder/cvsd_decode_bs.h> + +namespace gr { + namespace vocoder { + + class cvsd_decode_bs_impl : public cvsd_decode_bs + { + private: + //! Member functions required by the encoder/decoder + //! \brief Rounding function specific to CVSD + //! \return the input value rounded to the nearest integer + int cvsd_round(double input); + + //! \brief A power function specific to CVSD data formats + //! \return (radix)^power, where radix and power are short integers + unsigned int cvsd_pow(short radix, short power); + + //! \brief Sums number of 1's in the input + //! \return the number of 1s in the four bytes of an input unsigned integer + unsigned char cvsd_bitwise_sum(unsigned int input); + + short d_min_step; + short d_max_step; + double d_step_decay; + double d_accum_decay; + + int d_K; //!< \brief Size of shift register; the number of output bits remembered in shift register + int d_J; //!< \brief Number of bits in the shift register that are equal; size of run of 1s, 0s + + short d_pos_accum_max; + short d_neg_accum_max; + + int d_accum; //!< \brief Current value of internal reference + int d_loop_counter; //!< \brief Current value of the loop counter + unsigned int d_runner; //!< \brief Current value of the shift register + unsigned int d_runner_mask; //!< \brief Value of the mask to access the last J bits of the shift register + short d_stepsize; //!< \brief Current value of the step sizer + + public: + cvsd_decode_bs_impl(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); + ~cvsd_decode_bs_impl(); + + 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); + }; + + } /* namespace vocoder */ +} /* namespace gr */ + +#endif /* INCLUDED_VOCODER_CVSD_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/cvsd_encode_sb_impl.cc b/gr-vocoder/lib/cvsd_encode_sb_impl.cc new file mode 100644 index 0000000000..74ecdb25e1 --- /dev/null +++ b/gr-vocoder/lib/cvsd_encode_sb_impl.cc @@ -0,0 +1,192 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "cvsd_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + cvsd_encode_sb::sptr + cvsd_encode_sb::make(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 gnuradio::get_initial_sptr + (new cvsd_encode_sb_impl(min_step, max_step, + step_decay, accum_decay, K, J, + pos_accum_max, neg_accum_max)); + } + + cvsd_encode_sb_impl::cvsd_encode_sb_impl(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("vocoder_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) + { + if(d_K > 32) + throw std::runtime_error("cvsd_decode_bs_impl: K must be <= 32\n"); + + if(d_J > d_K) + throw std::runtime_error("cvsd_decode_bs_impl: J must be <= K\n"); + } + + cvsd_encode_sb_impl::~cvsd_encode_sb_impl() + { + // nothing else required in this example + } + + unsigned char + cvsd_encode_sb_impl::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_impl::cvsd_round(double input) + { + double temp; + temp=input+0.5; + temp=floor(temp); + + return (int)temp; + } + + unsigned int + cvsd_encode_sb_impl::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_impl::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; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/cvsd_encode_sb_impl.h b/gr-vocoder/lib/cvsd_encode_sb_impl.h new file mode 100644 index 0000000000..1189920fa0 --- /dev/null +++ b/gr-vocoder/lib/cvsd_encode_sb_impl.h @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +#ifndef INCLUDED_VOCODER_CVSD_ENCODER_SB_IMPL_H +#define INCLUDED_VOCODER_CVSD_ENCODER_SB_IMPL_H + +#include <vocoder/cvsd_encode_sb.h> + +namespace gr { + namespace vocoder { + + class cvsd_encode_sb_impl : public cvsd_encode_sb + { + private: + //! Member functions required by the encoder/decoder + //! \brief Rounding function specific to CVSD + //! \return the input value rounded to the nearest integer + int cvsd_round(double input); + + //! \brief A power function specific to CVSD data formats + //! \return (radix)^power, where radix and power are short integers + unsigned int cvsd_pow(short radix, short power); + + //! \brief Sums number of 1's in the input + //! \return the number of 1s in the four bytes of an input unsigned integer + unsigned char cvsd_bitwise_sum(unsigned int input); + + // Members variables related to the CVSD encoder use to update interal reference value + short d_min_step; + short d_max_step; + double d_step_decay; + double d_accum_decay; + + int d_K; //!< \brief Size of shift register; the number of output bits remembered in shift register + int d_J; //!< \brief Number of bits in the shift register that are equal; size of run of 1s, 0s + + short d_pos_accum_max; + short d_neg_accum_max; + + int d_accum; //!< \brief Current value of internal reference + int d_loop_counter; //!< \brief Current value of the loop counter + unsigned int d_runner; //!< \brief Current value of the shift register + short d_stepsize; //!< \brief Current value of the step sizer + + public: + cvsd_encode_sb_impl(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); + ~cvsd_encode_sb_impl(); + + 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); + }; + + } /* namespace vocoder */ +} /* namespace gr */ + +#endif /* INCLUDED_VOCODER_CVSD_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/g721_decode_bs_impl.cc b/gr-vocoder/lib/g721_decode_bs_impl.cc new file mode 100644 index 0000000000..143bbc514d --- /dev/null +++ b/gr-vocoder/lib/g721_decode_bs_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g721_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g721_decode_bs::sptr + g721_decode_bs::make() + { + return gnuradio::get_initial_sptr + (new g721_decode_bs_impl()); + } + + g721_decode_bs_impl::g721_decode_bs_impl() + : gr_sync_block("vocoder_g721_decode_bs", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(short))) + { + g72x_init_state(&d_state); + } + + g721_decode_bs_impl::~g721_decode_bs_impl() + { + } + + int + g721_decode_bs_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g721_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g721_decode_bs_impl.h b/gr-vocoder/lib/g721_decode_bs_impl.h new file mode 100644 index 0000000000..b861591e49 --- /dev/null +++ b/gr-vocoder/lib/g721_decode_bs_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G721_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_G721_DECODE_BS_IMPL_H + +#include <vocoder/g721_decode_bs.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g721_decode_bs_impl : public g721_decode_bs + { + private: + g72x_state d_state; + + public: + g721_decode_bs_impl(); + ~g721_decode_bs_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_G721_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/g721_encode_sb_impl.cc b/gr-vocoder/lib/g721_encode_sb_impl.cc new file mode 100644 index 0000000000..a961b0efeb --- /dev/null +++ b/gr-vocoder/lib/g721_encode_sb_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g721_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g721_encode_sb::sptr + g721_encode_sb::make() + { + return gnuradio::get_initial_sptr + (new g721_encode_sb_impl()); + } + + g721_encode_sb_impl::g721_encode_sb_impl() + : gr_sync_block("vocoder_g721_encode_sb", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + g72x_init_state(&d_state); + } + + g721_encode_sb_impl::~g721_encode_sb_impl() + { + } + + int + g721_encode_sb_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g721_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g721_encode_sb_impl.h b/gr-vocoder/lib/g721_encode_sb_impl.h new file mode 100644 index 0000000000..f22949aa45 --- /dev/null +++ b/gr-vocoder/lib/g721_encode_sb_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G721_ENCODE_SB_IMPL_H +#define INCLUDED_VOCODER_G721_ENCODE_SB_IMPL_H + +#include <vocoder/g721_encode_sb.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g721_encode_sb_impl : public g721_encode_sb + { + private: + g72x_state d_state; + + public: + g721_encode_sb_impl(); + ~g721_encode_sb_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_G721_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/g723_24_decode_bs_impl.cc b/gr-vocoder/lib/g723_24_decode_bs_impl.cc new file mode 100644 index 0000000000..f7a8b59a08 --- /dev/null +++ b/gr-vocoder/lib/g723_24_decode_bs_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g723_24_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g723_24_decode_bs::sptr + g723_24_decode_bs::make() + { + return gnuradio::get_initial_sptr + (new g723_24_decode_bs_impl()); + } + + g723_24_decode_bs_impl::g723_24_decode_bs_impl() + : gr_sync_block("vocoder_g723_24_decode_bs", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(short))) + { + g72x_init_state(&d_state); + } + + g723_24_decode_bs_impl::~g723_24_decode_bs_impl() + { + } + + int + g723_24_decode_bs_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g723_24_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g723_24_decode_bs_impl.h b/gr-vocoder/lib/g723_24_decode_bs_impl.h new file mode 100644 index 0000000000..3ecea1b1ef --- /dev/null +++ b/gr-vocoder/lib/g723_24_decode_bs_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G723_24_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_G723_24_DECODE_BS_IMPL_H + +#include <vocoder/g723_24_decode_bs.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g723_24_decode_bs_impl : public g723_24_decode_bs + { + private: + g72x_state d_state; + + public: + g723_24_decode_bs_impl(); + ~g723_24_decode_bs_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_G723_24_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/g723_24_encode_sb_impl.cc b/gr-vocoder/lib/g723_24_encode_sb_impl.cc new file mode 100644 index 0000000000..8b168197b5 --- /dev/null +++ b/gr-vocoder/lib/g723_24_encode_sb_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g723_24_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g723_24_encode_sb::sptr + g723_24_encode_sb::make() + { + return gnuradio::get_initial_sptr + (new g723_24_encode_sb_impl()); + } + + g723_24_encode_sb_impl::g723_24_encode_sb_impl() + : gr_sync_block("vocoder_g723_24_encode_sb", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + g72x_init_state(&d_state); + } + + g723_24_encode_sb_impl::~g723_24_encode_sb_impl() + { + } + + int + g723_24_encode_sb_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g723_24_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g723_24_encode_sb_impl.h b/gr-vocoder/lib/g723_24_encode_sb_impl.h new file mode 100644 index 0000000000..d7a44bc57b --- /dev/null +++ b/gr-vocoder/lib/g723_24_encode_sb_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G723_24_ENCODE_SB_IMPL_H +#define INCLUDED_VOCODER_G723_24_ENCODE_SB_IMPL_H + +#include <vocoder/g723_24_encode_sb.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g723_24_encode_sb_impl : public g723_24_encode_sb + { + private: + g72x_state d_state; + + public: + g723_24_encode_sb_impl(); + ~g723_24_encode_sb_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_G723_24_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/g723_40_decode_bs_impl.cc b/gr-vocoder/lib/g723_40_decode_bs_impl.cc new file mode 100644 index 0000000000..0790c9481c --- /dev/null +++ b/gr-vocoder/lib/g723_40_decode_bs_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g723_40_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g723_40_decode_bs::sptr + g723_40_decode_bs::make() + { + return gnuradio::get_initial_sptr + (new g723_40_decode_bs_impl()); + } + + g723_40_decode_bs_impl::g723_40_decode_bs_impl() + : gr_sync_block("vocoder_g723_40_decode_bs", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(short))) + { + g72x_init_state(&d_state); + } + + g723_40_decode_bs_impl::~g723_40_decode_bs_impl() + { + } + + int + g723_40_decode_bs_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g723_40_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g723_40_decode_bs_impl.h b/gr-vocoder/lib/g723_40_decode_bs_impl.h new file mode 100644 index 0000000000..3d5b4d6b7f --- /dev/null +++ b/gr-vocoder/lib/g723_40_decode_bs_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G723_40_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_G723_40_DECODE_BS_IMPL_H + +#include <vocoder/g723_40_decode_bs.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g723_40_decode_bs_impl : public g723_40_decode_bs + { + private: + g72x_state d_state; + + public: + g723_40_decode_bs_impl(); + ~g723_40_decode_bs_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_G723_40_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/g723_40_encode_sb_impl.cc b/gr-vocoder/lib/g723_40_encode_sb_impl.cc new file mode 100644 index 0000000000..54dd052637 --- /dev/null +++ b/gr-vocoder/lib/g723_40_encode_sb_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "g723_40_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + + g723_40_encode_sb::sptr + g723_40_encode_sb::make() + { + return gnuradio::get_initial_sptr + (new g723_40_encode_sb_impl()); + } + + g723_40_encode_sb_impl::g723_40_encode_sb_impl() + : gr_sync_block("vocoder_g723_40_encode_sb", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + g72x_init_state(&d_state); + } + + g723_40_encode_sb_impl::~g723_40_encode_sb_impl() + { + } + + int + g723_40_encode_sb_impl::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]; + + for(int i = 0; i < noutput_items; i++) + out[i] = g723_40_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/g723_40_encode_sb_impl.h b/gr-vocoder/lib/g723_40_encode_sb_impl.h new file mode 100644 index 0000000000..a4093e1fc7 --- /dev/null +++ b/gr-vocoder/lib/g723_40_encode_sb_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_G723_40_ENCODE_SB_IMPL_H +#define INCLUDED_VOCODER_G723_40_ENCODE_SB_IMPL_H + +#include <vocoder/g723_40_encode_sb.h> + +extern "C" { +#include "g7xx/g72x.h" +} + +namespace gr { + namespace vocoder { + + class g723_40_encode_sb_impl : public g723_40_encode_sb + { + private: + g72x_state d_state; + + public: + g723_40_encode_sb_impl(); + ~g723_40_encode_sb_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_G723_40_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/gsm_fr_decode_ps_impl.cc b/gr-vocoder/lib/gsm_fr_decode_ps_impl.cc new file mode 100644 index 0000000000..2b3d11135c --- /dev/null +++ b/gr-vocoder/lib/gsm_fr_decode_ps_impl.cc @@ -0,0 +1,77 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gsm_fr_decode_ps_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <assert.h> + +namespace gr { + namespace vocoder { + + gsm_fr_decode_ps::sptr + gsm_fr_decode_ps::make() + { + return gnuradio::get_initial_sptr + (new gsm_fr_decode_ps_impl()); + } + + gsm_fr_decode_ps_impl::gsm_fr_decode_ps_impl() + : gr_sync_interpolator("vocoder_gsm_fr_decode_ps", + gr_make_io_signature(1, 1, sizeof(gsm_frame)), + gr_make_io_signature(1, 1, sizeof(short)), + GSM_SAMPLES_PER_FRAME) + { + if((d_gsm = gsm_create()) == 0) + throw std::runtime_error("gsm_fr_decode_ps_impl: gsm_create failed"); + } + + gsm_fr_decode_ps_impl::~gsm_fr_decode_ps_impl() + { + gsm_destroy(d_gsm); + } + + int + gsm_fr_decode_ps_impl::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]; + + assert((noutput_items % GSM_SAMPLES_PER_FRAME) == 0); + + for(int i = 0; i < noutput_items; i += GSM_SAMPLES_PER_FRAME) { + gsm_decode(d_gsm, const_cast<unsigned char*>(in), out); + in += sizeof(gsm_frame); + out += GSM_SAMPLES_PER_FRAME; + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/gsm_fr_decode_ps_impl.h b/gr-vocoder/lib/gsm_fr_decode_ps_impl.h new file mode 100644 index 0000000000..3c1bb351d6 --- /dev/null +++ b/gr-vocoder/lib/gsm_fr_decode_ps_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_VOCODER_GSM_FR_DECODE_PS_IMPL_H +#define INCLUDED_VOCODER_GSM_FR_DECODE_PS_IMPL_H + +#include <vocoder/gsm_fr_decode_ps.h> + +extern "C"{ +#include "gsm/gsm.h" +} + +namespace gr { + namespace vocoder { + + class gsm_fr_decode_ps_impl : public gsm_fr_decode_ps + { + private: + struct gsm_state *d_gsm; + + public: + gsm_fr_decode_ps_impl(); + ~gsm_fr_decode_ps_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_GSM_FR_DECODE_PS_IMPL_H */ diff --git a/gr-vocoder/lib/gsm_fr_encode_sp_impl.cc b/gr-vocoder/lib/gsm_fr_encode_sp_impl.cc new file mode 100644 index 0000000000..c7b10089fb --- /dev/null +++ b/gr-vocoder/lib/gsm_fr_encode_sp_impl.cc @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gsm_fr_encode_sp_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace vocoder { + + gsm_fr_encode_sp::sptr + gsm_fr_encode_sp::make() + { + return gnuradio::get_initial_sptr + (new gsm_fr_encode_sp_impl()); + } + + gsm_fr_encode_sp_impl::gsm_fr_encode_sp_impl() + : gr_sync_decimator("vocoder_gsm_fr_encode_sp", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(gsm_frame)), + GSM_SAMPLES_PER_FRAME) + { + if((d_gsm = gsm_create ()) == 0) + throw std::runtime_error("gsm_fr_encode_sp_impl: gsm_create failed"); + } + + gsm_fr_encode_sp_impl::~gsm_fr_encode_sp_impl() + { + gsm_destroy (d_gsm); + } + + int + gsm_fr_encode_sp_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + gsm_encode(d_gsm, const_cast<short*>(in), out); + in += GSM_SAMPLES_PER_FRAME; + out += sizeof(gsm_frame); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/gsm_fr_encode_sp_impl.h b/gr-vocoder/lib/gsm_fr_encode_sp_impl.h new file mode 100644 index 0000000000..a5501deaae --- /dev/null +++ b/gr-vocoder/lib/gsm_fr_encode_sp_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_VOCODER_GSM_FR_ENCODE_SP_IMPL_H +#define INCLUDED_VOCODER_GSM_FR_ENCODE_SP_IMPL_H + +#include <vocoder/gsm_fr_encode_sp.h> + +extern "C"{ +#include "gsm/gsm.h" +} + +namespace gr { + namespace vocoder { + + class gsm_fr_encode_sp_impl : public gsm_fr_encode_sp + { + private: + struct gsm_state *d_gsm; + + public: + gsm_fr_encode_sp_impl(); + ~gsm_fr_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_GSM_FR_ENCODE_SP_IMPL_H */ diff --git a/gr-vocoder/lib/ulaw_decode_bs_impl.cc b/gr-vocoder/lib/ulaw_decode_bs_impl.cc new file mode 100644 index 0000000000..d0c99b70a0 --- /dev/null +++ b/gr-vocoder/lib/ulaw_decode_bs_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ulaw_decode_bs_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + +extern "C" { +#include "g7xx/g72x.h" +} + + ulaw_decode_bs::sptr + ulaw_decode_bs::make() + { + return gnuradio::get_initial_sptr + (new ulaw_decode_bs_impl()); + } + + ulaw_decode_bs_impl::ulaw_decode_bs_impl() + : gr_sync_block("vocoder_ulaw_decode_bs", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(short))) + { + } + + ulaw_decode_bs_impl::~ulaw_decode_bs_impl() + { + } + + int + ulaw_decode_bs_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = ulaw2linear(in[i]); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/ulaw_decode_bs_impl.h b/gr-vocoder/lib/ulaw_decode_bs_impl.h new file mode 100644 index 0000000000..db7a0dcab9 --- /dev/null +++ b/gr-vocoder/lib/ulaw_decode_bs_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_ULAW_DECODE_BS_IMPL_H +#define INCLUDED_VOCODER_ULAW_DECODE_BS_IMPL_H + +#include <vocoder/ulaw_decode_bs.h> + +namespace gr { + namespace vocoder { + + class ulaw_decode_bs_impl : public ulaw_decode_bs + { + public: + ulaw_decode_bs_impl(); + ~ulaw_decode_bs_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_ULAW_DECODE_BS_IMPL_H */ diff --git a/gr-vocoder/lib/ulaw_encode_sb_impl.cc b/gr-vocoder/lib/ulaw_encode_sb_impl.cc new file mode 100644 index 0000000000..a49df12b59 --- /dev/null +++ b/gr-vocoder/lib/ulaw_encode_sb_impl.cc @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ulaw_encode_sb_impl.h" +#include <gr_io_signature.h> +#include <limits.h> + +namespace gr { + namespace vocoder { + +extern "C" { +#include "g7xx/g72x.h" +} + + ulaw_encode_sb::sptr + ulaw_encode_sb::make() + { + return gnuradio::get_initial_sptr + (new ulaw_encode_sb_impl()); + } + + ulaw_encode_sb_impl::ulaw_encode_sb_impl() + : gr_sync_block("vocoder_ulaw_encode_sb", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(1, 1, sizeof(unsigned char))) + { + } + + ulaw_encode_sb_impl::~ulaw_encode_sb_impl() + { + } + + int + ulaw_encode_sb_impl::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]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = linear2ulaw(in[i]); + } + + return noutput_items; + } + + } /* namespace vocoder */ +} /* namespace gr */ diff --git a/gr-vocoder/lib/ulaw_encode_sb_impl.h b/gr-vocoder/lib/ulaw_encode_sb_impl.h new file mode 100644 index 0000000000..2ce207fbf8 --- /dev/null +++ b/gr-vocoder/lib/ulaw_encode_sb_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_VOCODER_ULAW_ENCODER_SB_IMPL_H +#define INCLUDED_VOCODER_ULAW_ENCODER_SB_IMPL_H + +#include <vocoder/ulaw_encode_sb.h> + +namespace gr { + namespace vocoder { + + class ulaw_encode_sb_impl : public ulaw_encode_sb + { + public: + ulaw_encode_sb_impl(); + ~ulaw_encode_sb_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_ULAW_ENCODE_SB_IMPL_H */ diff --git a/gr-vocoder/lib/vocoder_alaw_decode_bs.cc b/gr-vocoder/lib/vocoder_alaw_decode_bs.cc deleted file mode 100644 index 33c119e05f..0000000000 --- a/gr-vocoder/lib/vocoder_alaw_decode_bs.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_alaw_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -vocoder_alaw_decode_bs_sptr vocoder_make_alaw_decode_bs() -{ - return gnuradio::get_initial_sptr(new vocoder_alaw_decode_bs()); -} - -vocoder_alaw_decode_bs::vocoder_alaw_decode_bs() - : gr_sync_block("vocoder_alaw_decode_bs", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (short))) -{ -} - -vocoder_alaw_decode_bs::~vocoder_alaw_decode_bs() -{ -} - - - -int -vocoder_alaw_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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = alaw2linear(in[i]); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_alaw_encode_sb.cc b/gr-vocoder/lib/vocoder_alaw_encode_sb.cc deleted file mode 100644 index ebb953c341..0000000000 --- a/gr-vocoder/lib/vocoder_alaw_encode_sb.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_alaw_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -vocoder_alaw_encode_sb_sptr vocoder_make_alaw_encode_sb() -{ - return gnuradio::get_initial_sptr(new vocoder_alaw_encode_sb()); -} - -vocoder_alaw_encode_sb::vocoder_alaw_encode_sb() - : gr_sync_block("vocoder_alaw_encode_sb", - gr_make_io_signature (1, 1, sizeof(short)), - gr_make_io_signature (1, 1, sizeof(unsigned char))) -{ -} - -vocoder_alaw_encode_sb::~vocoder_alaw_encode_sb() -{ -} - -int -vocoder_alaw_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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = linear2alaw(in[i]); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_codec2_decode_ps.cc b/gr-vocoder/lib/vocoder_codec2_decode_ps.cc deleted file mode 100644 index 8e95c75dd1..0000000000 --- a/gr-vocoder/lib/vocoder_codec2_decode_ps.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vocoder_codec2_decode_ps.h" - -extern "C" { -#include "codec2/codec2.h" -} - -#include <gr_io_signature.h> -#include <stdexcept> -#include <assert.h> - -vocoder_codec2_decode_ps_sptr -vocoder_make_codec2_decode_ps () -{ - return gnuradio::get_initial_sptr(new vocoder_codec2_decode_ps ()); -} - -vocoder_codec2_decode_ps::vocoder_codec2_decode_ps () - : gr_sync_interpolator ("vocoder_codec2_decode_ps", - gr_make_io_signature (1, 1, CODEC2_BITS_PER_FRAME * sizeof (char)), - gr_make_io_signature (1, 1, sizeof (short)), - CODEC2_SAMPLES_PER_FRAME) -{ - if ((d_codec2 = codec2_create ()) == 0) - throw std::runtime_error ("vocoder_codec2_decode_ps: codec2_create failed"); -} - -vocoder_codec2_decode_ps::~vocoder_codec2_decode_ps () -{ - codec2_destroy(d_codec2); -} - -int -vocoder_codec2_decode_ps::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]; - - assert ((noutput_items % CODEC2_SAMPLES_PER_FRAME) == 0); - - for (int i = 0; i < noutput_items; i += CODEC2_SAMPLES_PER_FRAME){ - codec2_decode (d_codec2, out, const_cast<unsigned char*>(in)); - in += CODEC2_BITS_PER_FRAME * sizeof (char); - out += CODEC2_SAMPLES_PER_FRAME; - } - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_codec2_encode_sp.cc b/gr-vocoder/lib/vocoder_codec2_encode_sp.cc deleted file mode 100644 index da1c59c436..0000000000 --- a/gr-vocoder/lib/vocoder_codec2_encode_sp.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vocoder_codec2_encode_sp.h" - -extern "C" { -#include "codec2/codec2.h" -} - -#include <gr_io_signature.h> -#include <stdexcept> - -vocoder_codec2_encode_sp_sptr -vocoder_make_codec2_encode_sp () -{ - return gnuradio::get_initial_sptr(new vocoder_codec2_encode_sp ()); -} - -vocoder_codec2_encode_sp::vocoder_codec2_encode_sp () - : gr_sync_decimator ("vocoder_codec2_encode_sp", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, CODEC2_BITS_PER_FRAME * sizeof (char)), - CODEC2_SAMPLES_PER_FRAME) -{ - if ((d_codec2 = codec2_create ()) == 0) - throw std::runtime_error ("vocoder_codec2_encode_sp: codec2_create failed"); -} - -vocoder_codec2_encode_sp::~vocoder_codec2_encode_sp () -{ - codec2_destroy(d_codec2); -} - -int -vocoder_codec2_encode_sp::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]; - - for (int i = 0; i < noutput_items; i++){ - codec2_encode (d_codec2, out, const_cast<short*>(in)); - in += CODEC2_SAMPLES_PER_FRAME; - out += CODEC2_BITS_PER_FRAME * sizeof (char); - } - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_cvsd_decode_bs.cc b/gr-vocoder/lib/vocoder_cvsd_decode_bs.cc deleted file mode 100644 index 8202ec36ca..0000000000 --- a/gr-vocoder/lib/vocoder_cvsd_decode_bs.cc +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -/* - * 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 <vocoder_cvsd_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -/* - * Create a new instance of vocoder_cvsd_decode_bs and return - * a boost shared_ptr. This is effectively the public constructor. - */ -vocoder_cvsd_decode_bs_sptr -vocoder_make_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) -{ - return gnuradio::get_initial_sptr(new vocoder_cvsd_decode_bs (min_step, max_step, - step_decay, accum_decay, K, J, - pos_accum_max, neg_accum_max)); -} - -vocoder_cvsd_decode_bs::vocoder_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 ("vocoder_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_K <= 32); - assert(d_J <= d_K); -} - - -vocoder_cvsd_decode_bs::~vocoder_cvsd_decode_bs () -{ - // nothing else required in this example -} - -unsigned char vocoder_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 vocoder_cvsd_decode_bs::cvsd_round (double input) -{ - double temp; - temp=input+0.5; - temp=floor(temp); - - return (int)temp; -} - -unsigned int vocoder_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 -vocoder_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-vocoder/lib/vocoder_cvsd_encode_sb.cc b/gr-vocoder/lib/vocoder_cvsd_encode_sb.cc deleted file mode 100644 index e15882c227..0000000000 --- a/gr-vocoder/lib/vocoder_cvsd_encode_sb.cc +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -/* - * 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 <vocoder_cvsd_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -/* - * Create a new instance of vocoder_cvsd_encode_sb and return - * a boost shared_ptr. This is effectively the public constructor. - */ -vocoder_cvsd_encode_sb_sptr -vocoder_make_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) -{ - return gnuradio::get_initial_sptr(new vocoder_cvsd_encode_sb (min_step, max_step, - step_decay, accum_decay, K, J, - pos_accum_max, neg_accum_max)); -} - -vocoder_cvsd_encode_sb::vocoder_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 ("vocoder_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_K <= 32); - assert(d_J <= d_K); -} - - -vocoder_cvsd_encode_sb::~vocoder_cvsd_encode_sb () -{ - // nothing else required in this example -} - -unsigned char vocoder_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 vocoder_cvsd_encode_sb::cvsd_round (double input) -{ - double temp; - temp=input+0.5; - temp=floor(temp); - - return (int)temp; -} - -unsigned int vocoder_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 -vocoder_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-vocoder/lib/vocoder_g721_decode_bs.cc b/gr-vocoder/lib/vocoder_g721_decode_bs.cc deleted file mode 100644 index d5b737d1ce..0000000000 --- a/gr-vocoder/lib/vocoder_g721_decode_bs.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g721_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g721_decode_bs_impl : public vocoder_g721_decode_bs -{ -public: - - vocoder_g721_decode_bs_impl(); - ~vocoder_g721_decode_bs_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g721_decode_bs_sptr vocoder_make_g721_decode_bs() -{ - return gnuradio::get_initial_sptr(new vocoder_g721_decode_bs_impl()); -} - -vocoder_g721_decode_bs_impl::vocoder_g721_decode_bs_impl() - : gr_sync_block("vocoder_g721_decode_bs", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (short))) -{ - g72x_init_state(&d_state); -} - -vocoder_g721_decode_bs_impl::~vocoder_g721_decode_bs_impl() -{ -} - -int -vocoder_g721_decode_bs_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g721_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_g721_encode_sb.cc b/gr-vocoder/lib/vocoder_g721_encode_sb.cc deleted file mode 100644 index 1e33613a58..0000000000 --- a/gr-vocoder/lib/vocoder_g721_encode_sb.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g721_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g721_encode_sb_impl : public vocoder_g721_encode_sb -{ -public: - - vocoder_g721_encode_sb_impl(); - ~vocoder_g721_encode_sb_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g721_encode_sb_sptr vocoder_make_g721_encode_sb() -{ - return gnuradio::get_initial_sptr(new vocoder_g721_encode_sb_impl()); -} - -vocoder_g721_encode_sb_impl::vocoder_g721_encode_sb_impl() - : gr_sync_block("vocoder_g721_encode_sb", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - g72x_init_state(&d_state); -} - -vocoder_g721_encode_sb_impl::~vocoder_g721_encode_sb_impl() -{ -} - -int -vocoder_g721_encode_sb_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g721_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_g723_24_decode_bs.cc b/gr-vocoder/lib/vocoder_g723_24_decode_bs.cc deleted file mode 100644 index 0bedfe4ca1..0000000000 --- a/gr-vocoder/lib/vocoder_g723_24_decode_bs.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g723_24_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g723_24_decode_bs_impl : public vocoder_g723_24_decode_bs -{ -public: - - vocoder_g723_24_decode_bs_impl(); - ~vocoder_g723_24_decode_bs_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g723_24_decode_bs_sptr vocoder_make_g723_24_decode_bs() -{ - return gnuradio::get_initial_sptr(new vocoder_g723_24_decode_bs_impl()); -} - -vocoder_g723_24_decode_bs_impl::vocoder_g723_24_decode_bs_impl() - : gr_sync_block("vocoder_g723_24_decode_bs", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (short))) -{ - g72x_init_state(&d_state); -} - -vocoder_g723_24_decode_bs_impl::~vocoder_g723_24_decode_bs_impl() -{ -} - -int -vocoder_g723_24_decode_bs_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g723_24_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_g723_24_encode_sb.cc b/gr-vocoder/lib/vocoder_g723_24_encode_sb.cc deleted file mode 100644 index 1b61de79ff..0000000000 --- a/gr-vocoder/lib/vocoder_g723_24_encode_sb.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g723_24_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g723_24_encode_sb_impl : public vocoder_g723_24_encode_sb -{ -public: - - vocoder_g723_24_encode_sb_impl(); - ~vocoder_g723_24_encode_sb_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g723_24_encode_sb_sptr vocoder_make_g723_24_encode_sb() -{ - return gnuradio::get_initial_sptr(new vocoder_g723_24_encode_sb_impl()); -} - -vocoder_g723_24_encode_sb_impl::vocoder_g723_24_encode_sb_impl() - : gr_sync_block("vocoder_g723_24_encode_sb", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - g72x_init_state(&d_state); -} - -vocoder_g723_24_encode_sb_impl::~vocoder_g723_24_encode_sb_impl() -{ -} - -int -vocoder_g723_24_encode_sb_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g723_24_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_g723_40_decode_bs.cc b/gr-vocoder/lib/vocoder_g723_40_decode_bs.cc deleted file mode 100644 index cdc1528967..0000000000 --- a/gr-vocoder/lib/vocoder_g723_40_decode_bs.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g723_40_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g723_40_decode_bs_impl : public vocoder_g723_40_decode_bs -{ -public: - - vocoder_g723_40_decode_bs_impl(); - ~vocoder_g723_40_decode_bs_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g723_40_decode_bs_sptr vocoder_make_g723_40_decode_bs() -{ - return gnuradio::get_initial_sptr(new vocoder_g723_40_decode_bs_impl()); -} - -vocoder_g723_40_decode_bs_impl::vocoder_g723_40_decode_bs_impl() - : gr_sync_block("vocoder_g723_40_decode_bs", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (short))) -{ - g72x_init_state(&d_state); -} - -vocoder_g723_40_decode_bs_impl::~vocoder_g723_40_decode_bs_impl() -{ -} - -int -vocoder_g723_40_decode_bs_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g723_40_decoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_g723_40_encode_sb.cc b/gr-vocoder/lib/vocoder_g723_40_encode_sb.cc deleted file mode 100644 index 083aaf97af..0000000000 --- a/gr-vocoder/lib/vocoder_g723_40_encode_sb.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_g723_40_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -class vocoder_g723_40_encode_sb_impl : public vocoder_g723_40_encode_sb -{ -public: - - vocoder_g723_40_encode_sb_impl(); - ~vocoder_g723_40_encode_sb_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - - g72x_state d_state; - -}; - -vocoder_g723_40_encode_sb_sptr vocoder_make_g723_40_encode_sb() -{ - return gnuradio::get_initial_sptr(new vocoder_g723_40_encode_sb_impl()); -} - -vocoder_g723_40_encode_sb_impl::vocoder_g723_40_encode_sb_impl() - : gr_sync_block("vocoder_g723_40_encode_sb", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (unsigned char))) -{ - g72x_init_state(&d_state); -} - -vocoder_g723_40_encode_sb_impl::~vocoder_g723_40_encode_sb_impl() -{ -} - -int -vocoder_g723_40_encode_sb_impl::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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = g723_40_encoder(in[i], AUDIO_ENCODING_LINEAR, &d_state); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_gsm_fr_decode_ps.cc b/gr-vocoder/lib/vocoder_gsm_fr_decode_ps.cc deleted file mode 100644 index 146ddf63c8..0000000000 --- a/gr-vocoder/lib/vocoder_gsm_fr_decode_ps.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "vocoder_gsm_fr_decode_ps.h" -extern "C"{ -#include "gsm/gsm.h" -} -#include <gr_io_signature.h> -#include <stdexcept> -#include <assert.h> - -vocoder_gsm_fr_decode_ps_sptr -vocoder_make_gsm_fr_decode_ps () -{ - return gnuradio::get_initial_sptr(new vocoder_gsm_fr_decode_ps ()); -} - -vocoder_gsm_fr_decode_ps::vocoder_gsm_fr_decode_ps () - : gr_sync_interpolator ("vocoder_gsm_fr_decode_ps", - gr_make_io_signature (1, 1, sizeof (gsm_frame)), - gr_make_io_signature (1, 1, sizeof (short)), - GSM_SAMPLES_PER_FRAME) -{ - if ((d_gsm = gsm_create ()) == 0) - throw std::runtime_error ("vocoder_gsm_fr_decode_ps: gsm_create failed"); -} - -vocoder_gsm_fr_decode_ps::~vocoder_gsm_fr_decode_ps () -{ - gsm_destroy (d_gsm); -} - -int -vocoder_gsm_fr_decode_ps::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]; - - assert ((noutput_items % GSM_SAMPLES_PER_FRAME) == 0); - - for (int i = 0; i < noutput_items; i += GSM_SAMPLES_PER_FRAME){ - gsm_decode (d_gsm, const_cast<unsigned char*>(in), out); - in += sizeof (gsm_frame); - out += GSM_SAMPLES_PER_FRAME; - } - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_gsm_fr_encode_sp.cc b/gr-vocoder/lib/vocoder_gsm_fr_encode_sp.cc deleted file mode 100644 index 5abb3a4576..0000000000 --- a/gr-vocoder/lib/vocoder_gsm_fr_encode_sp.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "vocoder_gsm_fr_encode_sp.h" -extern "C"{ -#include "gsm/gsm.h" -} -#include <gr_io_signature.h> -#include <stdexcept> - -vocoder_gsm_fr_encode_sp_sptr -vocoder_make_gsm_fr_encode_sp () -{ - return gnuradio::get_initial_sptr(new vocoder_gsm_fr_encode_sp ()); -} - -vocoder_gsm_fr_encode_sp::vocoder_gsm_fr_encode_sp () - : gr_sync_decimator ("vocoder_gsm_fr_encode_sp", - gr_make_io_signature (1, 1, sizeof (short)), - gr_make_io_signature (1, 1, sizeof (gsm_frame)), - GSM_SAMPLES_PER_FRAME) -{ - if ((d_gsm = gsm_create ()) == 0) - throw std::runtime_error ("vocoder_gsm_fr_encode_sp: gsm_create failed"); -} - -vocoder_gsm_fr_encode_sp::~vocoder_gsm_fr_encode_sp () -{ - gsm_destroy (d_gsm); -} - -int -vocoder_gsm_fr_encode_sp::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]; - - for (int i = 0; i < noutput_items; i++){ - gsm_encode (d_gsm, const_cast<short*>(in), out); - in += GSM_SAMPLES_PER_FRAME; - out += sizeof (gsm_frame); - } - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_ulaw_decode_bs.cc b/gr-vocoder/lib/vocoder_ulaw_decode_bs.cc deleted file mode 100644 index 5abec77f82..0000000000 --- a/gr-vocoder/lib/vocoder_ulaw_decode_bs.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_ulaw_decode_bs.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -vocoder_ulaw_decode_bs_sptr vocoder_make_ulaw_decode_bs() -{ - return gnuradio::get_initial_sptr(new vocoder_ulaw_decode_bs()); -} - -vocoder_ulaw_decode_bs::vocoder_ulaw_decode_bs() - : gr_sync_block("vocoder_ulaw_decode_bs", - gr_make_io_signature (1, 1, sizeof (unsigned char)), - gr_make_io_signature (1, 1, sizeof (short))) -{ -} - -vocoder_ulaw_decode_bs::~vocoder_ulaw_decode_bs() -{ -} - - - -int -vocoder_ulaw_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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = ulaw2linear(in[i]); - - return noutput_items; -} diff --git a/gr-vocoder/lib/vocoder_ulaw_encode_sb.cc b/gr-vocoder/lib/vocoder_ulaw_encode_sb.cc deleted file mode 100644 index 3fabd7ad8a..0000000000 --- a/gr-vocoder/lib/vocoder_ulaw_encode_sb.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vocoder_ulaw_encode_sb.h> -#include <gr_io_signature.h> -#include <limits.h> - -extern "C" { -#include "g7xx/g72x.h" -} - -vocoder_ulaw_encode_sb_sptr vocoder_make_ulaw_encode_sb() -{ - return gnuradio::get_initial_sptr(new vocoder_ulaw_encode_sb()); -} - -vocoder_ulaw_encode_sb::vocoder_ulaw_encode_sb() - : gr_sync_block("vocoder_ulaw_encode_sb", - gr_make_io_signature (1, 1, sizeof(short)), - gr_make_io_signature (1, 1, sizeof(unsigned char))) -{ -} - -vocoder_ulaw_encode_sb::~vocoder_ulaw_encode_sb() -{ -} - -int -vocoder_ulaw_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]; - - for(int i = 0; i < noutput_items; i++) - out[i] = linear2ulaw(in[i]); - - return noutput_items; -} |