diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-05-20 13:43:49 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-05-20 13:43:49 +0100 |
commit | 126fa84b8591c3b285b7f598089451aa22447f10 (patch) | |
tree | 29eb78cd41870a1e4211e45b8e551a94b401ffe7 /cmd_fir1p.c | |
parent | c03a145002445eaaa814e3f133c9a28f991bb860 (diff) | |
download | agni-126fa84b8591c3b285b7f598089451aa22447f10.tar.gz agni-126fa84b8591c3b285b7f598089451aa22447f10.zip |
Moved commands to seperate directory, moved external sources to seperate directory, updated Makefile with auto include and auto compile features
Diffstat (limited to 'cmd_fir1p.c')
-rw-r--r-- | cmd_fir1p.c | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/cmd_fir1p.c b/cmd_fir1p.c deleted file mode 100644 index b011719..0000000 --- a/cmd_fir1p.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "cmd_fir1p.h" - -#define FIR_SIZE 12 - -double fir_coef[FIR_SIZE] = -{ - -0.0044384, -0.0041841, 0.0130183, 0.0746628, - 0.1720210, 0.2489204, 0.2489204, 0.1720210, - 0.0746628, 0.0130183, -0.0041841, -0.0044384 -}; - -#define MAX_INPUT_LEN 80 -#define BUFFER_LEN (FIR_SIZE-1+MAX_INPUT_LEN) -double insamp[BUFFER_LEN]; - -int fir1filter(double *coeffs, double *input, double *output, - int length, int filter_length) -{ - double acc; - double *coeffp; - double *inputp; - int n; - int k; - - memcpy(&insamp[filter_length-1], input, length*sizeof(double)); - - for (n=0; n<length; n++) - { - coeffp = coeffs; - inputp = &insamp[filter_length - 1 + n]; - acc = 0; - - for (k=0;k<filter_length;k++) - { - acc += (*coeffp++)*(*inputp--); - } - - output[n] = acc; - } - - memmove(&insamp[0], &insamp[length], (filter_length-1)*sizeof(double)); - - return 0; -} - -void *cmd_fir1p(void *data) -{ - char *ret = NULL; - int i=0,j=0; - - if (data == NULL) - { - ret = alloc_new_str("FIR filter N=12\n"); - return ret; - } - - double input[MAX_INPUT_LEN]; - double output[MAX_INPUT_LEN]; - - int count; - sds params = sdsnew(data); - sds out_result = sdsempty(); - sds *tokens; - //printf("%s\n",params); - //tokens = sdssplitlen(params, sdslen(params), " ", 1, &count); - tokens = sdssplitargs(params, &count); - - for (i=0;i<count;i++) - { - //printf("[%s]\n",tokens[i]); - input[i] = atof(tokens[i]); - } - - fir1filter(fir_coef, input, output, count, FIR_SIZE); - - for (i=0;i<count;i++) - { - //cut to max size 512 - char str_double[16]; - snprintf(str_double, 16, "%.3f ", output[i]); - out_result = sdscat(out_result, str_double); - } - out_result = sdscat(out_result,"\n"); - - - - ret = alloc_new_str(out_result); - - sdsfree(params); - sdsfree(out_result); - sdsfreesplitres(tokens, count); - - return ret; -}
\ No newline at end of file |