11 #ifndef INCLUDED_GR_FXPT_H
12 #define INCLUDED_GR_FXPT_H
32 static constexpr
int WORDBITS = 32;
33 static constexpr
int NBITS = 10;
34 static constexpr uint32_t ACCUM_MASK = ((1 << (WORDBITS - NBITS)) - 1);
35 static const float s_sine_table[1 << NBITS][2];
36 static const float PI;
37 static const float TAU;
38 static const float TWO_TO_THE_31;
44 int d = (int)std::floor(x / TAU + 0.5);
47 return (int32_t)((float)x * TWO_TO_THE_31 / PI);
55 static float sin(int32_t x)
58 int index = ux >> (WORDBITS - NBITS);
59 return s_sine_table[index][0] * (ux & ACCUM_MASK) + s_sine_table[index][1];
65 static float cos(int32_t x)
67 uint32_t ux = (uint32_t)x + 0x40000000;
68 int index = ux >> (WORDBITS - NBITS);
69 return s_sine_table[index][0] * (ux & ACCUM_MASK) + s_sine_table[index][1];
75 static void sincos(int32_t x,
float* s,
float* c)
78 int sin_index = ux >> (WORDBITS - NBITS);
79 *s = s_sine_table[sin_index][0] * (ux & ACCUM_MASK) + s_sine_table[sin_index][1];
81 ux = (uint32_t)x + 0x40000000;
82 int cos_index = ux >> (WORDBITS - NBITS);
83 *c = s_sine_table[cos_index][0] * (ux & ACCUM_MASK) + s_sine_table[cos_index][1];
fixed point sine and cosine and friends.
Definition: fxpt.h:31
static void sincos(int32_t x, float *s, float *c)
Definition: fxpt.h:75
static float cos(int32_t x)
Definition: fxpt.h:65
static int32_t float_to_fixed(float x)
Definition: fxpt.h:41
static float sin(int32_t x)
Given a fixed point angle x, return float sine (x)
Definition: fxpt.h:55
static float fixed_to_float(int32_t x)
Definition: fxpt.h:50
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29