summaryrefslogtreecommitdiff
path: root/gnuradio-core
diff options
context:
space:
mode:
authorPhilip Balister2012-03-15 14:28:26 -0400
committerPhilip Balister2012-03-15 14:28:26 -0400
commit5a55ae7098d58e5a1fc56b65110d9086d70c7124 (patch)
treec3ee0b16685e81c44989724389686b66a23ad737 /gnuradio-core
parent92a047f5b33217337bc19cca6cfd860ebd29ab9e (diff)
downloadgnuradio-5a55ae7098d58e5a1fc56b65110d9086d70c7124.tar.gz
gnuradio-5a55ae7098d58e5a1fc56b65110d9086d70c7124.tar.bz2
gnuradio-5a55ae7098d58e5a1fc56b65110d9086d70c7124.zip
gr_frequency_modulator_f : Convert from using libm sin/cos, to gr_fxpt sin/cos.
Signed-off-by: Philip Balister <philip@opensdr.com>
Diffstat (limited to 'gnuradio-core')
-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);