diff options
Diffstat (limited to 'gr-blocks')
-rw-r--r-- | gr-blocks/grc/blocks_block_tree.xml | 5 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_interleaved_short_to_complex.xml | 20 | ||||
-rw-r--r-- | gr-blocks/include/blocks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/include/blocks/complex_to_interleaved_short.h | 2 | ||||
-rw-r--r-- | gr-blocks/include/blocks/interleaved_short_to_complex.h | 49 | ||||
-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 | ||||
-rwxr-xr-x | gr-blocks/python/qa_type_conversions.py | 10 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig.i | 3 |
12 files changed, 270 insertions, 3 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 68135b924..9a56d4c41 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -29,7 +29,7 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Math Operations</name> + <name>Math Operations (New) </name> <block>blocks_add_xx</block> <block>blocks_add_const_vxx</block> <block>blocks_divide_xx</block> @@ -38,7 +38,7 @@ <block>blocks_sub_xx</block> </cat> <cat> - <name>Stream Type Conversions</name> + <name>Stream Type Conversions (New) </name> <block>blocks_char_to_float</block> <block>blocks_char_to_short</block> <block>blocks_complex_to_interleaved_short</block> @@ -54,5 +54,6 @@ <block>blocks_float_to_short</block> <block>blocks_float_to_uchar</block> <block>blocks_int_to_float</block> + <block>blocks_interleaved_short_to_complex</block> </cat> </cat> diff --git a/gr-blocks/grc/blocks_interleaved_short_to_complex.xml b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml new file mode 100644 index 000000000..e44113e74 --- /dev/null +++ b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Interleaved Short to Complex: +################################################### + --> +<block> + <name>IShort To Complex</name> + <key>blocks_interleaved_short_to_complex</key> + <import>from gnuradio import blocks</import> + <make>blocks.interleaved_short_to_complex()</make> + <sink> + <name>in</name> + <type>short</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index e56c7b87c..9616db3a6 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -99,6 +99,7 @@ install(FILES float_to_short.h float_to_uchar.h int_to_float.h + interleaved_complex_to_short.h multiply_cc.h multiply_ff.h multiply_const_cc.h diff --git a/gr-blocks/include/blocks/complex_to_interleaved_short.h b/gr-blocks/include/blocks/complex_to_interleaved_short.h index 33cbddf6b..f5e91123c 100644 --- a/gr-blocks/include/blocks/complex_to_interleaved_short.h +++ b/gr-blocks/include/blocks/complex_to_interleaved_short.h @@ -37,7 +37,7 @@ namespace gr { { public: - // gr::blocks::complex_to_interleaved_short_ff::sptr + // gr::blocks::complex_to_interleaved_short::sptr typedef boost::shared_ptr<complex_to_interleaved_short> sptr; static sptr make(); diff --git a/gr-blocks/include/blocks/interleaved_short_to_complex.h b/gr-blocks/include/blocks/interleaved_short_to_complex.h new file mode 100644 index 000000000..40e96fc46 --- /dev/null +++ b/gr-blocks/include/blocks/interleaved_short_to_complex.h @@ -0,0 +1,49 @@ +/* -*- 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_BLOCKS_INTERLEAVED_SHORT_TO_COMPLEX_H +#define INCLUDED_BLOCKS_INTERLEAVED_SHORT_TO_COMPLEX_H + +#include <blocks/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Convert stream of interleaved shorts to a stream of complex + * \ingroup converter_blk + */ + class BLOCKS_API interleaved_short_to_complex : virtual public gr_sync_decimator + { + public: + + // gr::blocks::interleaved_short_to_complex::sptr + typedef boost::shared_ptr<interleaved_short_to_complex> sptr; + + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_INTERLEAVED_SHORT_TO_COMPLEX_H */ 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 */ diff --git a/gr-blocks/python/qa_type_conversions.py b/gr-blocks/python/qa_type_conversions.py index 354cf9392..92e0a7ca4 100755 --- a/gr-blocks/python/qa_type_conversions.py +++ b/gr-blocks/python/qa_type_conversions.py @@ -261,6 +261,16 @@ class test_type_conversions(gr_unittest.TestCase): self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data()) + def test_interleaved_short_to_complex(self): + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + expected_data = (1+2j, 3+4j, 5+6j, 7+8j, 9+10j) + src = gr.vector_source_s(src_data) + op = blocks_swig.interleaved_short_to_complex() + dst = gr.vector_sink_c() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_data, dst.data()) + if __name__ == '__main__': gr_unittest.run(test_type_conversions, "test_type_conversions.xml") diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index 1a903e128..0545a833c 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -59,6 +59,7 @@ #include "blocks/float_to_short.h" #include "blocks/float_to_uchar.h" #include "blocks/int_to_float.h" +#include "blocks/interleaved_short_to_complex.h" #include "blocks/multiply_ss.h" #include "blocks/multiply_ii.h" #include "blocks/multiply_ff.h" @@ -108,6 +109,7 @@ %include "blocks/float_to_short.h" %include "blocks/float_to_uchar.h" %include "blocks/int_to_float.h" +%include "blocks/interleaved_short_to_complex.h" %include "blocks/multiply_ss.h" %include "blocks/multiply_ii.h" %include "blocks/multiply_ff.h" @@ -156,6 +158,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, float_to_int); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_short); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_uchar); GR_SWIG_BLOCK_MAGIC2(blocks, int_to_float); +GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff); |