From 5a55ae7098d58e5a1fc56b65110d9086d70c7124 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 15 Mar 2012 14:28:26 -0400 Subject: gr_frequency_modulator_f : Convert from using libm sin/cos, to gr_fxpt sin/cos. Signed-off-by: Philip Balister --- .../src/lib/general/gr_frequency_modulator_fc.cc | 20 ++++++++++---------- .../src/lib/general/gr_frequency_modulator_fc.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'gnuradio-core/src/lib/general') 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 #include -#include +#include #include #include @@ -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); -- cgit