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 3, 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)
36 //FIXME Eventually generalize this to fixed point
38 template<class o_type, class i_type>
41 gr_vco () : d_phase (0) {}
46 void set_phase (double angle) {
50 void adjust_phase (double delta_phase) {
51 d_phase += delta_phase;
52 if (fabs (d_phase) > M_PI){
54 while (d_phase > M_PI)
57 while (d_phase < -M_PI)
62 double get_phase () const { return d_phase; }
64 // compute sin and cos for current phase angle
65 void sincos (float *sinx, float *cosx) const;
67 // compute cos or sin for current phase angle
68 float cos () const { return std::cos (d_phase); }
69 float sin () const { return std::sin (d_phase); }
71 // compute a block at a time
72 void cos (float *output, const float *input, int noutput_items, double k, double ampl = 1.0);
78 template<class o_type, class i_type>
80 gr_vco<o_type,i_type>::sincos (float *sinx, float *cosx) const
82 gr_sincosf (d_phase, sinx, cosx);
85 template<class o_type, class i_type>
87 gr_vco<o_type,i_type>::cos (float *output, const float *input, int noutput_items, double k, double ampl)
89 for (int i = 0; i < noutput_items; i++){
90 output[i] = cos() * ampl;
91 adjust_phase(input[i] * k);
94 #endif /* _GR_VCO_H_ */