-
Notifications
You must be signed in to change notification settings - Fork 25
/
freqpoles.py
36 lines (29 loc) · 1021 Bytes
/
freqpoles.py
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
# FREQPOLES - Pole set generation for the PARFILTDES function.
# [P]=freqpoles(FR,Fs) creates poles from the given frequency vector
# FR with sampling frequency Fs such that the frequency responses
# of the second-order basis functions cross approximatelly at their
# -3 dB point.
# (See the equations in my 128th AES Convention paper.)
#
# [P]=freqpoles(FR,Fs,Q) creates poles from the given frequency vector
# FR with sampling frequency Fs but it uses the quality factors
# given in Q vector to set the radius of the poles. (-3dB bandwidth
# is DeltaF=FR/Q.)
#
# C. Balazs Bank, 2010.
import numpy as np
def freqpoles(fr, Fs = 44100, Q = None):
# discrete pole frequencies
wp = 2 * np.pi * fr / Fs
dwp = []
if Q is None:
pnum = wp.size
dwp = np.zeros(pnum)
for k in range(1, pnum-1):
dwp[k] = (wp[k+1] - wp[k-1])/2
dwp[0] = wp[1] - wp[0]
dwp[pnum-1] = wp[pnum-1] - wp[pnum-2]
else:
dwp = wp / Q
p = np.exp(-dwp/2) * np.exp(1j * wp)
return np.hstack([p, p.conj()])