howto_signal_adder_cc.cc


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <howto_signal_adder_cc.h>
#include <algorithm>
#include <gr_io_signature.h>

static const int MIN_IN = 1;	// mininum number of input streams
static const int MAX_IN = -1;	// maximum number of input streams
static const int MIN_OUT = 1;
static const int MAX_OUT = -1;

howto_signal_adder_cc::howto_signal_adder_cc (int vlen)
  : gr_sync_block ("signal_adder_cc", 
		   gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex) * vlen),
		   gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex) * vlen)),
    d_vlen(vlen)
{
}

int
howto_signal_adder_cc::work (int noutput_items,
		    gr_vector_const_void_star &input_items,
		    gr_vector_void_star &output_items)
{
    const gr_complex *in0 = (const gr_complex *) input_items[0];
    const gr_complex *in1 = (const gr_complex *) input_items[1];
    gr_complex *out = (gr_complex *) output_items[0];
    
    for (int i = 0; i < noutput_items * d_vlen; i++){
	out[i] = in0[i] + in1[i];
    }
    return noutput_items;
}


howto_signal_adder_cc_sptr
howto_make_signal_adder_cc (int vlen)
{
  return howto_signal_adder_cc_sptr (new howto_signal_adder_cc (vlen));
}