/* -*- c++ -*- */
/*
* Copyright 2004 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.
*/
/*
* WARNING: This file is automatically generated by generate_gr_fir_filter_XXX.py
* Any changes made to this file will be overwritten.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <howto_interp_scrambler_cc.h>
#include <gr_io_signature.h>
#include <stdexcept>
#include <iostream>
howto_interp_scrambler_cc_sptr howto_make_interp_scrambler_cc (unsigned interpolation, int mask, int seed, int len)
{
return howto_interp_scrambler_cc_sptr (new howto_interp_scrambler_cc (interpolation, mask, seed, len));
}
howto_interp_scrambler_cc::howto_interp_scrambler_cc (unsigned interpolation, int mask, int seed, int len)
: gr_sync_interpolator ("interp_fir_filter_ccf",
gr_make_io_signature (1, 1, sizeof (gr_complex)),
gr_make_io_signature (1, 1, sizeof (gr_complex)),
interpolation),
d_lfsr(mask, seed, len)
{
if (interpolation == 0)
throw std::out_of_range ("interpolation must be > 0");
}
/*
howto_interp_scrambler_cc::~howto_interp_scrambler_cc ()
{
int interp = interpolation ();
for (int i = 0; i < interp; i++)
delete d_firs[i];
}
*/
int
howto_interp_scrambler_cc::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
int out_idx;
int ntaps = interpolation ();
int ni = noutput_items / interpolation ();
float nextbit;
for (int i = 0; i < ni; i++){
for (int nt = 0; nt < ntaps; nt++){
nextbit = d_lfsr.next_bit();
//printf("next_bit = %f\n", nextbit);
out[nt] = gr_complex(nextbit*real(in[i]), imag(in[i])); //The type of argument must be complex<float> !
}
out += ntaps;
}
return noutput_items;
}
最終更新:2011年06月16日 22:23