Merged master
This commit is contained in:
commit
1258ff4919
@ -21,6 +21,13 @@ typedef struct Sosfilterbank {
|
|||||||
dmat state;
|
dmat state;
|
||||||
} Sosfilterbank;
|
} Sosfilterbank;
|
||||||
|
|
||||||
|
us Sosfilterbank_getFilterbankSize(const Sosfilterbank* fb) {
|
||||||
|
fsTRACE(15);
|
||||||
|
assertvalidptr(fb);
|
||||||
|
return fb->filterbank_size;
|
||||||
|
feTRACE(15);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Sosfilterbank* Sosfilterbank_create(const us filterbank_size,
|
Sosfilterbank* Sosfilterbank_create(const us filterbank_size,
|
||||||
const us nsections) {
|
const us nsections) {
|
||||||
|
@ -23,6 +23,14 @@ typedef struct Sosfilterbank Sosfilterbank;
|
|||||||
Sosfilterbank* Sosfilterbank_create(const us filterbank_size,
|
Sosfilterbank* Sosfilterbank_create(const us filterbank_size,
|
||||||
const us nsections);
|
const us nsections);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of channels in the filterbank (the filberbank size).
|
||||||
|
*
|
||||||
|
* @param[in] fb: Filterbank handle
|
||||||
|
* @return The number of filters in the bank
|
||||||
|
* */
|
||||||
|
us Sosfilterbank_getFilterbankSize(const Sosfilterbank* fb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the filter coeficients in the filterbank
|
* Initialize the filter coeficients in the filterbank
|
||||||
*
|
*
|
||||||
@ -30,7 +38,7 @@ Sosfilterbank* Sosfilterbank_create(const us filterbank_size,
|
|||||||
* @param filter_no: Filter number in the bank
|
* @param filter_no: Filter number in the bank
|
||||||
* @param coefss: Array of filter coefficients. Should have a length of
|
* @param coefss: Array of filter coefficients. Should have a length of
|
||||||
* nsections x 6, for each of the sections, it contains (b0, b1, b2, a0,
|
* nsections x 6, for each of the sections, it contains (b0, b1, b2, a0,
|
||||||
* a1, a2), where a are the numerator coefficients and b are the denominator
|
* a1, a2), where b are the numerator coefficients and a are the denominator
|
||||||
* coefficients.
|
* coefficients.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -136,29 +136,57 @@ class SPLFilterDesigner:
|
|||||||
z, p, k = bilinear_zpk(zeros_analog, poles_analog, k_analog, fs)
|
z, p, k = bilinear_zpk(zeros_analog, poles_analog, k_analog, fs)
|
||||||
sos = zpk2sos(z, p, k)
|
sos = zpk2sos(z, p, k)
|
||||||
return sos
|
return sos
|
||||||
|
# return z, p, k
|
||||||
|
# return zeros_analog, poles_analog, k_analog
|
||||||
|
|
||||||
def A_Sos_design(self, fs):
|
def show_Afir():
|
||||||
"""
|
from asceefig.plot import Figure
|
||||||
Create filter coefficients of the A-weighting filter. Uses the bilinear
|
|
||||||
transform to convert the analog filter to a digital one.
|
|
||||||
|
|
||||||
Args:
|
fs = 48000.
|
||||||
fs: Sampling frequency [Hz]
|
freq_design = np.linspace(0, 17e3, 3000)
|
||||||
|
freq_design[-1] = fs/2
|
||||||
|
amp_design = A(freq_design)
|
||||||
|
amp_design[-1] = 0.
|
||||||
|
firs = []
|
||||||
|
|
||||||
Returns:
|
# firs.append(arbitrary_fir_design(fs,L,freq_design,amp_design,window='hamming'))
|
||||||
Sos: Second order sections
|
# firs.append(arbitrary_fir_design(fs,L,freq_design,amp_design,window='hann'))
|
||||||
"""
|
firs.append(A_fir_design())
|
||||||
# Poles of A-filter
|
# from scipy.signal import iirdesign
|
||||||
p1 = 2*np.pi*self.f1
|
# b,a = iirdesign()
|
||||||
p2 = 2*np.pi*self.f2
|
freq_check = np.logspace(0, np.log10(fs/2), 5000)
|
||||||
p3 = 2*np.pi*self.f3
|
f = Figure()
|
||||||
p4 = 2*np.pi*self.f4
|
|
||||||
|
|
||||||
zeros_analog = [0,0,0,0]
|
f.semilogx(freq_check, 20*np.log10(A(freq_check)))
|
||||||
poles_analog = [p1, p1, p2, p3, p4, p4]
|
for fir in firs:
|
||||||
k_analog = p4**2/self._A_uncor(self.fr)
|
H = freqResponse(fs, freq_check, fir)
|
||||||
|
f.plot(freq_check, 20*np.log10(np.abs(H)))
|
||||||
|
|
||||||
z, p, k = bilinear_zpk(zeros_analog, poles_analog, k_analog, fs)
|
f.fig.get_axes()[0].set_ylim(-75, 3)
|
||||||
sos = zpk2sos(z, p, k)
|
|
||||||
return sos
|
|
||||||
|
def show_Cfir():
|
||||||
|
from asceefig.plot import Figure
|
||||||
|
|
||||||
|
fs = 48000.
|
||||||
|
freq_design = np.linspace(0, 17e3, 3000)
|
||||||
|
freq_design[-1] = fs/2
|
||||||
|
amp_design = C(freq_design)
|
||||||
|
amp_design[-1] = 0.
|
||||||
|
firs = []
|
||||||
|
|
||||||
|
# firs.append(arbitrary_fir_design(fs,L,freq_design,amp_design,window='hamming'))
|
||||||
|
# firs.append(arbitrary_fir_design(fs,L,freq_design,amp_design,window='hann'))
|
||||||
|
firs.append(C_fir_design())
|
||||||
|
# from scipy.signal import iirdesign
|
||||||
|
# b,a = iirdesign()
|
||||||
|
freq_check = np.logspace(0, np.log10(fs/2), 5000)
|
||||||
|
f = Figure()
|
||||||
|
|
||||||
|
f.semilogx(freq_check, 20*np.log10(C(freq_check)))
|
||||||
|
for fir in firs:
|
||||||
|
H = freqResponse(fs, freq_check, fir)
|
||||||
|
f.plot(freq_check, 20*np.log10(np.abs(H)))
|
||||||
|
|
||||||
|
f.fig.get_axes()[0].set_ylim(-30, 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user