diff options
author | Ben Reynwar | 2012-03-18 20:04:07 -0400 |
---|---|---|
committer | Tom Rondeau | 2012-03-18 20:04:07 -0400 |
commit | 7fda6b2c2269a575fd6722085c9c9ace41c1c512 (patch) | |
tree | 7bb8aa6db6bc8e2392fcba826425d0b8abbe8b97 /gnuradio-core/src | |
parent | 32ff86449a26958288b84f43b0cef2eff8e27972 (diff) | |
download | gnuradio-7fda6b2c2269a575fd6722085c9c9ace41c1c512.tar.gz gnuradio-7fda6b2c2269a575fd6722085c9c9ace41c1c512.tar.bz2 gnuradio-7fda6b2c2269a575fd6722085c9c9ace41c1c512.zip |
core: fixed point sin/cos generator properly folds frequencies outside nyquist range to alias signal.
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_fxpt.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/general/gr_fxpt.h b/gnuradio-core/src/lib/general/gr_fxpt.h index 5cf736dfb..9f5937d1a 100644 --- a/gnuradio-core/src/lib/general/gr_fxpt.h +++ b/gnuradio-core/src/lib/general/gr_fxpt.h @@ -26,7 +26,7 @@ #include <gr_types.h> /*! - * \brief fixed point sine and cosine and friend GR_CORE_APIs. + * \brief fixed point sine and cosine and friends. * \ingroup misc * * fixed pt radians @@ -48,6 +48,10 @@ public: static gr_int32 float_to_fixed (float x) { + // Fold x into -PI to PI. + int d = (int)floor(x/2/PI+0.5); + x -= d*2*PI; + // And convert to an integer. return (gr_int32) ((float) x * TWO_TO_THE_31 / PI); } |