Improve the FIR filter a bit
This commit is contained in:
parent
884d84bbf9
commit
63ca3c6439
42
src/main.c
42
src/main.c
|
@ -384,34 +384,52 @@ static void rf_rx_stop(void)
|
||||||
|
|
||||||
inline static int next_sample(const uint32_t *buf, int *h)
|
inline static int next_sample(const uint32_t *buf, int *h)
|
||||||
{
|
{
|
||||||
int x1 = buf[0] - buf[1];
|
int x3 = 2 * (buf[0] - buf[1]);
|
||||||
int x2 = 0;
|
int x2 = 0;
|
||||||
int x3 = buf[5] - buf[4];
|
int x1 = 2 * (buf[5] - buf[4]);
|
||||||
int x4 = 0;
|
int x0 = 0;
|
||||||
|
|
||||||
int sample = 18 * h[9] + 14 * h[8] - 32 * h[7] - 33 * h[6] + 106 * h[5] + 362 * h[4] +
|
const int c[] = { 4, 2, -8, -9, 19, 55 };
|
||||||
565 * h[3] + 565 * h[2] + 362 * h[1] + 106 * h[0] - 33 * x1 - 32 * x2 +
|
|
||||||
14 * x3 + 18 * x4;
|
|
||||||
|
|
||||||
|
int sample = 0;
|
||||||
|
sample += (c[0]) * h[10];
|
||||||
|
sample += (c[0] + c[1]) * h[9];
|
||||||
|
sample += (c[0] + c[1] + c[2]) * h[8];
|
||||||
|
sample += (c[0] + c[1] + c[2] + c[3]) * h[7];
|
||||||
|
sample += (c[1] + c[2] + c[3] + c[4]) * h[6];
|
||||||
|
sample += (c[2] + c[3] + c[4] + c[5]) * h[5];
|
||||||
|
sample += (c[3] + c[4] + c[5] + c[5]) * h[4];
|
||||||
|
sample += (c[4] + c[5] + c[5] + c[4]) * h[3];
|
||||||
|
sample += (c[5] + c[5] + c[4] + c[3]) * h[2];
|
||||||
|
sample += (c[5] + c[4] + c[3] + c[2]) * h[1];
|
||||||
|
sample += (c[4] + c[3] + c[2] + c[1]) * h[0];
|
||||||
|
sample += (c[3] + c[2] + c[1] + c[0]) * x3;
|
||||||
|
sample += (c[2] + c[1] + c[0]) * x2;
|
||||||
|
sample += (c[1] + c[0]) * x1;
|
||||||
|
sample += (c[0]) * x0;
|
||||||
|
sample *= gain;
|
||||||
|
sample /= 256;
|
||||||
|
|
||||||
|
h[10] = h[6];
|
||||||
h[9] = h[5];
|
h[9] = h[5];
|
||||||
h[8] = h[4];
|
h[8] = h[4];
|
||||||
h[7] = h[3];
|
h[7] = h[3];
|
||||||
h[6] = h[2];
|
h[6] = h[2];
|
||||||
h[5] = h[1];
|
h[5] = h[1];
|
||||||
h[4] = h[0];
|
h[4] = h[0];
|
||||||
h[3] = x1;
|
h[3] = x3;
|
||||||
h[2] = x2;
|
h[2] = x2;
|
||||||
h[1] = x3;
|
h[1] = x1;
|
||||||
h[0] = x4;
|
h[0] = x0;
|
||||||
|
|
||||||
return gain * sample / 565;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rf_rx(void)
|
static void rf_rx(void)
|
||||||
{
|
{
|
||||||
const uint32_t base = (uint32_t)rx_cos;
|
const uint32_t base = (uint32_t)rx_cos;
|
||||||
int prevI[10] = { 0 };
|
int prevI[11] = { 0 };
|
||||||
int prevQ[10] = { 0 };
|
int prevQ[11] = { 0 };
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
Loading…
Reference in a new issue