From e42911405c4bc2f8c097f47d4598baf8522ef3da Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 8 May 2016 16:02:01 +0100 Subject: Moved source to src directory --- src/filt/Kconfig | 0 src/filt/filt.h | 16 ++++++++++++++++ src/filt/filt_5th.c | 32 ++++++++++++++++++++++++++++++++ src/filt/filt_delay.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/filt/make.mk | 11 +++++++++++ 5 files changed, 110 insertions(+) create mode 100644 src/filt/Kconfig create mode 100644 src/filt/filt.h create mode 100644 src/filt/filt_5th.c create mode 100644 src/filt/filt_delay.c create mode 100644 src/filt/make.mk (limited to 'src/filt') diff --git a/src/filt/Kconfig b/src/filt/Kconfig new file mode 100644 index 0000000..e69de29 diff --git a/src/filt/filt.h b/src/filt/filt.h new file mode 100644 index 0000000..9ce2caa --- /dev/null +++ b/src/filt/filt.h @@ -0,0 +1,16 @@ +#ifndef __RADIOLA_FILT_H +#define __RADIOLA_FILT_H + +#include +#include +#include +#include +#include + +//fifth order filter from rtlsdr +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/src/filt/filt_5th.c b/src/filt/filt_5th.c new file mode 100644 index 0000000..23d5aab --- /dev/null +++ b/src/filt/filt_5th.c @@ -0,0 +1,32 @@ +#include "filt.h" + +void f_5th(int16_t *data, int length, int16_t *hist) +/* for half of interleaved data */ +{ + int i; + int16_t a, b, c, d, e, f; + a = hist[1]; + b = hist[2]; + c = hist[3]; + d = hist[4]; + e = hist[5]; + f = data[0]; + /* a downsample should improve resolution, so don't fully shift */ + data[0] = (a + (b+e)*5 + (c+d)*10 + f) >> 4; + for (i=4; i> 4; + } + /* archive */ + hist[0] = a; + hist[1] = b; + hist[2] = c; + hist[3] = d; + hist[4] = e; + hist[5] = f; +} diff --git a/src/filt/filt_delay.c b/src/filt/filt_delay.c new file mode 100644 index 0000000..53da0b0 --- /dev/null +++ b/src/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/src/filt/make.mk b/src/filt/make.mk new file mode 100644 index 0000000..51aa82a --- /dev/null +++ b/src/filt/make.mk @@ -0,0 +1,11 @@ +DIR_FILT = filt/ +SOURCES_FILT += $(SRC_DIR)filt/filt_5th.c $(SRC_DIR)filt/filt_delay.c +OBJECTS_FILT += $(SOURCES_FILT:.c=.o) +LDFLAGS += +LDFLAGS_BSD += + + +OBJECTS_DIR_FILT += $(subst $(SRC_DIR)$(DIR_FILT),$(BUILD_DIR)$(SRC_DIR)$(DIR_FILT),$(OBJECTS_FILT)) + +OBJECTS += $(OBJECTS_FILT) +OBJECTS_FINAL += $(OBJECTS_DIR_FILT) \ No newline at end of file -- cgit v1.2.3