summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc20
-rw-r--r--gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h4
2 files changed, 12 insertions, 12 deletions
diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
index bff22be25..553b50398 100644
--- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
+++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc
@@ -26,7 +26,7 @@
#include <gr_frequency_modulator_fc.h>
#include <gr_io_signature.h>
-#include <gr_sincos.h>
+#include <gr_fxpt.h>
#include <math.h>
#include <boost/math/special_functions/trunc.hpp>
@@ -54,17 +54,17 @@ gr_frequency_modulator_fc::work (int noutput_items,
for (int i = 0; i < noutput_items; i++){
d_phase = d_phase + d_sensitivity * in[i];
- float oi, oq;
- gr_sincosf (d_phase, &oq, &oi);
- out[i] = gr_complex (oi, oq);
- }
- // Limit the phase accumulator to [-16*pi,16*pi]
- // to avoid loss of precision in the addition above.
+ if (d_phase > (float)(M_PI))
+ d_phase -= (float)(2.0 * M_PI);
+ else if (d_phase < (float)(-M_PI))
+ d_phase += (float)(2.0 * M_PI);
- if (fabs (d_phase) > 16 * M_PI){
- double ii = boost::math::trunc (d_phase / (2 * M_PI));
- d_phase = d_phase - (ii * 2 * M_PI);
+ float oi, oq;
+
+ gr_int32 angle = gr_fxpt::float_to_fixed (d_phase);
+ gr_fxpt::sincos (angle, &oq, &oi);
+ out[i] = gr_complex (oi, oq);
}
return noutput_items;
diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
index 932e7da36..e3aaafb1a 100644
--- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
+++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h
@@ -39,8 +39,8 @@ GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (doubl
*/
class GR_CORE_API gr_frequency_modulator_fc : public gr_sync_block
{
- double d_sensitivity;
- double d_phase;
+ float d_sensitivity;
+ float d_phase;
friend GR_CORE_API gr_frequency_modulator_fc_sptr
gr_make_frequency_modulator_fc (double sensitivity);