GNU Radio 3.7.2.1 C++ API
fxpt_vco.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2002,2004,2005,2013 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
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)
10
* any later version.
11
*
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.
16
*
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.
21
*/
22
23
#ifndef INCLUDED_GR_FXPT_VCO_H
24
#define INCLUDED_GR_FXPT_VCO_H
25
26
#include <
gnuradio/api.h
>
27
#include <
gnuradio/fxpt.h
>
28
#include <
gnuradio/gr_complex.h
>
29
30
namespace
gr {
31
32
/*!
33
* \brief Voltage Controlled Oscillator (VCO)
34
* \ingroup misc
35
*/
36
class
/*GR_RUNTIME_API*/
fxpt_vco
{
37
gr_int32
d_phase;
38
39
public
:
40
fxpt_vco
() : d_phase(0) {}
41
42
~fxpt_vco
() {}
43
44
// radians
45
void
set_phase
(
float
angle) {
46
d_phase =
fxpt::float_to_fixed
(angle);
47
}
48
49
void
adjust_phase
(
float
delta_phase) {
50
d_phase +=
fxpt::float_to_fixed
(delta_phase);
51
}
52
53
float
get_phase
()
const
{
54
return
fxpt::fixed_to_float
(d_phase);
55
}
56
57
// compute sin and cos for current phase angle
58
void
sincos
(
float
*sinx,
float
*cosx)
const
59
{
60
*sinx =
fxpt::sin
(d_phase);
61
*cosx =
fxpt::cos
(d_phase);
62
}
63
64
// compute complex sine a block at a time
65
void
sincos
(
gr_complex
*output,
const
float
*input,
int
noutput_items,
66
float
k,
float
ampl = 1.0)
67
{
68
for
(
int
i = 0; i < noutput_items; i++) {
69
output[i] =
gr_complex
((
float
)(
fxpt::cos
(d_phase) * ampl),
70
(
float
)(
fxpt::sin
(d_phase) * ampl));
71
adjust_phase
(input[i] * k);
72
}
73
}
74
75
// compute a block at a time
76
void
cos
(
float
*output,
const
float
*input,
int
noutput_items,
float
k,
float
ampl = 1.0)
77
{
78
for
(
int
i = 0; i < noutput_items; i++) {
79
output[i] = (float)(
fxpt::cos
(d_phase) * ampl);
80
adjust_phase
(input[i] * k);
81
}
82
}
83
84
// compute cos or sin for current phase angle
85
float
cos
()
const
{
return
fxpt::cos
(d_phase); }
86
float
sin
()
const
{
return
fxpt::sin
(d_phase); }
87
};
88
89
}
/* namespace gr */
90
91
#endif
/* INCLUDED_GR_FXPT_VCO_H */
gnuradio
gnuradio-runtime
include
gnuradio
fxpt_vco.h
Generated by
1.8.3.1