File: coeff.m

package info (click to toggle)
baycomusb 0.10-15.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,884 kB
  • sloc: ansic: 49,182; asm: 17,572; sh: 2,442; makefile: 542; pascal: 183; sed: 93; perl: 31
file content (30 lines) | stat: -rw-r--r-- 631 bytes parent folder | download | duplicates (17)
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
%
fs=16000;
overs=16;
fg1=3500;
fg2=4500;
flen=16;

%c=remez(overs*flen-1,[ 0 2*fg1/fs/overs 2*fg2/fs/overs 1 ], [ 1 1 0 0 ]);
c=sinc((0.5-overs*flen/2:overs*flen/2-0.5)*(2*fg2/fs/overs)).*hamming(overs*flen)';

for t=1:overs,
  tt(t) = sum(abs(c(t:16:overs*flen)));
end;

c=c./max(tt);

t1=fft(c);
plot((0:overs*flen-1)*fs/flen,20*log10(abs(t1)));

fid=fopen('filter.txt','w');
fprintf(fid,'static const int16_t rxfilter[%d][%d] = {\n',overs,flen);
for t=1:overs,
  fprintf(fid,'\t{ ');
  for tt=0:flen-1,
    fprintf(fid, '%6d, ', round(c(tt*overs+t) * 65536));
  end;
  fprintf(fid,'},\n');
end;
fprintf(fid,'};');
fclose(fid);