-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_fs.c
50 lines (40 loc) · 1.3 KB
/
test_fs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "lo_pass.h"
int main(int argc, char **argv) {
filtpar *pars = mce_filter();
if (argc != 5) {
printf("This program requires exactly 4 arguments.\n");
printf(" n_chan n_samp input_file output_file\n");
return 1;
}
/* Load the input data */
int n_chan = atoi(argv[1]);
int n_samp = atoi(argv[2]);
FILE *fin = fopen(argv[3], "r");
int32_t *buf0 = calloc(n_samp*n_chan, sizeof(*buf0));
int32_t *buf1 = calloc(n_samp*n_chan, sizeof(*buf1));
fread(buf0, sizeof(*buf0), n_samp*n_chan, fin);
/* Create filter */
filtbank *bank1 = create_filtbank(n_chan, pars+0);
filtbank *bank2 = create_filtbank(n_chan, pars+1);
int32_t *output;
if (0) {
filter_data(bank1, buf0, buf1, n_samp);
filter_data(bank2, buf1, buf0, n_samp);
output = buf0;
} else {
filtbank banks[2];
memcpy(&banks[0], bank1, sizeof(*bank1));
memcpy(&banks[1], bank2, sizeof(*bank2));
multi_filter_data(banks, 2, buf0, buf1, n_samp);
output = buf1;
}
/* Write output. */
FILE *fout = fopen(argv[4], "w");
fwrite(output, sizeof(*output), n_samp*n_chan, fout);
fclose(fout);
return 0;
}