5
5
"""
6
6
Create 2nd-order IIR filters with Butterworth design.
7
7
8
- Code based on https://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html
9
- Alternatively you can use scipy.signal.butter, which should yield the same results.
8
+ Code based on
9
+ https://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html
10
+ Alternatively you can use scipy.signal.butter,
11
+ which should yield the same results.
10
12
"""
11
13
12
14
@@ -20,8 +22,8 @@ def make_lowpass(
20
22
21
23
>>> filter = make_lowpass(1000, 48000)
22
24
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
23
- [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, 0.004277569313094809,
24
- 0.008555138626189618, 0.004277569313094809]
25
+ [1.0922959556412573, -1.9828897227476208, 0.9077040443587427,
26
+ 0.004277569313094809, 0.008555138626189618, 0.004277569313094809]
25
27
"""
26
28
w0 = tau * frequency / samplerate
27
29
_sin = sin (w0 )
@@ -50,8 +52,8 @@ def make_highpass(
50
52
51
53
>>> filter = make_highpass(1000, 48000)
52
54
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
53
- [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, 0.9957224306869052,
54
- -1.9914448613738105, 0.9957224306869052]
55
+ [1.0922959556412573, -1.9828897227476208, 0.9077040443587427,
56
+ 0.9957224306869052, -1.9914448613738105, 0.9957224306869052]
55
57
"""
56
58
w0 = tau * frequency / samplerate
57
59
_sin = sin (w0 )
@@ -80,8 +82,8 @@ def make_bandpass(
80
82
81
83
>>> filter = make_bandpass(1000, 48000)
82
84
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
83
- [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, 0.06526309611002579,
84
- 0, -0.06526309611002579]
85
+ [1.0922959556412573, -1.9828897227476208,
86
+ 0.9077040443587427, 0.06526309611002579, 0, -0.06526309611002579]
85
87
"""
86
88
w0 = tau * frequency / samplerate
87
89
_sin = sin (w0 )
@@ -111,8 +113,8 @@ def make_allpass(
111
113
112
114
>>> filter = make_allpass(1000, 48000)
113
115
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
114
- [1.0922959556412573, -1.9828897227476208, 0.9077040443587427, 0.9077040443587427,
115
- -1.9828897227476208, 1.0922959556412573]
116
+ [1.0922959556412573, -1.9828897227476208, 0.9077040443587427,
117
+ 0.9077040443587427, -1.9828897227476208, 1.0922959556412573]
116
118
"""
117
119
w0 = tau * frequency / samplerate
118
120
_sin = sin (w0 )
@@ -139,8 +141,8 @@ def make_peak(
139
141
140
142
>>> filter = make_peak(1000, 48000, 6)
141
143
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
142
- [1.0653405327119334, -1.9828897227476208, 0.9346594672880666, 1.1303715025601122,
143
- -1.9828897227476208, 0.8696284974398878]
144
+ [1.0653405327119334, -1.9828897227476208, 0.9346594672880666,
145
+ 1.1303715025601122, -1.9828897227476208, 0.8696284974398878]
144
146
"""
145
147
w0 = tau * frequency / samplerate
146
148
_sin = sin (w0 )
@@ -171,8 +173,8 @@ def make_lowshelf(
171
173
172
174
>>> filter = make_lowshelf(1000, 48000, 6)
173
175
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
174
- [3.0409336710888786, -5.608870992220748, 2.602157875636628, 3.139954022810743,
175
- -5.591841778072785, 2.5201667380627257]
176
+ [3.0409336710888786, -5.608870992220748, 2.602157875636628,
177
+ 3.139954022810743, -5.591841778072785, 2.5201667380627257]
176
178
"""
177
179
w0 = tau * frequency / samplerate
178
180
_sin = sin (w0 )
@@ -208,8 +210,8 @@ def make_highshelf(
208
210
209
211
>>> filter = make_highshelf(1000, 48000, 6)
210
212
>>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE
211
- [2.2229172136088806, -3.9587208137297303, 1.7841414181566304, 4.295432981120543,
212
- -7.922740859457287, 3.6756456963725253]
213
+ [2.2229172136088806, -3.9587208137297303, 1.7841414181566304,
214
+ 4.295432981120543, -7.922740859457287, 3.6756456963725253]
213
215
"""
214
216
w0 = tau * frequency / samplerate
215
217
_sin = sin (w0 )
0 commit comments