3 * Copyright 2005 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <gr_sincos.h>
29 #include <gr_complex.h>
32 * \brief base class template for Voltage Controlled Oscillator (VCO)
35 //FIXME Eventually generalize this to fixed point
37 template<class o_type, class i_type>
40 gr_vco () : d_phase (0) {}
45 void set_phase (double angle) {
49 void adjust_phase (double delta_phase) {
50 d_phase += delta_phase;
51 if (fabs (d_phase) > M_PI){
53 while (d_phase > M_PI)
56 while (d_phase < -M_PI)
61 double get_phase () const { return d_phase; }
63 // compute sin and cos for current phase angle
64 void sincos (float *sinx, float *cosx) const;
66 // compute cos or sin for current phase angle
67 float cos () const { return std::cos (d_phase); }
68 float sin () const { return std::sin (d_phase); }
70 // compute a block at a time
71 void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0);
77 template<class o_type, class i_type>
79 gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const
81 gr_sincosf (d_phase, sinx, cosx);
84 template<class o_type, class i_type>
86 gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl)
88 for (int i = 0; i < noutput_items; i++){
89 output[i] = cos() * ampl;
90 adjust_phase(input[i] * k);
93 #endif /* _GR_VCO_H_ */