diff options
author | Johnathan Corgan | 2012-06-27 06:50:22 -0700 |
---|---|---|
committer | Johnathan Corgan | 2012-06-27 06:50:22 -0700 |
commit | be1219b0623bbceb5bca6a6f6774f0669f52bdde (patch) | |
tree | 508b604e7871a5ec8e14ec398632928a0d33ff79 /gr-blocks/lib | |
parent | 3de0c77ed91e417c0b54972a78ffbad62f4bbb87 (diff) | |
download | gnuradio-be1219b0623bbceb5bca6a6f6774f0669f52bdde.tar.gz gnuradio-be1219b0623bbceb5bca6a6f6774f0669f52bdde.tar.bz2 gnuradio-be1219b0623bbceb5bca6a6f6774f0669f52bdde.zip |
blocks: added gr::blocks::interleaved_short_to_complex
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-blocks/lib/interleaved_short_array_to_complex.cc | 39 | ||||
-rw-r--r-- | gr-blocks/lib/interleaved_short_array_to_complex.h | 36 | ||||
-rw-r--r-- | gr-blocks/lib/interleaved_short_to_complex_impl.cc | 61 | ||||
-rw-r--r-- | gr-blocks/lib/interleaved_short_to_complex_impl.h | 45 |
5 files changed, 183 insertions, 0 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 16656dafc..21b17d315 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -135,6 +135,8 @@ list(APPEND gr_blocks_sources float_array_to_uchar.cc float_to_uchar_impl.cc int_to_float_impl.cc + interleaved_short_array_to_complex.cc + interleaved_short_to_complex_impl.cc multiply_cc_impl.cc multiply_ff_impl.cc multiply_const_cc_impl.cc diff --git a/gr-blocks/lib/interleaved_short_array_to_complex.cc b/gr-blocks/lib/interleaved_short_array_to_complex.cc new file mode 100644 index 000000000..eb6431b7a --- /dev/null +++ b/gr-blocks/lib/interleaved_short_array_to_complex.cc @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2012 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 "interleaved_short_array_to_complex.h" +#include <assert.h> + +void +interleaved_short_array_to_complex (const short *in, + gr_complex *out, int nsamples) +{ + assert (nsamples % 2 == 0); + + for (int i = 0; i < nsamples/2; i++){ + out[i] = gr_complex (in[i*2 + 0], in[i*2 + 1]); + } +} diff --git a/gr-blocks/lib/interleaved_short_array_to_complex.h b/gr-blocks/lib/interleaved_short_array_to_complex.h new file mode 100644 index 000000000..3f20fdb98 --- /dev/null +++ b/gr-blocks/lib/interleaved_short_array_to_complex.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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_INTERLEAVED_SHORT_ARRAY_TO_COMPLEX_H +#define INCLUDED_INTERLEAVED_SHORT_ARRAY_TO_COMPLEX_H + +#include <blocks/api.h> +#include <gr_complex.h> + +/* + * convert array of interleaved shorts to complex. + * the shorts contains real, imaginary, real, imaginary... + * nsamples is the number of shorts; it must be even. + */ +BLOCKS_API void interleaved_short_array_to_complex (const short *in, gr_complex *out, int nsamples); + +#endif /* INCLUDED_INTERLEAVED_SHORT_ARRAY_TO_COMPLEX_H */ diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.cc b/gr-blocks/lib/interleaved_short_to_complex_impl.cc new file mode 100644 index 000000000..1be6fdc9d --- /dev/null +++ b/gr-blocks/lib/interleaved_short_to_complex_impl.cc @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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 "interleaved_short_to_complex_impl.h" +#include "interleaved_short_array_to_complex.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + interleaved_short_to_complex::sptr interleaved_short_to_complex::make() + { + return gnuradio::get_initial_sptr(new interleaved_short_to_complex_impl()); + } + + interleaved_short_to_complex_impl::interleaved_short_to_complex_impl() + : gr_sync_decimator("interleaved_short_to_complex", + gr_make_io_signature (1, 1, sizeof(short)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + 2) + { + } + + int + interleaved_short_to_complex_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]; + gr_complex *out = (gr_complex *) output_items[0]; + + interleaved_short_array_to_complex (in, out, 2 * noutput_items); + + return noutput_items; + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.h b/gr-blocks/lib/interleaved_short_to_complex_impl.h new file mode 100644 index 000000000..62a1db308 --- /dev/null +++ b/gr-blocks/lib/interleaved_short_to_complex_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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_INTERLEAVED_SHORT_TO_COMPLEX_IMPL_H +#define INCLUDED_INTERLEAVED_SHORT_TO_COMPLEX_IMPL_H + +#include <blocks/interleaved_short_to_complex.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API interleaved_short_to_complex_impl : public interleaved_short_to_complex + { + public: + interleaved_short_to_complex_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + + +#endif /* INCLUDED_INTERLEAVED_SHORT_TO_COMPLEX_IMPL_H */ |