diff options
-rw-r--r-- | gnuradio-core/src/lib/general/Makefile.am | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/general.i | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_cpfsk_bc.cc | 78 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_cpfsk_bc.h | 63 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_cpfsk_bc.i | 34 |
5 files changed, 182 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index ef5354cfe..5a12a739a 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -55,6 +55,7 @@ libgeneral_la_SOURCES = \ gr_correlate_access_code_bb.cc \ gr_costas_loop_cc.cc \ gr_count_bits.cc \ + gr_cpfsk_bc.cc \ gr_crc32.cc \ gr_ctcss_squelch_ff.cc \ gr_dd_mpsk_sync_cc.cc \ @@ -197,7 +198,8 @@ grinclude_HEADERS = \ gr_correlate_access_code_bb.h \ gr_costas_loop_cc.h \ gr_count_bits.h \ - gr_crc32.h \ + gr_cpfsk_bc.h \ + gr_crc32.h \ gr_ctcss_squelch_ff.h \ gr_dd_mpsk_sync_cc.h \ gr_diff_decoder_bb.h \ @@ -352,6 +354,7 @@ swiginclude_HEADERS = \ gr_constellation_decoder_cb.i \ gr_correlate_access_code_bb.i \ gr_costas_loop_cc.i \ + gr_cpfsk_bc.i \ gr_crc32.i \ gr_ctcss_squelch_ff.i \ gr_dd_mpsk_sync_cc.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 64aa2d889..724ea0316 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005,2006,2007 Free Software Foundation, Inc. + * Copyright 2004,2005,2006,2007,2008 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -130,6 +130,7 @@ #include <gr_glfsr_source_f.h> #include <gr_peak_detector2_fb.h> #include <gr_repeat.h> +#include <gr_cpfsk_bc.h> %} %include "gr_nop.i" @@ -240,3 +241,4 @@ %include "gr_glfsr_source_f.i" %include "gr_peak_detector2_fb.i" %include "gr_repeat.i" +%include "gr_cpfsk_bc.i" diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc b/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc new file mode 100644 index 000000000..95d7c1753 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 Free Software Foundation, Inc. + * + * 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 <gr_cpfsk_bc.h> +#include <gr_io_signature.h> +#include <gr_expj.h> + +#define M_TWOPI (2*M_PI) + +gr_cpfsk_bc_sptr +gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym) +{ + return gr_cpfsk_bc_sptr(new gr_cpfsk_bc(k, ampl, samples_per_sym)); +} + +gr_cpfsk_bc::gr_cpfsk_bc(float k, float ampl, int samples_per_sym) + : gr_sync_interpolator("cpfsk_bc", + gr_make_io_signature(1, 1, sizeof(char)), + gr_make_io_signature(1, 1, sizeof(gr_complex)), + samples_per_sym) +{ + d_samples_per_sym = samples_per_sym; + d_freq = k*M_PI/samples_per_sym; + d_ampl = ampl; + d_phase = 0.0; +} + +gr_cpfsk_bc::~gr_cpfsk_bc() +{ +} + +int +gr_cpfsk_bc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const char *in = (const char *)input_items[0]; + gr_complex *out = (gr_complex *)output_items[0]; + + for (int i = 0; i < noutput_items/d_samples_per_sym; i++) { + for (int j = 0; j < d_samples_per_sym; j++) { + if (in[i] == 1) + d_phase += d_freq; + else + d_phase -= d_freq; + + while (d_phase > M_TWOPI) + d_phase -= M_TWOPI; + while (d_phase < -M_TWOPI) + d_phase += M_TWOPI; + + *out++ = gr_expj(d_phase)*d_ampl; + } + } + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h new file mode 100644 index 000000000..38429543f --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 Free Software Foundation, Inc. + * + * 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_GR_CPFSK_BC_H +#define INCLUDED_GR_CPFSK_BC_H + +#include <gr_sync_interpolator.h> + +class gr_cpfsk_bc; + +typedef boost::shared_ptr<gr_cpfsk_bc> gr_cpfsk_bc_sptr; + +gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); + +/*! + * \brief Perform continuous phase 2-level frequncy modulation on an input stream + * of unpacked bits. + * \ingroup modulation + * + * \param k modulation index + * \param ampl output amplitude + * \param samples_per_sym number of output samples per input bit + */ + +class gr_cpfsk_bc : public gr_sync_interpolator +{ +private: + friend gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); + + gr_cpfsk_bc(float k, float ampl, int samples_per_sym); + + int d_samples_per_sym; // Samples per symbol, square pulse + float d_freq; // Modulation index*pi/samples_per_sym + float d_ampl; // Output amplitude + float d_phase; // Current phase + + public: + ~gr_cpfsk_bc(); + + void set_amplitude(float amplitude) { d_ampl = amplitude; } + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_GR_CPFSK_BC_H */ diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.i b/gnuradio-core/src/lib/general/gr_cpfsk_bc.i new file mode 100644 index 000000000..918766a68 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.i @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 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. + */ + +GR_SWIG_BLOCK_MAGIC(gr,cpfsk_bc); + +gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym); + +class gr_cpfsk_bc : public gr_sync_interpolator +{ +private: + gr_cpfsk_bc(float k, float ampl, int samples_per_sym); + +public: + void set_amplitude(float amplitude); +}; |