diff --git a/src/main.c b/src/main.c index d64a67a..f3a7fab 100644 --- a/src/main.c +++ b/src/main.c @@ -38,10 +38,10 @@ #define IQ_SAMPLES 32 #define IQ_BLOCK_LEN (2 * IQ_SAMPLES) -#define IQ_QUEUE_LEN 4 +#define IQ_QUEUE_LEN 8 #define ADC_RATE (2 * MHZ) -#define DECIMATE 8 +#define DECIMATE 4 /* * NOTE: Must have 256 phases with 256 bytes each. @@ -263,47 +263,18 @@ inline static struct IQ next_sample() { int I = 0, Q = 0; - int x07 = nextQ(); - I += 36 * x07; - Q += 36 * x07; - - int x06 = nextQ(); - I += 0 * x06; - Q += 51 * x06; - - int x05 = nextQ(); - I += -36 * x05; - Q += 36 * x05; - - int x04 = nextQ(); - I += -51 * x04; - Q += 0 * x04; - - int x03 = nextQ(); - I += -36 * x03; - Q += -36 * x03; - - int x02 = nextQ(); - I += 0 * x02; - Q += -51 * x02; - - int x01 = nextQ(); - I += 36 * x01; - Q += -36 * x01; - - int x00 = nextQ(); - I += 51 * x00; - Q += 0 * x00; + I += nextQ(); + Q += nextQ(); + I -= nextQ(); + Q -= nextQ(); I *= gain; - I >>= 8; - I += 127.4 * 256; - I >>= 8; + I += 32614; // 127.4 * 256 + I >>= 9; // one extra division by 2 because we add 2 samples Q *= gain; - Q >>= 8; - Q += 127.4 * 256; - Q >>= 8; + Q += 32614; + Q >>= 9; return (struct IQ){ I, Q }; }