-
Notifications
You must be signed in to change notification settings - Fork 0
/
irf.js
104 lines (103 loc) · 2.02 KB
/
irf.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const chev_filter_presets = [
[
0.01,
0.0008663387, 0,
0.001732678, 1.919129,
0.0008663387, -0.9225943
],
[
0.025,
0.005112374,
0.00001504626,
0.01022475,
1.797154,
0.005112374,
-0.8176033
],
[
0.05,
0.01868823,
0.0002141509,
0.03737647,
1.593937,
0.01868823,
-0.6686903
],
[
0.075,
0.0386943,
0.0009726342,
0.0773886,
1.392667,
0.0386943,
-0.5474446
],
[
0.1,
0.06372802,
0.002780755,
0.127456,
1.194365,
0.06372802,
-0.4492774
],
[
0.15, 0.1254285,
0.01180009, 0.250857,
0.8070778, 0.1254285,
-0.3087918
],
[
0.2, 0.1997396,
0.03224554, 0.3994792,
0.4291048, 0.1997396,
-0.2280633
],
[
0.25, 0.285811,
0.07015301, 0.5716221,
0.05423258, 0.285811,
-0.1974768
],
[
0.3, 0.3849163,
0.1335566, 0.7698326,
-0.3249116, 0.3849163,
-0.2147536
],
[
0.35, 0.5001024,
0.2340973, 1.000205,
-0.7158993, 0.5001024,
-0.2845103
],
[
0.4, 0.6362308,
0.3896966, 1.272462,
-1.125379, 0.6362308,
-0.4195441
],
[
0.45, 0.8001101,
0.6291693, 1.60022,
-1.556269, 0.8001101,
-0.6441713
]
];
function ct2hz(cents) {
return 8.176 * Math.pow(2.0, cents / 1200.0);
}
export default function get_iirf(ctx, freq, sr) {
const fc = ct2hz(freq);// / sr;
console.log(ct2hz(freq), freq, sr, fc);
for (const [fcc, b0, a0, b1, a1, b2, a2] of chev_filter_presets) {
console.log(fc, 'vs', fcc);
if (fcc > fc / 48000) {
return new IIRFilterNode(ctx, {
feedback: [b0, b1, b2],
feedforward: [a0, a1, a2],
});
}
}
return null;
}