-
Notifications
You must be signed in to change notification settings - Fork 4
/
bandfilters.sce
48 lines (39 loc) · 988 Bytes
/
bandfilters.sce
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
ncoef = 128;
amp = 32768;
fs = 48000;
f1 = 150/fs;
f2 = 600/fs;
f3 = 2900/fs;
fid = mopen("bandfilters.h", "w");
if (fid == -1)
error("cannot open file for writing");
end
mfprintf(fid, "/* Generated automatically by bandfilters.sce. Do not edit manually. */\n\n");
mfprintf(fid, "static const int bass_filter[%d] = {\n", ncoef);
bass = ffilt("lp", ncoef, f1);
for i=1:ncoef
mfprintf(fid, "%d,\n", amp*bass(i));
end
mfprintf(fid, "};\n\n");
mfprintf(fid, "static const int mid_filter[%d] = {\n", ncoef);
mid = ffilt("bp", ncoef, f1, f2);
for i=1:ncoef
mfprintf(fid, "%d,\n", amp*mid(i));
end
mfprintf(fid, "};\n\n");
mfprintf(fid, "static const int treb_filter[%d] = {\n", ncoef);
treb = ffilt("bp", ncoef, f2, f3);
for i=1:ncoef
mfprintf(fid, "%d,\n", amp*treb(i));
end
mfprintf(fid, "};\n\n");
mclose(fid);
// To plot :
//
//[hm,fr] = frmag(bass, 256);
//plot2d(fr',hm');
//[hm,fr] = frmag(mid, 256);
//plot2d(fr',hm');
//[hm,fr] = frmag(treb, 256);
//plot2d(fr',hm');
quit