Ticket #171 (enhancement)
Opened 1 year ago
gr_float_to_complex compatible to vector streams
Status: new
| Reported by: | guest | Assigned to: | eb |
|---|---|---|---|
| Priority: | low | Milestone: | to-be-decided |
| Component: | gnuradio-core | Version: | 3.0.4 |
| Keywords: | complex to float vector | Cc: | |
Small enhancement, but useful:
gr_float_to_complex.cc
gr_float_to_complex_sptr gr_make_float_to_complex (int vlen) { return gr_float_to_complex_sptr (new gr_float_to_complex (vlen)); } gr_float_to_complex::gr_float_to_complex (int vlen) : gr_sync_block ("gr_float_to_complex", gr_make_io_signature (1, 2, sizeof (float)*vlen), gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)), d_vlen(vlen) { } int gr_float_to_complex::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { float *r = (float *)input_items[0]; float *i = (float *)input_items[1]; gr_complex *out = (gr_complex *) output_items[0]; switch (input_items.size ()){ case 1: for (int j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], 0); break; case 2: for (int j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], i[j]); break; default: assert (0); } return noutput_items; }
gr_float_to_complex.h
gr_float_to_complex_sptr gr_make_float_to_complex (int vlen); /*! * \brief Convert 1 or 2 streams of float to a stream of gr_complex * \ingroup converter */ class gr_float_to_complex : public gr_sync_block { friend gr_float_to_complex_sptr gr_make_float_to_complex (int vlen); gr_float_to_complex (int vlen); int d_vlen; public: virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); };
gr_float_to_complex.i
GR_SWIG_BLOCK_MAGIC(gr,float_to_complex) gr_float_to_complex_sptr gr_make_float_to_complex (int vlen); class gr_float_to_complex : public gr_sync_block { private: gr_float_to_complex (int vlen); };
