-
Notifications
You must be signed in to change notification settings - Fork 0
/
VSLM_filters.py
64 lines (49 loc) · 3.41 KB
/
VSLM_filters.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
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
# VSLM_filters.py
# This file returns 5th order IIR filter coefficients for A and C weighted
# filters for a given sampling frequency of 22, 44, 48, or 96 kHz.
#
#
# The filter coefficients created by generating a freq response curve in MATLAB
# The freq response curve is generated using the ANSI S1.42 and MATLAB freqs
# The filter coefficients were found by inverting freq response curve using
# MATLAB invfreqz. This is more accurate than using the bilinear transform
# b coefficients are the numerators, a coefficients are the denominators
#
# 27-Oct-2018 Ralph Muehleisen
def awt_design(fs):
# choose filter coefficients based on sampling frequency
if abs(fs - 22050) < 0.001:
# from invfreqzw(22050, "A", 5, 2048, 0.990)
a = [1.00000000000000, -3.73261225019353, 5.17810591633653, -3.12994928108332, 0.656107238402624, 0.0283485805865765]
b = [0.890176119617637, -3.30094510608969, 4.30207690054463, -2.00232132041455, -0.148688234435067, 0.259701640776960]
elif abs(fs - 44100) < 0.001:
# from invfreqzw(44100, "A", 5, 2048, 0.994)
a = [1.00000000000000, -4.14030658173254, 6.65276117461792, -5.11480686908108, 1.83256386636597, -0.230211580521527]
b = [0.629584036659726, -2.27411727146471, 2.80064301448737, -1.05306578343937, -0.347248574020498, 0.244204577777479]
elif abs(fs - 48000) < 0.001:
# from invfreqzw(48000, "A", 5, 2048, 0.993)
a = [1.00000000000000, -4.19159237574137, 6.84599956726162, -5.38713399949207, 2.00264419150845, -0.269917377010070]
b = [0.588511587030434, -2.11372727191972, 2.56980702791811, -0.912173327794927, -0.372723275630642, 0.240305260396735]
else: # otherwise assume fs = 96000 Hz
# from invfreqzw(96000, "A", 5, 4096, 0.970)
a = [1.00000000000000, -3.86822721642028, 5.82534354841227, -4.24986218202641, 1.49672889224926, -0.203982862802550]
b = [0.279902790778685, -0.750834748797596, 0.560578951953746, 0.0239393041782461, -0.125790223664751, 0.0122039254755701]
return [b, a]
def cwt_design(fs):
if abs(fs - 22050) < 0.001:
# from invfreqzw(22050, "C", 5, 2048, 0.600)
a = [1.00000000000000, -1.17464719843225, -0.554345810266849, 0.647418620849631, 0.0889180246259013, -0.00728006857786818]
b = [0.800675259706111, -0.745089503694298, -0.695567152733068, 0.433907189797665, 0.195702587144663, 0.0103716251248267]
elif abs(fs - 44100) < 0.001:
# from invfreqzw(44100, "C", 5, 4096, 0.850)
a = [1.00000000000000, -1.84797019064638, 0.344893264701284, 0.929264073763538, -0.496256560731038, 0.0700768736746900]
b = [0.534720653033672, -0.643980774017942, -0.368069457504618, 0.483314207862860, 0.0398970894689278, -0.0458817202829421]
elif abs(fs - 48000) < 0.001:
# from invfreqzw(48000, "C", 5, 4096, 0.860)
a = [1.00000000000000, -1.87902525769601, 0.496210884028678, 0.699269445528909, -0.366207830803829, 0.0497593120477516]
b = [0.497614271678798, -0.583913345000611, -0.310279388238900, 0.359868001138611, 0.0586756087904432, -0.0219651485428612]
else: # otherwise Fs is 96000 Hz
# from invfreqzw(96000, "C", 5, 4096, 0.840)
a = [1.00000000000000, -2.37631043038297, 1.48755568101990, 0.260428966202263, -0.477038417794698, 0.105365042123360]
b = [0.230167302849238, -0.261304376923445, -0.134276974871471, 0.131512279719116, 0.0341758923092667, -0.000274122862838129]
return [b, a]