summaryrefslogtreecommitdiff
path: root/filt
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2015-12-30 19:20:20 +0000
committerFreeArtMan <dos21h@gmail.com>2015-12-30 19:20:20 +0000
commita9d66c6a759515c7061e2e8aac661eeb0082ea1e (patch)
treeda0bfb62d614fcad482cc5267f0a4348cbde5256 /filt
parent03a2ac933087722b3754f5eca349b26193e9bffd (diff)
downloadradiola-a9d66c6a759515c7061e2e8aac661eeb0082ea1e.tar.gz
radiola-a9d66c6a759515c7061e2e8aac661eeb0082ea1e.zip
More configurable sources. Move some math functions to core/math.h. Move delay filter from sdr_fm
Diffstat (limited to 'filt')
-rw-r--r--filt/filt.h7
-rw-r--r--filt/filt_5th.c (renamed from filt/f_5th.c)2
-rw-r--r--filt/filt_delay.c51
-rw-r--r--filt/make.mk2
4 files changed, 59 insertions, 3 deletions
diff --git a/filt/filt.h b/filt/filt.h
index d235449..9ce2caa 100644
--- a/filt/filt.h
+++ b/filt/filt.h
@@ -3,9 +3,14 @@
#include <stdlib.h>
#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
#include <unistd.h>
//fifth order filter from rtlsdr
-void f_5th(int16_t *data, int length, int16_t *hist);
+void filt_5th(int16_t *data, int length, int16_t *hist);
+
+//delay filtering from https://github.com/dpiponi/mini_fm.git
+void filt_delay( uint8_t *buf, int buf_len );
#endif \ No newline at end of file
diff --git a/filt/f_5th.c b/filt/filt_5th.c
index 811fb18..23d5aab 100644
--- a/filt/f_5th.c
+++ b/filt/filt_5th.c
@@ -29,4 +29,4 @@ void f_5th(int16_t *data, int length, int16_t *hist)
hist[3] = d;
hist[4] = e;
hist[5] = f;
-} \ No newline at end of file
+}
diff --git a/filt/filt_delay.c b/filt/filt_delay.c
new file mode 100644
index 0000000..53da0b0
--- /dev/null
+++ b/filt/filt_delay.c
@@ -0,0 +1,51 @@
+#include "filt.h"
+
+//delay filtering
+void filt_delay( uint8_t *buf, int buf_len )
+{
+ //delay length
+ const int n=10;
+
+ int i=0;
+ uint32_t cycle=0;
+ uint32_t avg_i=0, avg_q=0;
+ uint32_t cyc_buffer_i[n],delay_i=0;
+ uint32_t cyc_buffer_q[n],delay_q=0;
+ uint8_t in1=0,in2=0,out1=0,out2=0;
+
+ memset( cyc_buffer_i, 0, n*sizeof(uint32_t) );
+ memset( cyc_buffer_q, 0, n*sizeof(uint32_t) );
+
+ //for (i=0; i<(buf_len-(n*2));i+=2)
+ for (i=0 ; i<(buf_len-1) ; i+=2 )
+ //for (i=0; i<1000; i+=2)
+ {
+ in1 = buf[i];
+ in2 = buf[i+1];
+
+ //average
+ avg_i += (uint32_t)in1;
+ avg_q += (uint32_t)in2;
+
+ delay_i = cyc_buffer_i[cycle];
+ delay_q = cyc_buffer_q[cycle];
+
+ cyc_buffer_i[cycle] = avg_i;
+ cyc_buffer_q[cycle] = avg_q;
+ cycle = cycle + 1;
+ if ( cycle >= n )
+ {
+ cycle = 0;
+ }
+
+ out1 = (avg_i - delay_i)/n;
+ out2 = (avg_q - delay_q)/n;
+
+ buf[i] = out1;
+ buf[i+1] = out2;
+
+ //printf("%d,avg=[%d,%d],delay=[%d,%d],in=[%d,%d],out=[%d,%d]\n",
+ // cycle, avg_i,avg_q,delay_i,delay_q,in1,in2,out1,out2);
+
+ }
+} \ No newline at end of file
diff --git a/filt/make.mk b/filt/make.mk
index bde2fe3..be7468f 100644
--- a/filt/make.mk
+++ b/filt/make.mk
@@ -1,5 +1,5 @@
DIR_FILT = filt/
-SOURCES_FILT += filt/f_5th.c
+SOURCES_FILT += filt/filt_5th.c filt/filt_delay.c
OBJECTS_FILT += $(SOURCES_FILT:.c=.o)
LDFLAGS +=
LDFLAGS_BSD +=