bf_freq_domain_filters.m 1.71 KB
Newer Older
1
filt_len = 16;
2 3

F = -3/4:1/4:7/4;
4 5 6
F_l = zeros(8,filt_len);
F_r = zeros(8,filt_len);
F_m = zeros(8,filt_len);
7 8 9 10

F2 =-3/5:1/5:8/5;

for i=0:3
11 12 13
  F_l(i+1,:)  = floor(16384*[F(8+i:-1:4) zeros(1,7-i) zeros(1,4)]);
  F_r(i+1,:)  = floor(16384*[zeros(1,4+i) F(4:end-i) zeros(1,4)]);
  F_m(i+1,:)  = floor(16384*[F(4-i:8) F(7:-1:1+i) zeros(1,4)]);
14 15 16
end

for i=0:1
17 18 19
  F_l(i+5,:)  = floor(16384*[F(8:-1:4-i) zeros(1,7-i) zeros(1,4)]);
  F_r(i+5,:)  = floor(16384*[zeros(1,5+i) F2(5+i) F2(7:end-i) zeros(1,4)]);
  F_m(i+5,:)  = floor(16384*[F(4-i:8) F2(8-i) F2(6:-1:1+i) zeros(1,4)]);
20 21 22
end

for i=2:3
23 24 25
  F_l(i+5,:)  = floor(16384*[F2(end:-1:7) F2(8-i) zeros(1,5) zeros(1,4)]);
  F_r(i+5,:)  = floor(16384*[zeros(1,4+i) F(4:end-i) zeros(1,4)]);
  F_m(i+5,:)  = floor(16384*[F2(4-i:6) F2(4+i) F(8:-1:1+i) zeros(1,4)]);
26 27 28
end


29
fd = fopen("filt16_32.h","w");
30 31

for i=0:3
32
  fprintf(fd,"short filt%d_l%d[%d] = {\n",filt_len,i,filt_len);
33 34 35
  fprintf(fd,"%d,",F_l(i+1,1:end-1));
  fprintf(fd,"%d};\n\n",F_l(i+1,end));
  
36
  fprintf(fd,"short filt%d_r%d[%d] = {\n",filt_len,i,filt_len);
37 38 39
  fprintf(fd,"%d,",F_r(i+1,1:end-1));
  fprintf(fd,"%d};\n\n",F_r(i+1,end));
  
40
  fprintf(fd,"short filt%d_m%d[%d] = {\n",filt_len,i,filt_len);
41 42 43 44 45
  fprintf(fd,"%d,",F_m(i+1,1:end-1));
  fprintf(fd,"%d};\n\n",F_m(i+1,end));
end

for i=0:3
46
  fprintf(fd,"short filt%d_l%d_dc[%d] = {\n",filt_len,i,filt_len);
47 48 49
  fprintf(fd,"%d,",F_l(i+5,1:end-1));
  fprintf(fd,"%d};\n\n",F_l(i+5,end));
  
50
  fprintf(fd,"short filt%d_r%d_dc[%d] = {\n",filt_len,i,filt_len);
51 52 53
  fprintf(fd,"%d,",F_r(i+5,1:end-1));
  fprintf(fd,"%d};\n\n",F_r(i+5,end));
  
54
  fprintf(fd,"short filt%d_m%d_dc[%d] = {\n",filt_len,i,filt_len);
55 56 57 58 59
  fprintf(fd,"%d,",F_m(i+5,1:end-1));
  fprintf(fd,"%d};\n\n",F_m(i+5,end));
end

fclose(fd);