55"""
66Create 2nd-order IIR filters with Butterworth design.
77
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.
1012"""
1113
1214
@@ -20,8 +22,8 @@ def make_lowpass(
2022
2123 >>> filter = make_lowpass(1000, 48000)
2224 >>> 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]
2527 """
2628 w0 = tau * frequency / samplerate
2729 _sin = sin (w0 )
@@ -50,8 +52,8 @@ def make_highpass(
5052
5153 >>> filter = make_highpass(1000, 48000)
5254 >>> 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]
5557 """
5658 w0 = tau * frequency / samplerate
5759 _sin = sin (w0 )
@@ -80,8 +82,8 @@ def make_bandpass(
8082
8183 >>> filter = make_bandpass(1000, 48000)
8284 >>> 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]
8587 """
8688 w0 = tau * frequency / samplerate
8789 _sin = sin (w0 )
@@ -111,8 +113,8 @@ def make_allpass(
111113
112114 >>> filter = make_allpass(1000, 48000)
113115 >>> 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]
116118 """
117119 w0 = tau * frequency / samplerate
118120 _sin = sin (w0 )
@@ -139,8 +141,8 @@ def make_peak(
139141
140142 >>> filter = make_peak(1000, 48000, 6)
141143 >>> 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]
144146 """
145147 w0 = tau * frequency / samplerate
146148 _sin = sin (w0 )
@@ -171,8 +173,8 @@ def make_lowshelf(
171173
172174 >>> filter = make_lowshelf(1000, 48000, 6)
173175 >>> 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]
176178 """
177179 w0 = tau * frequency / samplerate
178180 _sin = sin (w0 )
@@ -208,8 +210,8 @@ def make_highshelf(
208210
209211 >>> filter = make_highshelf(1000, 48000, 6)
210212 >>> 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]
213215 """
214216 w0 = tau * frequency / samplerate
215217 _sin = sin (w0 )
0 commit comments