summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2011-04-07 11:09:51 -0400
committerTom Rondeau2011-04-07 11:12:09 -0400
commite36dc98e5f5aa82b146007c0379b6e55eca40578 (patch)
tree0f0931ab9f5e2739fa7b337afc39bbffee9c35c7
parent4a5c3dd3efaa5a57835e3561b33215d1fcfc7646 (diff)
downloadgnuradio-e36dc98e5f5aa82b146007c0379b6e55eca40578.tar.gz
gnuradio-e36dc98e5f5aa82b146007c0379b6e55eca40578.tar.bz2
gnuradio-e36dc98e5f5aa82b146007c0379b6e55eca40578.zip
core: adding a type converter - int -> float.
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am2
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc59
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.h51
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.i30
5 files changed, 144 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 3ceea7a6d..c36e7d7e7 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -139,6 +139,7 @@ libgeneral_la_SOURCES = \
gr_rms_cf.cc \
gr_rms_ff.cc \
gr_short_to_float.cc \
+ gr_int_to_float.cc \
gr_simple_correlator.cc \
gr_simple_framer.cc \
gr_simple_squelch_cc.cc \
@@ -301,6 +302,7 @@ grinclude_HEADERS = \
gr_rms_cf.h \
gr_rms_ff.h \
gr_short_to_float.h \
+ gr_int_to_float.h \
gr_simple_correlator.h \
gr_simple_framer.h \
gr_simple_framer_sync.h \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index fb9c4c0f2..e8a18ab19 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -42,6 +42,7 @@
#include <gr_float_to_char.h>
#include <gr_float_to_uchar.h>
#include <gr_short_to_float.h>
+#include <gr_int_to_float.h>
#include <gr_char_to_float.h>
#include <gr_uchar_to_float.h>
#include <gr_frequency_modulator_fc.h>
@@ -167,6 +168,7 @@
%include "gr_float_to_char.i"
%include "gr_float_to_uchar.i"
%include "gr_short_to_float.i"
+%include "gr_int_to_float.i"
%include "gr_char_to_float.i"
%include "gr_uchar_to_float.i"
%include "gr_frequency_modulator_fc.i"
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc
new file mode 100644
index 000000000..c60157e34
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc
@@ -0,0 +1,59 @@
+/* -*- 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 <gr_int_to_float.h>
+#include <gr_io_signature.h>
+
+gr_int_to_float_sptr
+gr_make_int_to_float ()
+{
+ return gnuradio::get_initial_sptr(new gr_int_to_float ());
+}
+
+gr_int_to_float::gr_int_to_float ()
+ : gr_sync_block ("gr_int_to_float",
+ gr_make_io_signature (1, 1, sizeof (int32_t)),
+ gr_make_io_signature (1, 1, sizeof (float)))
+{
+}
+
+int
+gr_int_to_float::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const int32_t *in = (const int32_t *) input_items[0];
+ float *out = (float *) output_items[0];
+
+ for(int i=0; i<noutput_items; i++){
+ out[i] = (float) in[i];
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h
new file mode 100644
index 000000000..cf1223be5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.h
@@ -0,0 +1,51 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_GR_INT_TO_FLOAT_H
+#define INCLUDED_GR_INT_TO_FLOAT_H
+
+#include <gr_sync_block.h>
+
+class gr_int_to_float;
+typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr;
+
+gr_int_to_float_sptr
+gr_make_int_to_float ();
+
+/*!
+ * \brief Convert stream of short to a stream of float
+ * \ingroup converter_blk
+ */
+
+class gr_int_to_float : public gr_sync_block
+{
+ friend gr_int_to_float_sptr gr_make_int_to_float ();
+ gr_int_to_float ();
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_INT_TO_FLOAT_H */
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i
new file mode 100644
index 000000000..8cb9e35b5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.i
@@ -0,0 +1,30 @@
+/* -*- 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,int_to_float)
+
+gr_int_to_float_sptr gr_make_int_to_float ();
+
+class gr_int_to_float : public gr_sync_block
+{
+ gr_int_to_float ();
+};